# DrawTransform

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/drawscope/DrawTransform.kt+class:androidx.compose.ui.graphics.drawscope.DrawTransform) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0) Common/All
- Cmn

  ```
  @DrawScopeMarker
  interface DrawTransform
  ```

*** ** * ** ***

Defines transformations that can be applied to a drawing environment

## Summary

| ### Public functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/DrawTransform#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 rounded rectangle. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/DrawTransform#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 rectangle indicated by the given left, top, right and bottom bounds. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/DrawTransform#inset(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float)(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)` Simultaneously translate the coordinate space by `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/DrawTransform#inset(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float)` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/DrawTransform#inset(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float)` as well as modify the dimensions of the current painting area. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/DrawTransform#rotate(kotlin.Float,androidx.compose.ui.geometry.Offset)(degrees: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, pivot: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset)` 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/drawscope/DrawTransform#scale(kotlin.Float,kotlin.Float,androidx.compose.ui.geometry.Offset)(scaleX: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, scaleY: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, pivot: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset)` 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 |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/DrawTransform#transform(androidx.compose.ui.graphics.Matrix)(matrix: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Matrix)` Transform the drawing environment by the given matrix | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/DrawTransform#translate(kotlin.Float,kotlin.Float)(left: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, top: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Translate the coordinate space by the given delta in pixels in both the x and y coordinates respectively | Cmn |

| ### Public properties |
|---|---|---|
| `open https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/DrawTransform#center()` Convenience method to obtain the current position of the current transformation | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/DrawTransform#size()` Get the current size of the CanvasTransform | Cmn |

| ### Extension functions |
|---|---|---|
| `inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/DrawTransform.https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/DrawTransform#(androidx.compose.ui.graphics.drawscope.DrawTransform).inset(kotlin.Float)(inset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Convenience method modifies the `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/DrawScope` bounds to inset both left, top, right and bottom bounds by `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/package-summary#(androidx.compose.ui.graphics.drawscope.DrawTransform).inset(kotlin.Float)`. | Cmn |
| `inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/DrawTransform.https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/DrawTransform#(androidx.compose.ui.graphics.drawscope.DrawTransform).inset(kotlin.Float,kotlin.Float)(horizontal: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, vertical: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Convenience method modifies the `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/DrawTransform` bounds to inset both left and right bounds by `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/package-summary#(androidx.compose.ui.graphics.drawscope.DrawTransform).inset(kotlin.Float,kotlin.Float)` as well as the top and bottom by `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/package-summary#(androidx.compose.ui.graphics.drawscope.DrawTransform).inset(kotlin.Float,kotlin.Float)`. | Cmn |
| `inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/DrawTransform.https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/DrawTransform#(androidx.compose.ui.graphics.drawscope.DrawTransform).rotateRad(kotlin.Float,androidx.compose.ui.geometry.Offset)(radians: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, pivot: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset)` Add a rotation (in radians clockwise) to the current transform at the given pivot point. | Cmn |
| `inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/DrawTransform.https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/DrawTransform#(androidx.compose.ui.graphics.drawscope.DrawTransform).scale(kotlin.Float,androidx.compose.ui.geometry.Offset)(scale: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, pivot: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset)` Add an axis-aligned scale to the current transform, scaling uniformly in both directions by the provided scale factor at the pivot coordinate. | Cmn |

## 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 rounded rectangle. After this method is invoked, this clip is no longer applied

| Parameters |
|---|---|
| `path: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Path` | Shape to clip drawing content within |
| `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()` |

### clipRect

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

```
fun clipRect(
    left: Float = 0.0f,
    top: Float = 0.0f,
    right: Float = size.width,
    bottom: Float = size.height,
    clipOp: ClipOp = ClipOp.Intersect
): 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. After this method is invoked, this clip is no longer applied.

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 = 0.0f` | Left bound of the rectangle to clip |
| `top: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = 0.0f` | Top bound of the rectangle to clip |
| `right: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = size.width` | Right bound ofthe rectangle to clip |
| `bottom: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = size.height` | Bottom bound of the rectangle to clip |
| `clipOp: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/ClipOp = ClipOp.Intersect` | Clipping operation to perform on the given bounds |

### inset

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

```
fun inset(left: Float, top: Float, right: Float, bottom: Float): Unit
```

Simultaneously translate the coordinate space by `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/DrawTransform#inset(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float)` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/DrawTransform#inset(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float)` as well as modify the dimensions of the current painting area. This provides a callback to issue more drawing instructions within the modified coordinate space. This method modifies the width to be equivalent to width - (left + right) as well as height to height - (top + bottom)

| Parameters |
|---|---|
| `left: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | number of pixels to inset the left drawing bound |
| `top: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | number of pixels to inset the top drawing bound |
| `right: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | number of pixels to inset the right drawing bound |
| `bottom: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | number of pixels to inset the bottom drawing bound |

### rotate

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

```
fun rotate(degrees: Float, pivot: Offset = center): 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 |
| `pivot: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset = center` | The coordinates for the pivot point, defaults to the center of the coordinate space |

### scale

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

```
fun scale(scaleX: Float, scaleY: Float, pivot: Offset = center): 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.

| Parameters |
|---|---|
| `scaleX: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The amount to scale in X |
| `scaleY: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The amount to scale in Y |
| `pivot: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset = center` | The coordinate for the pivot point, defaults to the center of the coordinate space |

### transform

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

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

Transform the drawing environment by the given matrix

| Parameters |
|---|---|
| `matrix: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Matrix` | transformation matrix used to transform the drawing environment |

### translate

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

```
fun translate(left: Float = 0.0f, top: Float = 0.0f): Unit
```

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

| Parameters |
|---|---|
| `left: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = 0.0f` | Pixels to translate the coordinate space in the x-axis |
| `top: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = 0.0f` | Pixels to translate the coordinate space in the y-axis |

## Public properties

### center

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

```
open val center: Offset
```

Convenience method to obtain the current position of the current transformation

### size

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

```
val size: Size
```

Get the current size of the CanvasTransform

## Extension functions

### DrawTransform.inset

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/drawscope/DrawTransform.kt+function:inset)

```
inline fun DrawTransform.inset(inset: Float): Unit
```

Convenience method modifies the `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/DrawScope` bounds to inset both left, top, right and bottom bounds by `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/package-summary#(androidx.compose.ui.graphics.drawscope.DrawTransform).inset(kotlin.Float)`. After this method is invoked, the coordinate space is returned to the state before this inset was applied.

| Parameters |
|---|---|
| `inset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | number of pixels to inset left, top, right, and bottom bounds. |

### DrawTransform.inset

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/drawscope/DrawTransform.kt+function:inset)

```
inline fun DrawTransform.inset(horizontal: Float = 0.0f, vertical: Float = 0.0f): Unit
```

Convenience method modifies the `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/DrawTransform` bounds to inset both left and right bounds by `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/package-summary#(androidx.compose.ui.graphics.drawscope.DrawTransform).inset(kotlin.Float,kotlin.Float)` as well as the top and bottom by `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/package-summary#(androidx.compose.ui.graphics.drawscope.DrawTransform).inset(kotlin.Float,kotlin.Float)`. After this method is invoked, the coordinate space is returned to the state before the inset was applied

| Parameters |
|---|---|
| `horizontal: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = 0.0f` | number of pixels to inset both left and right bounds. Zero by default. |
| `vertical: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = 0.0f` | number of pixels to inset both top and bottom bounds. Zero by default. |

### DrawTransform.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/drawscope/DrawTransform.kt+function:rotateRad)

```
inline fun DrawTransform.rotateRad(radians: Float, pivot: Offset = center): 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` | to rotate clockwise |
| `pivot: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset = center` | The coordinate for the pivot point, defaults to the center of the coordinate space |

### DrawTransform.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/drawscope/DrawTransform.kt+function:scale)

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

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

| Parameters |
|---|---|
| `scale: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The amount to scale |
| `pivot: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset = center` | The coordinate for the pivot point, defaults to the center of the coordinate space |