androidx.compose.ui.graphics
GraphicsLayerScope
Interface · from org.jetbrains.compose.ui:ui:1.12.2
No hand-written docs yet.
A scope which can be used to define the effects to apply for the content, such as scaling (scaleX, scaleY), rotation (rotationX, rotationY, rotationZ), opacity (alpha), shadow (shadowElevation, shape), and clipping (clip, shape).
interface GraphicsLayerScope : Density
Is a
How to get one
Create it
GraphicsLayerScope()
Used by
Parameters that take a GraphicsLayerScope.
graphicsLayer(block)Placeable.PlacementScope.placeRelativeWithLayer(layerBlock)Placeable.PlacementScope.placeWithLayer(layerBlock)
Properties
scaleX
val scaleX: Float
The horizontal scale of the drawn area. Default value is 1.
scaleY
val scaleY: Float
The vertical scale of the drawn area. Default value is 1.
alpha
val alpha: Float
The alpha of the drawn area. Setting this to something other than 1 will cause the drawn contents to be translucent and setting it to 0 will cause it to be fully invisible. Default value is 1 and the range is between 0 and 1.
translationX
val translationX: Float
Horizontal pixel offset of the layer relative to its left bound. Default value is 0.
translationY
val translationY: Float
Vertical pixel offset of the layer relative to its top bound. Default value is 0
shadowElevation
val shadowElevation: Float
Sets the elevation for the shadow in pixels. With the shadowElevation > 0f and shape set, a shadow is produced. Default value is 0 and the value must not be negative.
ambientShadowColor
val ambientShadowColor: Color
Sets the color of the ambient shadow that is drawn when shadowElevation > 0f.
spotShadowColor
val spotShadowColor: Color
Sets the color of the spot shadow that is drawn when shadowElevation > 0f.
rotationX
val rotationX: Float
The rotation, in degrees, of the contents around the horizontal axis in degrees. Default value is 0.
rotationY
val rotationY: Float
The rotation, in degrees, of the contents around the vertical axis in degrees. Default value is 0.
rotationZ
val rotationZ: Float
The rotation, in degrees, of the contents around the Z axis in degrees. Default value is 0.
cameraDistance
val cameraDistance: Float
Sets the distance along the Z axis (orthogonal to the X/Y plane on which layers are drawn) from the camera to this layer. The camera's distance affects 3D transformations, for instance rotations around the X and Y axis. If the rotationX or rotationY properties are changed and this view is large (more than half the size of the screen), it is recommended to always use a camera distance that's greater than the height (X axis rotation) or the width (Y axis rotation) of this view.
transformOrigin
val transformOrigin: TransformOrigin
Offset percentage along the x and y axis for which contents are rotated and scaled. The default value of 0.5f, 0.5f indicates the pivot point will be at the midpoint of the left and right as well as the top and bottom bounds of the layer. Default value is TransformOrigin.Center
shape
val shape: Shape
The Shape of the layer. When shadowElevation is non-zero a shadow is produced using this shape. When clip is true contents will be clipped to this shape. When clipping, the content will be redrawn when the shape changes. Default value is RectangleShape
clip
val clip: Boolean
Set to true to clip the content to the shape. Default value is false
renderEffect
val renderEffect: RenderEffect?
Configure the RenderEffect to apply to this GraphicsLayerScope. This will apply a visual effect to the results of the GraphicsLayerScope before it is drawn. For example if BlurEffect is provided, the contents will be drawn in a separate layer, then this layer will be blurred when this GraphicsLayerScope is drawn.
blendModeSince 1.9
val blendMode: BlendMode
BlendMode to use when drawing this layer to the destination. The default is BlendMode.SrcOver. Any value other than BlendMode.SrcOver will force this GraphicsLayerScope to use an offscreen compositing layer for rendering and is equivalent to using CompositingStrategy.Offscreen.
colorFilterSince 1.9
val colorFilter: ColorFilter?
ColorFilter applied when drawing this layer to the destination. Setting of this to any non-null will force this GraphicsLayer to use an offscreen compositing layer for rendering and is equivalent to using CompositingStrategy.Offscreen
compositingStrategy
val compositingStrategy: CompositingStrategy
Determines the CompositingStrategy used to render the contents of this graphicsLayer into an offscreen buffer first before rendering to the destination
size
val size: Size
Size of the graphicsLayer represented in pixels. Drawing commands can extend beyond the size specified, however, if the graphicsLayer is promoted to an offscreen rasterization layer, any content rendered outside of the specified size will be clipped.
outsetsSince 1.12
val outsets: LayerOutsets
Adds to the size of the layer increasing its bounds. This can be used to prevent content that renders outside the layer's size (such as shadows) from being clipped if the graphicsLayer is promoted to an offscreen rasterization layer. The clip and shadow will still be based on the original size of the layer.
Library docs
A scope which can be used to define the effects to apply for the content, such as scaling
(scaleX, scaleY), rotation (rotationX, rotationY, rotationZ), opacity (alpha), shadow
(shadowElevation, shape), and clipping (clip, shape).