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

Canvas

interface Canvas
androidx.compose.ui.graphics.Canvas

Summary

Public methods
abstract Unit
clipPath(path: Path, clipOp: ClipOp = ClipOp.Intersect)

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

open Unit
clipRect(rect: Rect, clipOp: ClipOp = ClipOp.Intersect)

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

abstract Unit
clipRect(left: Float, top: Float, right: Float, bottom: Float, clipOp: ClipOp = ClipOp.Intersect)

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

abstract Unit
concat(matrix: Matrix)

Multiply the current transform by the specified 4⨉4 transformation matrix specified as a list of values in column-major order.

abstract Unit

Disables Z support, preventing any layers drawn after this point from being visually reordered or having shadows rendered.

open Unit
drawArc(rect: Rect, startAngle: Float, sweepAngle: Float, useCenter: Boolean, paint: Paint)

Draw an arc scaled to fit inside the given rectangle.

abstract Unit
drawArc(left: Float, top: Float, right: Float, bottom: Float, startAngle: Float, sweepAngle: Float, useCenter: Boolean, paint: Paint)

Draw an arc scaled to fit inside the given rectangle.

open Unit
drawArcRad(rect: Rect, startAngleRad: Float, sweepAngleRad: Float, useCenter: Boolean, paint: Paint)

Draw an arc scaled to fit inside the given rectangle.

abstract Unit
drawCircle(center: Offset, radius: Float, paint: Paint)

Draws a circle centered at the point given by the first argument and that has the radius given by the second argument, with the Paint given in the third argument.

abstract Unit
drawImage(image: ImageBitmap, topLeftOffset: Offset, paint: Paint)

Draws the given ImageBitmap into the canvas with its top-left corner at the given Offset.

abstract Unit
drawImageRect(image: ImageBitmap, srcOffset: IntOffset = IntOffset.Zero, srcSize: IntSize = IntSize(image.width, image.height), dstOffset: IntOffset = IntOffset.Zero, dstSize: IntSize = srcSize, paint: Paint)

Draws the subset of the given image described by the src argument into the canvas in the axis-aligned rectangle given by the dst argument.

abstract Unit
drawLine(p1: Offset, p2: Offset, paint: Paint)

Draws a line between the given points using the given paint.

open Unit
drawOval(rect: Rect, paint: Paint)

Draws an axis-aligned oval that fills the given axis-aligned rectangle with the given Paint.

abstract Unit
drawOval(left: Float, top: Float, right: Float, bottom: Float, paint: Paint)

Draws an axis-aligned oval that fills the given bounds provided with the given Paint.

abstract Unit
drawPath(path: Path, paint: Paint)

Draws the given Path with the given Paint.

abstract Unit
drawPoints(pointMode: PointMode, points: List<Offset>, paint: Paint)

Draws a sequence of points according to the given PointMode.

abstract Unit
drawRawPoints(pointMode: PointMode, points: FloatArray, paint: Paint)

Draws a sequence of points according to the given PointMode.

open Unit
drawRect(rect: Rect, paint: Paint)

Draws a rectangle with the given Paint.

abstract Unit
drawRect(left: Float, top: Float, right: Float, bottom: Float, paint: Paint)

Draws a rectangle with the given Paint.

abstract Unit
drawRoundRect(left: Float, top: Float, right: Float, bottom: Float, radiusX: Float, radiusY: Float, paint: Paint)

Draws a rounded rectangle with the given Paint.

abstract Unit
drawVertices(vertices: Vertices, blendMode: BlendMode, paint: Paint)

abstract Unit

Enables Z support which defaults to disabled.

abstract Unit

Pops the current save stack, if there is anything to pop.

abstract Unit
rotate(degrees: Float)

Add a rotation (in degrees clockwise) to the current transform

abstract Unit

Saves a copy of the current transform and clip on the save stack.

abstract Unit
saveLayer(bounds: Rect, paint: Paint)

Saves a copy of the current transform and clip on the save stack, and then creates a new group which subsequent calls will become a part of.

abstract Unit