Android 12 Developer Preview is here! Try it out, and give us your feedback!

GraphicsLayerScope

interface GraphicsLayerScope : Density
androidx.compose.ui.graphics.GraphicsLayerScope

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).

Summary

Inherited functions
Properties
abstract Float

The alpha of the drawn area.

abstract 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.

abstract Boolean

Set to true to clip the content to the shape.

abstract Float

The rotation, in degrees, of the contents around the horizontal axis in degrees.

abstract Float

The rotation, in degrees, of the contents around the vertical axis in degrees.

abstract Float

The rotation, in degrees, of the contents around the Z axis in degrees.

abstract Float

The horizontal scale of the drawn area.

abstract Float

The vertical scale of the drawn area.

abstract Float

Sets the elevation for the shadow in pixels.

abstract Shape

The Shape of the layer.

abstract TransformOrigin

Offset percentage along the x and y axis for which contents are rotated and scaled.

abstract Float

Horizontal pixel offset of the layer relative to its left bound.

abstract Float

Vertical pixel offset of the layer relative to its top bound.

Inherited properties

Properties

alpha

abstract var 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.

cameraDistance

abstract var 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.

The distance of the camera from the drawing plane can have an affect on the perspective distortion of the layer when it is rotated around the x or y axis. For example, a large distance will result in a large viewing angle, and there will not be much perspective distortion of the view as it rotates. A short distance may cause much more perspective distortion upon rotation, and can also result in some drawing artifacts if the rotated view ends up partially behind the camera (which is why the recommendation is to use a distance at least as far as the size of the view, if the view is to be rotated.)

The distance is expressed in pixels and must always be positive. Default value is DefaultCameraDistance

clip

abstract var clip: Boolean

Set to true to clip the content to the shape. Default value is false

rotationX

abstract var rotationX: Float

The rotation, in degrees, of the contents around the horizontal axis in degrees. Default value is 0.

rotationY

abstract var rotationY: Float

The rotation, in degrees, of the contents around the vertical axis in degrees. Default value is 0.