# Canvas

Artifact: [androidx.compose.ui:ui-graphics](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/graphics/Canvas.kt+class:androidx.compose.ui.graphics.Canvas) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0) Common/AllAndroid/JVM
- Cmn

  ```
  interface Canvas
  ```

*** ** * ** ***

## Summary

| ### Public functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#clipPath(androidx.compose.ui.graphics.Path,androidx.compose.ui.graphics.ClipOp)(path: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Path, clipOp: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/ClipOp)` Reduces the clip region to the intersection of the current clip and the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Path`. | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#clipRect(androidx.compose.ui.geometry.Rect,androidx.compose.ui.graphics.ClipOp)(rect: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Rect, clipOp: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/ClipOp)` Reduces the clip region to the intersection of the current clip and the given rectangle. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#clipRect(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,androidx.compose.ui.graphics.ClipOp)(left: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, top: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, right: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, bottom: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, clipOp: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/ClipOp)` Reduces the clip region to the intersection of the current clip and the given bounds. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#concat(androidx.compose.ui.graphics.Matrix)(matrix: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Matrix)` Multiply the current transform by the specified 4⨉4 transformation matrix specified as a list of values in column-major order. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#disableZ()()` Disables Z support, preventing any layers drawn after this point from being visually reordered or having shadows rendered. | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#drawArc(androidx.compose.ui.geometry.Rect,kotlin.Float,kotlin.Float,kotlin.Boolean,androidx.compose.ui.graphics.Paint)( rect: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Rect, startAngle: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, sweepAngle: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, useCenter: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, paint: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint )` Draw an arc scaled to fit inside the given rectangle. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#drawArc(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Boolean,androidx.compose.ui.graphics.Paint)( left: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, top: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, right: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, bottom: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, startAngle: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, sweepAngle: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, useCenter: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, paint: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint )` Draw an arc scaled to fit inside the given rectangle. | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#drawArcRad(androidx.compose.ui.geometry.Rect,kotlin.Float,kotlin.Float,kotlin.Boolean,androidx.compose.ui.graphics.Paint)( rect: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Rect, startAngleRad: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, sweepAngleRad: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, useCenter: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, paint: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint )` Draw an arc scaled to fit inside the given rectangle. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#drawCircle(androidx.compose.ui.geometry.Offset,kotlin.Float,androidx.compose.ui.graphics.Paint)(center: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset, radius: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, paint: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/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 `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint` given in the third argument. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#drawImage(androidx.compose.ui.graphics.ImageBitmap,androidx.compose.ui.geometry.Offset,androidx.compose.ui.graphics.Paint)(image: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/ImageBitmap, topLeftOffset: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset, paint: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint)` Draws the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/ImageBitmap` into the canvas with its top-left corner at the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#drawImageRect(androidx.compose.ui.graphics.ImageBitmap,androidx.compose.ui.unit.IntOffset,androidx.compose.ui.unit.IntSize,androidx.compose.ui.unit.IntOffset,androidx.compose.ui.unit.IntSize,androidx.compose.ui.graphics.Paint)( image: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/ImageBitmap, srcOffset: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntOffset, srcSize: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntSize, dstOffset: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntOffset, dstSize: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntSize, paint: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/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. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#drawLine(androidx.compose.ui.geometry.Offset,androidx.compose.ui.geometry.Offset,androidx.compose.ui.graphics.Paint)(p1: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset, p2: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset, paint: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint)` Draws a line between the given points using the given paint. | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#drawOval(androidx.compose.ui.geometry.Rect,androidx.compose.ui.graphics.Paint)(rect: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Rect, paint: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint)` Draws an axis-aligned oval that fills the given axis-aligned rectangle with the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#drawOval(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,androidx.compose.ui.graphics.Paint)(left: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, top: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, right: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, bottom: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, paint: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint)` Draws an axis-aligned oval that fills the given bounds provided with the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#drawPath(androidx.compose.ui.graphics.Path,androidx.compose.ui.graphics.Paint)(path: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Path, paint: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint)` Draws the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Path` with the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#drawPoints(androidx.compose.ui.graphics.PointMode,kotlin.collections.List,androidx.compose.ui.graphics.Paint)(pointMode: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/PointMode, points: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset>, paint: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint)` Draws a sequence of points according to the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/PointMode`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#drawRawPoints(androidx.compose.ui.graphics.PointMode,kotlin.FloatArray,androidx.compose.ui.graphics.Paint)(pointMode: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/PointMode, points: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float-array/index.html, paint: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint)` Draws a sequence of points according to the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/PointMode`. | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#drawRect(androidx.compose.ui.geometry.Rect,androidx.compose.ui.graphics.Paint)(rect: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Rect, paint: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint)` Draws a rectangle with the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#drawRect(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,androidx.compose.ui.graphics.Paint)(left: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, top: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, right: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, bottom: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, paint: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint)` Draws a rectangle with the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#drawRoundRect(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,androidx.compose.ui.graphics.Paint)( left: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, top: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, right: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, bottom: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, radiusX: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, radiusY: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, paint: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint )` Draws a rounded rectangle with the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#drawVertices(androidx.compose.ui.graphics.Vertices,androidx.compose.ui.graphics.BlendMode,androidx.compose.ui.graphics.Paint)(vertices: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Vertices, blendMode: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/BlendMode, paint: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint)` | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#enableZ()()` Enables Z support which defaults to disabled. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#restore()()` Pops the current save stack, if there is anything to pop. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#rotate(kotlin.Float)(degrees: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Add a rotation (in degrees clockwise) to the current transform | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#save()()` Saves a copy of the current transform and clip on the save stack. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#saveLayer(androidx.compose.ui.geometry.Rect,androidx.compose.ui.graphics.Paint)(bounds: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Rect, paint: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/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. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#scale(kotlin.Float,kotlin.Float)(sx: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, sy: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` 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. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#skew(kotlin.Float,kotlin.Float)(sx: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, sy: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Add an axis-aligned skew to the current transform, with the first argument being the horizontal skew in degrees clockwise around the origin, and the second argument being the vertical skew in degrees clockwise around the origin. | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#skewRad(kotlin.Float,kotlin.Float)(sxRad: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, syRad: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Add an axis-aligned skew to the current transform, with the first argument being the horizontal skew in radians clockwise around the origin, and the second argument being the vertical skew in radians clockwise around the origin. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#translate(kotlin.Float,kotlin.Float)(dx: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, dy: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Add a translation to the current transform, shifting the coordinate space horizontally by the first argument and vertically by the second argument. | Cmn |

| ### Extension functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas.https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#(androidx.compose.ui.graphics.Canvas).rotate(kotlin.Float,kotlin.Float,kotlin.Float)(degrees: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, pivotX: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, pivotY: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Add a rotation (in degrees clockwise) to the current transform at the given pivot point. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas.https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#(androidx.compose.ui.graphics.Canvas).rotateRad(kotlin.Float,kotlin.Float,kotlin.Float)(radians: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, pivotX: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, pivotY: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Add a rotation (in radians clockwise) to the current transform at the given pivot point. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas.https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#(androidx.compose.ui.graphics.Canvas).scale(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float)(sx: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, sy: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, pivotX: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, pivotY: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` 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. | Cmn |
| `inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas.https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#(androidx.compose.ui.graphics.Canvas).withSave(kotlin.Function0)(block: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Saves a copy of the current transform and clip on the save stack and executes the provided lambda with the current transform applied. | Cmn |
| `inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas.https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#(androidx.compose.ui.graphics.Canvas).withSaveLayer(androidx.compose.ui.geometry.Rect,androidx.compose.ui.graphics.Paint,kotlin.Function0)(bounds: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Rect, paint: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint, block: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` 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. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas.https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#(androidx.compose.ui.graphics.Canvas).drawOutline(androidx.compose.ui.graphics.Outline,androidx.compose.ui.graphics.Paint)(outline: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Outline, paint: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint)` Draws the `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Outline` on a `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas`. | Cmn |

| ### Extension properties |
|---|---|---|
| `https://developer.android.com/reference/android/graphics/Canvas.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas.https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#(androidx.compose.ui.graphics.Canvas).nativeCanvas()` Return an instance of the native primitive that implements the Canvas interface | android |

## Public functions

### clipPath

Cmn Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

```
fun clipPath(path: Path, clipOp: ClipOp = ClipOp.Intersect): Unit
```

Reduces the clip region to the intersection of the current clip and the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Path`.

### clipRect

Cmn Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

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

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

Use `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/ClipOp#Difference()` to subtract the provided rectangle from the current clip.

### clipRect

Cmn Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

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

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

Use `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/ClipOp#Difference()` to subtract the provided rectangle from the current clip.

| Parameters |
|---|---|
| `left: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | Left bound of the clip region |
| `top: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | Top bound of the clip region |
| `right: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | Right bound of the clip region |
| `bottom: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | Bottom bound of the clip region |
| `clipOp: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/ClipOp = ClipOp.Intersect` | Clipping operation to conduct on the given bounds, defaults to `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/ClipOp#Intersect()` |

### concat

Cmn Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

```
fun concat(matrix: Matrix): Unit
```

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

### disableZ

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun disableZ(): Unit
```

Disables Z support, preventing any layers drawn after this point from being visually reordered or having shadows rendered. This is not impacted by any `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#save()` or `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#restore()` calls as it is not considered part of the matrix or clip.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#enableZ()` |   |

### drawArc

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

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

Draw an arc scaled to fit inside the given rectangle. It starts from startAngle degrees around the oval up to startAngle + sweepAngle degrees around the oval, with zero degrees being the point on the right hand side of the oval that crosses the horizontal line that intersects the center of the rectangle and with positive angles going clockwise around the oval. If useCenter is true, the arc is closed back to the center, forming a circle sector. Otherwise, the arc is not closed, forming a circle segment.

This method is optimized for drawing arcs and should be faster than `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Path#arcTo(androidx.compose.ui.geometry.Rect,kotlin.Float,kotlin.Float,kotlin.Boolean)`.

### drawArc

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

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

Draw an arc scaled to fit inside the given rectangle. It starts from startAngle degrees around the oval up to startAngle + sweepAngle degrees around the oval, with zero degrees being the point on the right hand side of the oval that crosses the horizontal line that intersects the center of the rectangle and with positive angles going clockwise around the oval. If useCenter is true, the arc is closed back to the center, forming a circle sector. Otherwise, the arc is not closed, forming a circle segment.

This method is optimized for drawing arcs and should be faster than `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Path#arcTo(androidx.compose.ui.geometry.Rect,kotlin.Float,kotlin.Float,kotlin.Boolean)`.

| Parameters |
|---|---|
| `left: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | Left bound of the arc |
| `top: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | Top bound of the arc |
| `right: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | Right bound of the arc |
| `bottom: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | Bottom bound of the arc |
| `startAngle: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | Starting angle of the arc relative to 3 o'clock |
| `sweepAngle: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | Sweep angle in degrees clockwise |
| `useCenter: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Flag indicating whether or not to include the center of the oval in the |
| `paint: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint` | Paint used to draw the arc. arc, and close it if it is being stroked. This will draw a wedge. |

### drawArcRad

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

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

Draw an arc scaled to fit inside the given rectangle. It starts from startAngle radians around the oval up to startAngle + sweepAngle radians around the oval, with zero radians being the point on the right hand side of the oval that crosses the horizontal line that intersects the center of the rectangle and with positive angles going clockwise around the oval. If useCenter is true, the arc is closed back to the center, forming a circle sector. Otherwise, the arc is not closed, forming a circle segment.

This method is optimized for drawing arcs and should be faster than `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Path#arcTo(androidx.compose.ui.geometry.Rect,kotlin.Float,kotlin.Float,kotlin.Boolean)`.

### drawCircle

Cmn Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

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

Draws a circle centered at the point given by the first argument and that has the radius given by the second argument, with the `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint` given in the third argument. Whether the circle is filled or stroked (or both) is controlled by `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint#style()`.

### drawImage

Cmn Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

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

Draws the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/ImageBitmap` into the canvas with its top-left corner at the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset`. The image is composited into the canvas using the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint`.

### drawImageRect

Cmn Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

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

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.

This might sample from outside the `src` rect by up to half the width of an applied filter.

| Parameters |
|---|---|
| `image: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/ImageBitmap` | ImageBitmap to draw |
| `srcOffset: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntOffset = IntOffset.Zero` | : Optional offset representing the top left offset of the source image to draw, this defaults to the origin of `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#drawImageRect(androidx.compose.ui.graphics.ImageBitmap,androidx.compose.ui.unit.IntOffset,androidx.compose.ui.unit.IntSize,androidx.compose.ui.unit.IntOffset,androidx.compose.ui.unit.IntSize,androidx.compose.ui.graphics.Paint)` |
| `srcSize: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntSize = IntSize(image.width, image.height)` | : Optional dimensions of the source image to draw relative to `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#drawImageRect(androidx.compose.ui.graphics.ImageBitmap,androidx.compose.ui.unit.IntOffset,androidx.compose.ui.unit.IntSize,androidx.compose.ui.unit.IntOffset,androidx.compose.ui.unit.IntSize,androidx.compose.ui.graphics.Paint)`, this defaults the width and height of `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#drawImageRect(androidx.compose.ui.graphics.ImageBitmap,androidx.compose.ui.unit.IntOffset,androidx.compose.ui.unit.IntSize,androidx.compose.ui.unit.IntOffset,androidx.compose.ui.unit.IntSize,androidx.compose.ui.graphics.Paint)` |
| `dstOffset: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntOffset = IntOffset.Zero` | : Offset representing the top left offset of the destination image to draw |
| `dstSize: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntSize = srcSize` | : Dimensions of the destination to draw |
| `paint: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint` | Paint used to composite the `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/ImageBitmap` pixels into the canvas |

### drawLine

Cmn Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

```
fun drawLine(p1: Offset, p2: Offset, paint: Paint): Unit
```

Draws a line between the given points using the given paint. The line is stroked, the value of the `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint#style()` is ignored for this call.

The `p1` and `p2` arguments are interpreted as offsets from the origin.

### drawOval

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

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

Draws an axis-aligned oval that fills the given axis-aligned rectangle with the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint`. Whether the oval is filled or stroked (or both) is controlled by `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint#style()`.

### drawOval

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

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

Draws an axis-aligned oval that fills the given bounds provided with the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint`. Whether the rectangle is filled or stroked (or both) is controlled by `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint#style()`.

| Parameters |
|---|---|
| `left: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The left bound of the rectangle |
| `top: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The top bound of the rectangle |
| `right: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The right bound of the rectangle |
| `bottom: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The bottom bound of the rectangle |
| `paint: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint` | Paint used to color the rectangle with a fill or stroke |

### drawPath

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun drawPath(path: Path, paint: Paint): Unit
```

Draws the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Path` with the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint`. Whether this shape is filled or stroked (or both) is controlled by `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint#style()`. If the path is filled, then subpaths within it are implicitly closed (see `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Path#close()`).

### drawPoints

Cmn Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

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

Draws a sequence of points according to the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/PointMode`.

The `points` argument is interpreted as offsets from the origin.

See also:

- `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#drawRawPoints(androidx.compose.ui.graphics.PointMode,kotlin.FloatArray,androidx.compose.ui.graphics.Paint)`, which takes `points` as a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float-array/index.html` rather than a List.

### drawRawPoints

Cmn Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

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

Draws a sequence of points according to the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/PointMode`.

The `points` argument is interpreted as a list of pairs of floating point numbers, where each pair represents an x and y offset from the origin.

See also:

- `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#drawPoints(androidx.compose.ui.graphics.PointMode,kotlin.collections.List,androidx.compose.ui.graphics.Paint)`, which takes `points` as a List rather than a List.

### drawRect

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

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

Draws a rectangle with the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint`. Whether the rectangle is filled or stroked (or both) is controlled by `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint#style()`.

### drawRect

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

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

Draws a rectangle with the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint`. Whether the rectangle is filled or stroked (or both) is controlled by `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint#style()`.

| Parameters |
|---|---|
| `left: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The left bound of the rectangle |
| `top: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The top bound of the rectangle |
| `right: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The right bound of the rectangle |
| `bottom: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The bottom bound of the rectangle |
| `paint: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint` | Paint used to color the rectangle with a fill or stroke |

### drawRoundRect

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

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

Draws a rounded rectangle with the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint`. Whether the rectangle is filled or stroked (or both) is controlled by `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint#style()`.

### drawVertices

Cmn Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

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

### enableZ

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun enableZ(): Unit
```

Enables Z support which defaults to disabled. This allows layers drawn with different elevations to be rearranged based on their elevation. It also enables rendering of shadows.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#disableZ()` |   |

### restore

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun restore(): Unit
```

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

Use `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#save()` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#saveLayer(androidx.compose.ui.geometry.Rect,androidx.compose.ui.graphics.Paint)` to push state onto the stack.

If the state was pushed with with `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#saveLayer(androidx.compose.ui.geometry.Rect,androidx.compose.ui.graphics.Paint)`, then this call will also cause the new layer to be composited into the previous layer.

### rotate

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun rotate(degrees: Float): Unit
```

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

| Parameters |
|---|---|
| `degrees: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | to rotate clockwise |

### save

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun save(): Unit
```

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

Call `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#restore()` to pop the save stack.

See also:

- `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#saveLayer(androidx.compose.ui.geometry.Rect,androidx.compose.ui.graphics.Paint)`, which does the same thing but additionally also groups the commands done until the matching `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#restore()`.

### saveLayer

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun saveLayer(bounds: Rect, paint: Paint): Unit
```

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. When the save stack is later popped, the group will be flattened into a layer and have the given `paint`'s `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint#colorFilter()` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint#blendMode()` applied.

This lets you create composite effects, for example making a group of drawing commands semi-transparent. Without using `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#saveLayer(androidx.compose.ui.geometry.Rect,androidx.compose.ui.graphics.Paint)`, each part of the group would be painted individually, so where they overlap would be darker than where they do not. By using `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#saveLayer(androidx.compose.ui.geometry.Rect,androidx.compose.ui.graphics.Paint)` to group them together, they can be drawn with an opaque color at first, and then the entire group can be made transparent using the `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#saveLayer(androidx.compose.ui.geometry.Rect,androidx.compose.ui.graphics.Paint)`'s paint.

Call `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#restore()` to pop the save stack and apply the paint to the group.

## Using saveLayer with clips

When a rectangular clip operation (from `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#clipRect(androidx.compose.ui.geometry.Rect,androidx.compose.ui.graphics.ClipOp)`) is not axis-aligned with the raster buffer, or when the clip operation is not rectalinear (e.g. because it is a rounded rectangle clip created by `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#clipPath(androidx.compose.ui.graphics.Path,androidx.compose.ui.graphics.ClipOp)`, the edge of the clip needs to be anti-aliased.

If two draw calls overlap at the edge of such a clipped region, without using `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#saveLayer(androidx.compose.ui.geometry.Rect,androidx.compose.ui.graphics.Paint)`, the first drawing will be anti-aliased with the background first, and then the second will be anti-aliased with the result of blending the first drawing and the background. On the other hand, if `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#saveLayer(androidx.compose.ui.geometry.Rect,androidx.compose.ui.graphics.Paint)` is used immediately after establishing the clip, the second drawing will cover the first in the layer, and thus the second alone will be anti-aliased with the background when the layer is clipped and composited (when `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#restore()` is called).

(Incidentally, rather than using `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#clipPath(androidx.compose.ui.graphics.Path,androidx.compose.ui.graphics.ClipOp)` with a rounded rectangle defined in a path to draw rounded rectangles like this, prefer the `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#drawRoundRect(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,androidx.compose.ui.graphics.Paint)` method.

## Performance considerations

Generally speaking, `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#saveLayer(androidx.compose.ui.geometry.Rect,androidx.compose.ui.graphics.Paint)` is relatively expensive.

There are a several different hardware architectures for GPUs (graphics processing units, the hardware that handles graphics), but most of them involve batching commands and reordering them for performance. When layers are used, they cause the rendering pipeline to have to switch render target (from one layer to another). Render target switches can flush the GPU's command buffer, which typically means that optimizations that one could get with larger batching are lost. Render target switches also generate a lot of memory churn because the GPU needs to copy out the current frame buffer contents from the part of memory that's optimized for writing, and then needs to copy it back in once the previous render target (layer) is restored.

See also:

- `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#save()`, which saves the current state, but does not create a new layer for subsequent commands.

- `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/BlendMode`, which discusses the use of `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint#blendMode()` with `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#saveLayer(androidx.compose.ui.geometry.Rect,androidx.compose.ui.graphics.Paint)`.

### scale

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun scale(sx: Float, sy: Float = sx): 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.

If `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#scale(kotlin.Float,kotlin.Float)` is unspecified, `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#scale(kotlin.Float,kotlin.Float)` will be used for the scale in both directions.

| Parameters |
|---|---|
| `sx: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The amount to scale in X |
| `sy: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = sx` | The amount to scale in Y |

### skew

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun skew(sx: Float, sy: Float): Unit
```

Add an axis-aligned skew to the current transform, with the first argument being the horizontal skew in degrees clockwise around the origin, and the second argument being the vertical skew in degrees clockwise around the origin.

### skewRad

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
open fun skewRad(sxRad: Float, syRad: Float): Unit
```

Add an axis-aligned skew to the current transform, with the first argument being the horizontal skew in radians clockwise around the origin, and the second argument being the vertical skew in radians clockwise around the origin.

### translate

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun translate(dx: Float, dy: Float): Unit
```

Add a translation to the current transform, shifting the coordinate space horizontally by the first argument and vertically by the second argument.

## Extension functions

### Canvas.rotate

Cmn Artifact: [androidx.compose.ui:ui-graphics](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/graphics/Canvas.kt+function:rotate)

```
fun Canvas.rotate(degrees: Float, pivotX: Float, pivotY: Float): Unit
```

Add a rotation (in degrees clockwise) to the current transform at the given pivot point. The pivot coordinate remains unchanged by the rotation transformation

| Parameters |
|---|---|
| `degrees: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | to rotate clockwise |
| `pivotX: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The x-coord for the pivot point |
| `pivotY: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The y-coord for the pivot point |

### Canvas.rotateRad

Cmn Artifact: [androidx.compose.ui:ui-graphics](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/graphics/Canvas.kt+function:rotateRad)

```
fun Canvas.rotateRad(radians: Float, pivotX: Float = 0.0f, pivotY: Float = 0.0f): Unit
```

Add a rotation (in radians clockwise) to the current transform at the given pivot point. The pivot coordinate remains unchanged by the rotation transformation

| Parameters |
|---|---|
| `radians: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | Rotation transform to apply to the `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas` |
| `pivotX: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = 0.0f` | The x-coord for the pivot point |
| `pivotY: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = 0.0f` | The y-coord for the pivot point |

### Canvas.scale

Cmn Artifact: [androidx.compose.ui:ui-graphics](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/graphics/Canvas.kt+function:scale)

```
fun Canvas.scale(sx: Float, sy: Float = sx, pivotX: Float, pivotY: Float): 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. The pivot coordinate remains unchanged by the scale transformation.

If `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/package-summary#(androidx.compose.ui.graphics.Canvas).scale(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float)` is unspecified, `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/package-summary#(androidx.compose.ui.graphics.Canvas).scale(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float)` will be used for the scale in both directions.

| Parameters |
|---|---|
| `sx: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The amount to scale in X |
| `sy: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = sx` | The amount to scale in Y |
| `pivotX: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The x-coord for the pivot point |
| `pivotY: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The y-coord for the pivot point |

### Canvas.withSave

Cmn Artifact: [androidx.compose.ui:ui-graphics](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/graphics/Canvas.kt+function:withSave)

```
inline fun Canvas.withSave(block: () -> Unit): Unit
```

Saves a copy of the current transform and clip on the save stack and executes the provided lambda with the current transform applied. Once the lambda has been executed, the transformation is popped from the stack, undoing the transformation.

See also:

`https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#saveLayer(androidx.compose.ui.geometry.Rect,androidx.compose.ui.graphics.Paint)`, which does the same thing but additionally also groups the commands

### Canvas.withSaveLayer

Cmn Artifact: [androidx.compose.ui:ui-graphics](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/graphics/Canvas.kt+function:withSaveLayer)

```
inline fun Canvas.withSaveLayer(bounds: Rect, paint: Paint, block: () -> Unit): Unit
```

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. When the lambda is executed and the save stack is popped, the group will be flattened into a layer and have the given `paint`'s `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint#colorFilter()` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint#blendMode()` applied.

This lets you create composite effects, for example making a group of drawing commands semi-transparent. Without using `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#saveLayer(androidx.compose.ui.geometry.Rect,androidx.compose.ui.graphics.Paint)`, each part of the group would be painted individually, so where they overlap would be darker than where they do not. By using `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#saveLayer(androidx.compose.ui.geometry.Rect,androidx.compose.ui.graphics.Paint)` to group them together, they can be drawn with an opaque color at first, and then the entire group can be made transparent using the `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#saveLayer(androidx.compose.ui.geometry.Rect,androidx.compose.ui.graphics.Paint)`'s paint.

## Using saveLayer with clips

When a rectangular clip operation (from `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#clipRect(androidx.compose.ui.geometry.Rect,androidx.compose.ui.graphics.ClipOp)`) is not axis-aligned with the raster buffer, or when the clip operation is not rectalinear (e.g. because it is a rounded rectangle clip created by `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#clipPath(androidx.compose.ui.graphics.Path,androidx.compose.ui.graphics.ClipOp)`), the edge of the clip needs to be anti-aliased.

If two draw calls overlap at the edge of such a clipped region, without using `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#saveLayer(androidx.compose.ui.geometry.Rect,androidx.compose.ui.graphics.Paint)`, the first drawing will be anti-aliased with the background first, and then the second will be anti-aliased with the result of blending the first drawing and the background. On the other hand, if `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#saveLayer(androidx.compose.ui.geometry.Rect,androidx.compose.ui.graphics.Paint)` is used immediately after establishing the clip, the second drawing will cover the first in the layer, and thus the second alone will be anti-aliased with the background when the layer is clipped and composited (when lambda is finished executing).

## Performance considerations

Generally speaking, `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#saveLayer(androidx.compose.ui.geometry.Rect,androidx.compose.ui.graphics.Paint)` is relatively expensive.

There are a several different hardware architectures for GPUs (graphics processing units, the hardware that handles graphics), but most of them involve batching commands and reordering them for performance. When layers are used, they cause the rendering pipeline to have to switch render target (from one layer to another). Render target switches can flush the GPU's command buffer, which typically means that optimizations that one could get with larger batching are lost. Render target switches also generate a lot of memory churn because the GPU needs to copy out the current frame buffer contents from the part of memory that's optimized for writing, and then needs to copy it back in once the previous render target (layer) is restored.

See also:

- `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#save()`, which saves the current state, but does not create a new layer for subsequent commands.

- `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/BlendMode`, which discusses the use of `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint#blendMode()` with `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas#saveLayer(androidx.compose.ui.geometry.Rect,androidx.compose.ui.graphics.Paint)`.

### Canvas.drawOutline

Cmn Artifact: [androidx.compose.ui:ui-graphics](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/graphics/Outline.kt+function:drawOutline)

```
fun Canvas.drawOutline(outline: Outline, paint: Paint): Unit
```

Draws the `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Outline` on a `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas`.

| Parameters |
|---|---|
| `outline: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Outline` | the outline to draw. |
| `paint: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Paint` | the paint used for the drawing. |

## Extension properties

### Canvas.nativeCanvas

android Artifact: [androidx.compose.ui:ui-graphics](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/graphics/AndroidCanvas.android.kt+symbol:nativeCanvas)

```
val Canvas.nativeCanvas: Canvas
```

Return an instance of the native primitive that implements the Canvas interface