CanvasDrawScope


Implementation of DrawScope that issues drawing commands into the specified canvas and bounds via CanvasDrawScope.draw

Summary

Public constructors

Cmn

Public functions

inline Unit
draw(
    density: Density,
    layoutDirection: LayoutDirection,
    canvas: Canvas,
    size: Size,
    block: DrawScope.() -> Unit
)

Draws into the provided Canvas with the commands specified in the lambda with this DrawScope as a receiver

Cmn
open 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
)
Cmn
open 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
)
Cmn
open Unit
drawCircle(
    brush: Brush,
    radius: Float,
    center: Offset,
    alpha: @FloatRange(from = 0.0, to = 1.0) Float,
    style: DrawStyle,
    colorFilter: ColorFilter?,
    blendMode: BlendMode
)
Cmn
open Unit
drawCircle(
    color: Color,
    radius: Float,
    center: Offset,
    alpha: @FloatRange(from = 0.0, to = 1.0) Float,
    style: DrawStyle,
    colorFilter: ColorFilter?,
    blendMode: BlendMode
)
Cmn
open Unit
drawImage(
    image: ImageBitmap,
    topLeft: Offset,
    alpha: @FloatRange(from = 0.0, to = 1.0) Float,
    style: DrawStyle,
    colorFilter: ColorFilter?,
    blendMode: BlendMode
)
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
)
Cmn
open 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
)
Cmn
open 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
)
Cmn
open Unit
drawOval(
    brush: Brush,
    topLeft: Offset,
    size: Size,
    alpha: @FloatRange(from = 0.0, to = 1.0) Float,
    style: DrawStyle,
    colorFilter: ColorFilter?,
    blendMode: BlendMode
)
Cmn
open Unit
drawOval(
    color: Color,
    topLeft: Offset,
    size: Size,
    alpha: @FloatRange(from = 0.0, to = 1.0) Float,
    style: DrawStyle,
    colorFilter: ColorFilter?,
    blendMode: BlendMode
)
Cmn
open Unit
drawPath(
    path: Path,
    brush: Brush,
    alpha: @FloatRange(from = 0.0, to = 1.0) Float,
    style: DrawStyle,
    colorFilter: ColorFilter?,
    blendMode: BlendMode
)
Cmn
open Unit
drawPath(
    path: Path,
    color: Color,
    alpha: @FloatRange(from = 0.0, to = 1.0) Float,
    style: DrawStyle,
    colorFilter: ColorFilter?,
    blendMode: BlendMode
)
Cmn
open 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
)
Cmn
open 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
)
Cmn
open Unit
drawRect(
    brush: Brush,
    topLeft: Offset,
    size: Size,
    alpha: @FloatRange(from = 0.0, to = 1.0) Float,
    style: DrawStyle,
    colorFilter: ColorFilter?,
    blendMode: BlendMode
)
Cmn
open Unit
drawRect(
    color: Color,
    topLeft: Offset,
    size: Size,
    alpha: @FloatRange(from = 0.0, to = 1.0) Float,
    style: DrawStyle,
    colorFilter: ColorFilter?,
    blendMode: BlendMode
)
Cmn
open 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
)
Cmn
open 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
)
Cmn

Public properties

open Float

The logical density of the display.

Cmn
open DrawContext

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

Cmn
open Float

Current user preference for the scaling factor for fonts.

Cmn
open LayoutDirection

The layout direction of the layout being drawn in.

Cmn

Inherited functions

From androidx.compose.ui.unit.Density
open Int

Convert Dp to Int by rounding

Cmn
open Int

Convert Sp to Int by rounding

Cmn
open Dp

Convert an Int pixel value to Dp.

Cmn
open Dp

Convert a Float pixel value to a Dp

Cmn
open DpSize

Convert a Size to a DpSize.

Cmn
open Float

Convert Dp to pixels.

Cmn
open Float

Convert Sp to pixels.

Cmn
open Rect

Convert a DpRect to a Rect.

Cmn
open Size

Convert a DpSize to a Size.

Cmn
open TextUnit

Convert an Int pixel value to Sp.

Cmn
open TextUnit

Convert a Float pixel value to a Sp

Cmn
From androidx.compose.ui.unit.FontScaling
open Dp

Convert Sp to Dp.

Cmn
open TextUnit

Convert Dp to Sp.

Cmn

Inherited properties

From androidx.compose.ui.graphics.drawscope.DrawScope
open Offset

Center of the current bounds of the drawing environment

Cmn
open Size

Provides the dimensions of the current drawing environment

Cmn

Public constructors

CanvasDrawScope

CanvasDrawScope()

Public functions

draw

inline fun draw(
    density: Density,
    layoutDirection: LayoutDirection,
    canvas: Canvas,
    size: Size,
    block: DrawScope.() -> Unit
): Unit

Draws into the provided Canvas with the commands specified in the lambda with this DrawScope as a receiver

Parameters
density: Density

Density used to assist in conversions of density independent pixels to raw pixels to draw

layoutDirection: LayoutDirection

LayoutDirection of the layout being drawn in.

canvas: Canvas

target canvas to render into

size: Size

bounds relative to the current canvas translation in which the DrawScope should draw within

block: DrawScope.() -> Unit

lambda that is called to issue drawing commands on this DrawScope

drawArc

open fun 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
): Unit
See also
drawArc

drawArc

open fun 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
): Unit
See also
drawArc

drawCircle

open fun drawCircle(
    brush: Brush,
    radius: Float,
    center: Offset,
    alpha: @FloatRange(from = 0.0, to = 1.0) Float,
    style: DrawStyle,
    colorFilter: ColorFilter?,
    blendMode: BlendMode
): Unit
See also
drawCircle

drawCircle

open fun drawCircle(
    color: Color,
    radius: Float,
    center: Offset,
    alpha: @FloatRange(from = 0.0, to = 1.0) Float,
    style: DrawStyle,
    colorFilter: ColorFilter?,
    blendMode: BlendMode
): Unit
See also
drawCircle

drawImage

open fun drawImage(
    image: ImageBitmap,
    topLeft: Offset,
    alpha: @FloatRange(from = 0.0, to = 1.0) Float,
    style: DrawStyle,
    colorFilter: ColorFilter?,
    blendMode: BlendMode
): Unit
See also
drawImage

drawImage

open fun 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
): Unit
See also
drawImage

drawLine

open fun 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
): Unit
See also
drawLine

drawLine

open fun 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
): Unit
See also
drawLine

drawOval

open fun drawOval(
    brush: Brush,
    topLeft: Offset,
    size: Size,
    alpha: @FloatRange(from = 0.0, to = 1.0) Float,
    style: DrawStyle,
    colorFilter: ColorFilter?,
    blendMode: BlendMode
): Unit
See also
drawOval

drawOval

open fun drawOval(
    color: Color,
    topLeft: Offset,
    size: Size,
    alpha: @FloatRange(from = 0.0, to = 1.0) Float,
    style: DrawStyle,
    colorFilter: ColorFilter?,
    blendMode: BlendMode
): Unit
See also
drawOval

drawPath

open fun drawPath(
    path: Path,
    brush: Brush,
    alpha: @FloatRange(from = 0.0, to = 1.0) Float,
    style: DrawStyle,
    colorFilter: ColorFilter?,
    blendMode: BlendMode
): Unit
See also
drawPath

drawPath

open fun drawPath(
    path: Path,
    color: Color,
    alpha: @FloatRange(from = 0.0, to = 1.0) Float,
    style: DrawStyle,
    colorFilter: ColorFilter?,
    blendMode: BlendMode
): Unit
See also
drawPath

drawPoints

open fun 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
): Unit
See also
drawPoints

drawPoints

open fun 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
): Unit
See also
drawPoints

drawRect

open fun drawRect(
    brush: Brush,
    topLeft: Offset,
    size: Size,
    alpha: @FloatRange(from = 0.0, to = 1.0) Float,
    style: DrawStyle,
    colorFilter: ColorFilter?,
    blendMode: BlendMode
): Unit
See also
drawRect

drawRect

open fun drawRect(
    color: Color,
    topLeft: Offset,
    size: Size,
    alpha: @FloatRange(from = 0.0, to = 1.0) Float,
    style: DrawStyle,
    colorFilter: ColorFilter?,
    blendMode: BlendMode
): Unit
See also
drawRect

drawRoundRect

open fun drawRoundRect(
    brush: Brush,
    topLeft: Offset,
    size: Size,
    cornerRadius: CornerRadius,
    alpha: @FloatRange(from = 0.0, to = 1.0) Float,
    style: DrawStyle,
    colorFilter: ColorFilter?,
    blendMode: BlendMode
): Unit
See also
drawRoundRect

drawRoundRect

open fun drawRoundRect(
    color: Color,
    topLeft: Offset,
    size: Size,
    cornerRadius: CornerRadius,
    style: DrawStyle,
    alpha: @FloatRange(from = 0.0, to = 1.0) Float,
    colorFilter: ColorFilter?,
    blendMode: BlendMode
): Unit
See also
drawRoundRect

Public properties

density

open val densityFloat

The logical density of the display. This is a scaling factor for the Dp unit.

drawContext

open val drawContextDrawContext

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

fontScale

open val fontScaleFloat

Current user preference for the scaling factor for fonts.

layoutDirection

open val layoutDirectionLayoutDirection

The layout direction of the layout being drawn in.