{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

ContentDrawScope

public interface ContentDrawScope extends DrawScope


Receiver scope for drawing content into a layout, where the content can be drawn between other canvas operations. If drawContent is not called, the contents of the layout will not be drawn.

Summary

Public methods

abstract void

Causes child drawing operations to run during the onPaint lambda.

Inherited methods

From androidx.compose.ui.unit.Density
abstract float

The logical density of the display.

abstract float

Current user preference for the scaling factor for fonts.

default int

Convert Dp to Int by rounding

default int

Convert Sp to Int by rounding

default @NonNull Dp

Convert Sp to Dp.

default @NonNull Dp
orgKt.toDp(int receiver)

Convert an Int pixel value to Dp.

default @NonNull Dp
orgKt.toDp(float receiver)

Convert a Float pixel value to a Dp

default @NonNull DpSize

Convert a Size to a DpSize.

default float
orgKt.toPx(@NonNull Dp receiver)

Convert Dp to pixels.

default float

Convert Sp to pixels.

default @NonNull Rect

Convert a DpRect to a Rect.

default @NonNull Size

Convert a DpSize to a Size.

default @NonNull TextUnit
orgKt.toSp(@NonNull Dp receiver)

Convert Dp to Sp.

default @NonNull TextUnit
orgKt.toSp(int receiver)

Convert an Int pixel value to Sp.

default @NonNull TextUnit
orgKt.toSp(float receiver)

Convert a Float pixel value to a Sp

From androidx.compose.ui.graphics.drawscope.DrawScope
abstract void
drawArc(
    @NonNull Brush brush,
    float startAngle,
    float sweepAngle,
    boolean useCenter,
    @NonNull Offset topLeft,
    @NonNull Size size,
    float alpha,
    @NonNull DrawStyle style,
    ColorFilter colorFilter,
    @NonNull BlendMode blendMode
)

Draw an arc scaled to fit inside the given rectangle.

abstract void
drawArc(
    @NonNull Color color,
    float startAngle,
    float sweepAngle,
    boolean useCenter,
    @NonNull Offset topLeft,
    @NonNull Size size,
    float alpha,
    @NonNull DrawStyle style,
    ColorFilter colorFilter,
    @NonNull BlendMode blendMode
)

Draw an arc scaled to fit inside the given rectangle.

abstract void
drawCircle(
    @NonNull Brush brush,
    float radius,
    @NonNull Offset center,
    float alpha,
    @NonNull DrawStyle style,
    ColorFilter colorFilter,
    @NonNull BlendMode blendMode
)

Draws a circle at the provided center coordinate and radius.

abstract void
drawCircle(
    @NonNull Color color,
    float radius,
    @NonNull Offset center,
    float alpha,
    @NonNull DrawStyle style,
    ColorFilter colorFilter,
    @NonNull BlendMode blendMode
)

Draws a circle at the provided center coordinate and radius.

abstract void
drawImage(
    @NonNull ImageBitmap image,
    @NonNull Offset topLeft,
    float alpha,
    @NonNull DrawStyle style,
    ColorFilter colorFilter,
    @NonNull BlendMode blendMode
)

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

default void
drawImage(
    @NonNull ImageBitmap image,
    @NonNull IntOffset srcOffset,
    @NonNull IntSize srcSize,
    @NonNull IntOffset dstOffset,
    @NonNull IntSize dstSize,
    float alpha,
    @NonNull DrawStyle style,
    ColorFilter colorFilter,
    @NonNull BlendMode blendMode,
    @NonNull 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.

abstract void
drawLine(
    @NonNull Brush brush,
    @NonNull Offset start,
    @NonNull Offset end,
    float strokeWidth,
    @NonNull StrokeCap cap,
    PathEffect pathEffect,
    float alpha,
    ColorFilter colorFilter,
    @NonNull BlendMode blendMode
)

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

abstract void
drawLine(
    @NonNull Color color,
    @NonNull Offset start,
    @NonNull Offset end,
    float strokeWidth,
    @NonNull StrokeCap cap,
    PathEffect pathEffect,
    float alpha,
    ColorFilter colorFilter,
    @NonNull BlendMode blendMode
)

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

abstract void
drawOval(
    @NonNull Brush brush,
    @NonNull Offset topLeft,
    @NonNull Size size,
    float alpha,
    @NonNull DrawStyle style,
    ColorFilter colorFilter,
    @NonNull BlendMode blendMode
)

Draws an oval with the given offset and size.

abstract void
drawOval(
    @NonNull Color color,
    @NonNull Offset topLeft,
    @NonNull Size size,
    float alpha,
    @NonNull DrawStyle style,
    ColorFilter colorFilter,
    @NonNull BlendMode blendMode
)

Draws an oval with the given offset and size.

abstract void
drawPath(
    @NonNull Path path,
    @NonNull Brush brush,
    float alpha,
    @NonNull DrawStyle style,
    ColorFilter colorFilter,
    @NonNull BlendMode blendMode
)

Draws the given Path with the given Color.

abstract void
drawPath(
    @NonNull Path path,
    @NonNull Color color,
    float alpha,
    @NonNull DrawStyle style,
    ColorFilter colorFilter,
    @NonNull BlendMode blendMode
)

Draws the given Path with the given Color.

abstract void
drawPoints(
    @NonNull List<@NonNull Offset> points,
    @NonNull PointMode pointMode,
    @NonNull Brush brush,
    float strokeWidth,
    @NonNull StrokeCap cap,
    PathEffect pathEffect,
    float alpha,
    ColorFilter colorFilter,
    @NonNull BlendMode blendMode
)

Draws a sequence of points according to the given PointMode.

abstract void
drawPoints(
    @NonNull List<@NonNull Offset> points,
    @NonNull PointMode pointMode,
    @NonNull Color color,
    float strokeWidth,
    @NonNull StrokeCap cap,
    PathEffect pathEffect,
    float alpha,
    ColorFilter colorFilter,
    @NonNull BlendMode blendMode
)

Draws a sequence of points according to the given PointMode.

abstract void
drawRect(
    @NonNull Brush brush,
    @NonNull Offset topLeft,
    @NonNull Size size,
    float alpha,
    @NonNull DrawStyle style,
    ColorFilter colorFilter,
    @NonNull BlendMode blendMode
)

Draws a rectangle with the given offset and size.

abstract void
drawRect(
    @NonNull Color color,
    @NonNull Offset topLeft,
    @NonNull Size size,
    float alpha,
    @NonNull DrawStyle style,
    ColorFilter colorFilter,
    @NonNull BlendMode blendMode
)

Draws a rectangle with the given offset and size.

abstract void
drawRoundRect(
    @NonNull Brush brush,
    @NonNull Offset topLeft,
    @NonNull Size size,
    @NonNull CornerRadius cornerRadius,
    float alpha,
    @NonNull DrawStyle style,
    ColorFilter colorFilter,
    @NonNull BlendMode blendMode
)

Draws a rounded rectangle with the provided size, offset and radii for the x and y axis respectively.

abstract void
drawRoundRect(
    @NonNull Color color,
    @NonNull Offset topLeft,
    @NonNull Size size,
    @NonNull CornerRadius cornerRadius,
    @NonNull DrawStyle style,
    float alpha,
    ColorFilter colorFilter,
    @NonNull BlendMode blendMode
)

Draws a rounded rectangle with the given Paint.

default @NonNull Offset

Center of the current bounds of the drawing environment

abstract @NonNull DrawContext

The current DrawContext that contains the dependencies needed to create the drawing environment

abstract @NonNull LayoutDirection

The layout direction of the layout being drawn in.

default @NonNull Size

Provides the dimensions of the current drawing environment

Public methods

drawContent

abstract void drawContent()

Causes child drawing operations to run during the onPaint lambda.