Google is committed to advancing racial equity for Black communities. See how.

androidx.compose.ui.graphics.drawscope

Interfaces

ContentDrawScope

Receiver scope for drawing content into a layout, where the content can be drawn between other canvas operations.

DrawContext

Object that provides the dependencies to support a DrawScope drawing environment.

DrawScope

Creates a scoped drawing environment with the provided Canvas.

DrawTransform

Defines transformations that can be applied to a drawing environment

Classes

CanvasDrawScope

Implementation of DrawScope that issues drawing commands into the specified canvas and bounds via CanvasDrawScope.draw

DrawStyle

Represents how the shapes should be drawn within a DrawScope

Stroke

DrawStyle that provides information for drawing content with a stroke

Annotations

DrawScopeMarker

DSL marker used to distinguish between drawing operations and canvas transform operations

Extension functions summary

For DrawScope
Unit
DrawScope.clipPath(path: Path, clipOp: ClipOp = ClipOp.Intersect, block: DrawScope.() -> Unit)

Reduces the clip region to the intersection of the current clip and the given path.

Unit
DrawScope.clipRect(left: Float = 0.0f, top: Float = 0.0f, right: Float = size.width, bottom: Float = size.height, clipOp: ClipOp = ClipOp.Intersect, block: DrawScope.() -> Unit)

Reduces the clip region to the intersection of the current clip and the given rectangle indicated by the given left, top, right and bottom bounds.

Unit

Provides access to draw directly with the underlying Canvas.

Unit
DrawScope.inset(left: Float, top: Float, right: Float, bottom: Float, block: DrawScope.() -> Unit)

Simultaneously translate the DrawScope coordinate space by left and top as well as modify the dimensions of the current painting area.

Unit
DrawScope.inset(inset: Float, block: DrawScope.() -> Unit)

Convenience method modifies the DrawScope bounds to inset both left, top, right and bottom bounds by inset.

Unit
DrawScope.inset(horizontal: Float = 0.0f, vertical: Float = 0.0f, block: DrawScope.() -> Unit)

Convenience method modifies the DrawScope bounds to inset both left and right bounds by horizontal as well as the top and bottom by vertical.

Unit
DrawScope.rotate(degrees: Float, pivot: Offset = center, block: DrawScope.() -> Unit)

Add a rotation (in degrees clockwise) to the current transform at the given pivot point.

Unit
DrawScope.rotateRad(radians: Float, pivot: Offset = center, block: DrawScope.() -> Unit)

Add a rotation (in radians clockwise) to the current transform at the given pivot point.

Unit
DrawScope.scale(scaleX: Float, scaleY: Float, pivot: Offset = center, block: DrawScope.() -> Unit)

Add an axis-aligned scale to the current transform, scaling by the first argument in the horizontal direction and the second in the vertical direction at the given pivot coordinate.

Unit
DrawScope.scale(scale: Float, pivot: Offset = center, block: DrawScope.() -> Unit)

Add an axis-aligned scale to the current transform, scaling both the horizontal direction and the vertical direction at the given pivot coordinate.

Unit
DrawScope.translate(left: Float = 0.0f, top: Float = 0.0f, block: DrawScope.() -> Unit)

Translate the coordinate space by the given delta in pixels in both the x and y coordinates respectively

Unit
DrawScope.withTransform(transformBlock: DrawTransform.() -> Unit, drawBlock: DrawScope.() -> Unit)

Perform 1 or more transformations and execute drawing commands with the specified transformations applied.

For DrawTransform
Unit
DrawTransform.inset(horizontal: Float = 0.0f, vertical: Float = 0.0f)

Convenience method modifies the DrawTransform bounds to inset both left and right bounds by horizontal as well as the top and bottom by vertical.

Unit

Convenience method modifies the DrawScope bounds to inset both left, top, right and bottom bounds by inset.

Unit
DrawTransform.rotateRad(radians: Float, pivot: Offset = center)

Add a rotation (in radians clockwise) to the current transform at the given pivot point.

Unit
DrawTransform.scale(scale: Float, pivot: Offset = center)

Add an axis-aligned scale to the current transform, scaling uniformly in both directions by the provided scale factor at the pivot coordinate.

Extension functions

clipPath

inline fun DrawScope.clipPath(
    path: Path