> Documentation index: https://developer.android.com/reference/llms.txt

# DrawAnnotationScope

Artifact: [androidx.compose.ui:ui-text](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/text/DrawAnnotation.kt+class:androidx.compose.ui.text.DrawAnnotationScope) Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01) Common/AllAndroid/JVM
- Cmn

  ```
  interface DrawAnnotationScope : DrawScope
  ```

*** ** * ** ***

Receiver scope for `DrawAnnotation` callbacks that draws behind or over a character range in laid-out text.

Aligns the `DrawScope` coordinate space with the text layout origin and exposes the measured `textLayoutResult` along with the resolved `[start, end)` character offsets for the annotated range. Call `TextLayoutResult.getBoundingBoxesForRange` or `TextLayoutResult.fillPathForRange` with `start` and `end` to obtain per-line bounding boxes or contour paths.

| See also |
|---|---|
| `DrawAnnotation` |   |
| `TextLayoutResult` |   |

## Summary

| ### Public properties |
|---|---|---|
| `Int` | `end` Exclusive end character offset of the annotated range, clamped to `[start, text.length]`. | Cmn |
| `Int` | `start` Inclusive start character offset of the annotated range, clamped to the text length. | Cmn |
| `TextLayoutResult` | `textLayoutResult` Measured `TextLayoutResult` for the text being drawn. | Cmn |

### Inherited functions

From [androidx.compose.ui.unit.Density](https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density.md.txt) `open Int` `Dp.roundToPx()`

Convert `Dp` to `Int` by rounding
Cmn `open Int` `TextUnit.roundToPx()`

Convert Sp to `Int` by rounding
Cmn `open Dp` `Int.toDp()`

Convert an `Int` pixel value to `Dp`.
Cmn `open Dp` `Float.toDp()`

Convert a `Float` pixel value to a Dp
Cmn `open DpSize` `Size.toDpSize()`

Convert a `Size` to a `DpSize`.
Cmn `open Float` `Dp.toPx()`

Convert `Dp` to pixels.
Cmn `open Float` `TextUnit.toPx()`

Convert Sp to pixels.
Cmn `open Rect` `DpRect.toRect()`

Convert a `DpRect` to a `Rect`.
Cmn `open Size` `DpSize.toSize()`

Convert a `DpSize` to a `Size`.
Cmn `open TextUnit` `Int.toSp()`

Convert an `Int` pixel value to Sp.
Cmn `open TextUnit` `Float.toSp()`

Convert a `Float` pixel value to a Sp
Cmn From [androidx.compose.ui.graphics.drawscope.DrawScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/DrawScope.md.txt) `Unit` `drawArc(
brush: Brush,
startAngle: Float,
sweepAngle: Float,
useCenter: Boolean,
topLeft: Offset,
size: Size,
alpha: @FloatRange(from = 0.0, to = 1.0) Float,
style: DrawStyle,
colorFilter: ColorFilter?,
blendMode: BlendMode
)`

Draw an arc scaled to fit inside the given rectangle.
Cmn `Unit` `drawArc(
color: Color,
startAngle: Float,
sweepAngle: Float,
useCenter: Boolean,
topLeft: Offset,
size: Size,
alpha: @FloatRange(from = 0.0, to = 1.0) Float,
style: DrawStyle,
colorFilter: ColorFilter?,
blendMode: BlendMode
)`

Draw an arc scaled to fit inside the given rectangle.
Cmn `Unit` `drawCircle(
brush: Brush,
radius: Float,
center: Offset,
alpha: @FloatRange(from = 0.0, to = 1.0) Float,
style: DrawStyle,
colorFilter: ColorFilter?,
blendMode: BlendMode
)`

Draws a circle at the provided center coordinate and radius.
Cmn `Unit` `drawCircle(
color: Color,
radius: Float,
center: Offset,
alpha: @FloatRange(from = 0.0, to = 1.0) Float,
style: DrawStyle,
colorFilter: ColorFilter?,
blendMode: BlendMode
)`

Draws a circle at the provided center coordinate and radius.
Cmn `Unit` `drawImage(
image: ImageBitmap,
topLeft: Offset,
alpha: @FloatRange(from = 0.0, to = 1.0) Float,
style: DrawStyle,
colorFilter: ColorFilter?,
blendMode: BlendMode
)`

Draws the given `ImageBitmap` into the canvas with its top-left corner at the given `Offset`.
Cmn `open Unit` `drawImage(
image: ImageBitmap,
srcOffset: IntOffset,
srcSize: IntSize,
dstOffset: IntOffset,
dstSize: IntSize,
alpha: @FloatRange(from = 0.0, to = 1.0) Float,
style: DrawStyle,
colorFilter: ColorFilter?,
blendMode: BlendMode,
filterQuality: FilterQuality
)`

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 `Unit` `drawLine(
brush: Brush,
start: Offset,
end: Offset,
strokeWidth: Float,
cap: StrokeCap,
pathEffect: PathEffect?,
alpha: @FloatRange(from = 0.0, to = 1.0) Float,
colorFilter: ColorFilter?,
blendMode: BlendMode
)`

Draws a line between the given points using the given paint.
Cmn `Unit` `drawLine(
color: Color,
start: Offset,
end: Offset,
strokeWidth: Float,
cap: StrokeCap,
pathEffect: PathEffect?,
alpha: @FloatRange(from = 0.0, to = 1.0) Float,
colorFilter: ColorFilter?,
blendMode: BlendMode
)`

Draws a line between the given points using the given paint.
Cmn `Unit` `drawOval(
brush: Brush,
topLeft: Offset,
size: Size,
alpha: @FloatRange(from = 0.0, to = 1.0) Float,
style: DrawStyle,
colorFilter: ColorFilter?,
blendMode: BlendMode
)`

Draws an oval with the given offset and size.
Cmn `Unit` `drawOval(
color: Color,
topLeft: Offset,
size: Size,
alpha: @FloatRange(from = 0.0, to = 1.0) Float,
style: DrawStyle,
colorFilter: ColorFilter?,
blendMode: BlendMode
)`

Draws an oval with the given offset and size.
Cmn `Unit` `drawPath(
path: Path,
brush: Brush,
alpha: @FloatRange(from = 0.0, to = 1.0) Float,
style: DrawStyle,
colorFilter: ColorFilter?,
blendMode: BlendMode
)`

Draws the given `Path` with the given `Color`.
Cmn `Unit` `drawPath(
path: Path,
color: Color,
alpha: @FloatRange(from = 0.0, to = 1.0) Float,
style: DrawStyle,
colorFilter: ColorFilter?,
blendMode: BlendMode
)`

Draws the given `Path` with the given `Color`.
Cmn `Unit` `drawPoints(
points: List<Offset>,
pointMode: PointMode,
brush: Brush,
strokeWidth: Float,
cap: StrokeCap,
pathEffect: PathEffect?,
alpha: @FloatRange(from = 0.0, to = 1.0) Float,
colorFilter: ColorFilter?,
blendMode: BlendMode
)`

Draws a sequence of points according to the given `PointMode`.
Cmn `Unit` `drawPoints(
points: List<Offset>,
pointMode: PointMode,
color: Color,
strokeWidth: Float,
cap: StrokeCap,
pathEffect: PathEffect?,
alpha: @FloatRange(from = 0.0, to = 1.0) Float,
colorFilter: ColorFilter?,
blendMode: BlendMode
)`

Draws a sequence of points according to the given `PointMode`.
Cmn `Unit` `drawRect(
brush: Brush,
topLeft: Offset,
size: Size,
alpha: @FloatRange(from = 0.0, to = 1.0) Float,
style: DrawStyle,
colorFilter: ColorFilter?,
blendMode: BlendMode
)`

Draws a rectangle with the given offset and size.
Cmn `Unit` `drawRect(
color: Color,
topLeft: Offset,
size: Size,
alpha: @FloatRange(from = 0.0, to = 1.0) Float,
style: DrawStyle,
colorFilter: ColorFilter?,
blendMode: BlendMode
)`

Draws a rectangle with the given offset and size.
Cmn `Unit` `drawRoundRect(
brush: Brush,
topLeft: Offset,
size: Size,
cornerRadius: CornerRadius,
alpha: @FloatRange(from = 0.0, to = 1.0) Float,
style: DrawStyle,
colorFilter: ColorFilter?,
blendMode: BlendMode
)`

Draws a rounded rectangle with the provided size, offset and radii for the x and y axis respectively.
Cmn `Unit` `drawRoundRect(
color: Color,
topLeft: Offset,
size: Size,
cornerRadius: CornerRadius,
style: DrawStyle,
alpha: @FloatRange(from = 0.0, to = 1.0) Float,
colorFilter: ColorFilter?,
blendMode: BlendMode
)`

Draws a rounded rectangle with the given `Paint`.
Cmn `open Unit` `GraphicsLayer.record(size: IntSize, block: DrawScope.() -> Unit)`

Record the corresponding drawing commands for this `GraphicsLayer` instance using the `Density`, `LayoutDirection` and `IntSize` from the provided `DrawScope` as defaults.
Cmn From [androidx.compose.ui.unit.FontScaling](https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/FontScaling.md.txt) `Dp` `TextUnit.toDp()`

Convert Sp to `Dp`.
Cmn `TextUnit` `Dp.toSp()`

Convert `Dp` to Sp.
Cmn

### Inherited properties

From [androidx.compose.ui.unit.Density](https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density.md.txt) `Float` `density`

The logical density of the display.
Cmn From [androidx.compose.ui.graphics.drawscope.DrawScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/DrawScope.md.txt) `open Offset` `center`

Center of the current bounds of the drawing environment
Cmn `DrawContext` `drawContext`

The current `DrawContext` that contains the dependencies needed to create the drawing environment
Cmn `LayoutDirection` `layoutDirection`

The layout direction of the layout being drawn in.
Cmn `open Size` `size`

Provides the dimensions of the current drawing environment
Cmn From [androidx.compose.ui.unit.FontScaling](https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/FontScaling.md.txt) `Float` `fontScale`

Current user preference for the scaling factor for fonts.
Cmn

## Public properties

### end

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

```
val end: Int
```

Exclusive end character offset of the annotated range, clamped to `[start, text.length]`.

### start

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

```
val start: Int
```

Inclusive start character offset of the annotated range, clamped to the text length.

### textLayoutResult

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

```
val textLayoutResult: TextLayoutResult
```

Measured `TextLayoutResult` for the text being drawn.