Kanvas

interface Kanvas

Something to draw on. Implementations are not required to be safe across multiple threads.

Inheritors

Properties

Link copied to clipboard
abstract val height: Float

Gets the height of the canvas.

Link copied to clipboard
abstract val width: Float

Gets the width of the canvas.

Functions

Link copied to clipboard
abstract fun drawArc(left: Float, top: Float, right: Float, bottom: Float, startAngle: Float, sweepAngle: Float, paint: Paint)

Draw an arc that fits in the oval defined by the rectangle left, top, right, and bottom, from startAngle (in degrees, with 0 at the right) to startAngle + sweepAngle.

Link copied to clipboard
abstract fun drawCircle(centerX: Float, centerY: Float, radius: Float, paint: Paint)

Draw a circle at centerX, centerY with size defined by its radius.

Link copied to clipboard
abstract fun drawColor(color: Color)

Draw a color over the entire canvas. Implementations may or may not restrict this to the current clip.

Link copied to clipboard
abstract fun drawLine(startX: Float, startY: Float, endX: Float, endY: Float, paint: Paint)

Draw a line from startX, startY to endX, endY.

Link copied to clipboard
abstract fun drawOval(left: Float, top: Float, right: Float, bottom: Float, paint: Paint)

Draw an oval defined by the rectangle left, top, right, and bottom.

Link copied to clipboard
abstract fun drawPath(path: Path, paint: Paint)

Draws a Path.

Link copied to clipboard
abstract fun drawRect(left: Float, top: Float, right: Float, bottom: Float, paint: Paint)

Draws the rectangle left, top, right, bottom.

Link copied to clipboard
abstract fun drawText(text: CharSequence, x: Float, y: Float, paint: Paint)

Draws a string of text at x, y. Exact horizontal behavior is controlled by the paint's alignment.

Link copied to clipboard
abstract fun pop()

Removes the last pushClip or pushTransform operation.

Link copied to clipboard
abstract fun pushClip(clip: Clip)

Pushes a clip to the canvas. Remove it with pop.

Link copied to clipboard
abstract fun pushTransform(transform: Transform)

Pushes a transform to the canvas. Remove it with pop.

Link copied to clipboard
inline fun Kanvas.withClip(clip: Clip, actions: Kanvas.() -> Unit)

Invokes actions inside of a Kanvas.pushClip/Kanvas.pop pair.

Link copied to clipboard
inline fun Kanvas.withTransform(transform: Transform, actions: Kanvas.() -> Unit)

Invokes actions inside of a Kanvas.pushTransform/Kanvas.pop pair.