Canvas

open class Canvas : Managed

Inheritors

Constructors

Link copied to clipboard
constructor(bitmap: Bitmap, surfaceProps: SurfaceProps = SurfaceProps())

Constructs a canvas that draws into bitmap. Sets default pixel geometry in constructed Surface.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
expect open val isClosed: Boolean

Check if underlying resource is closed.

Link copied to clipboard

Returns the total transformation matrix for the canvas.

Link copied to clipboard

Functions

Link copied to clipboard
fun clear(color: Int): Canvas
Link copied to clipboard
fun clipPath(p: Path, antiAlias: Boolean): Canvas
fun clipPath(p: Path, mode: ClipMode): Canvas
fun clipPath(p: Path, mode: ClipMode, antiAlias: Boolean): Canvas
Link copied to clipboard
fun clipRect(r: Rect, antiAlias: Boolean): Canvas
fun clipRect(r: Rect, mode: ClipMode): Canvas
fun clipRect(r: Rect, mode: ClipMode, antiAlias: Boolean): Canvas
Link copied to clipboard
Link copied to clipboard
fun clipRRect(r: RRect, antiAlias: Boolean): Canvas
fun clipRRect(r: RRect, mode: ClipMode): Canvas
fun clipRRect(r: RRect, mode: ClipMode, antiAlias: Boolean): Canvas
Link copied to clipboard
expect open fun close()

Free underlying native resource, peer is useless afterwards.

Link copied to clipboard
fun concat(matrix: Matrix33): Canvas
fun concat(matrix: Matrix44): Canvas
Link copied to clipboard
fun drawArc(left: Float, top: Float, right: Float, bottom: Float, startAngle: Float, sweepAngle: Float, includeCenter: Boolean, paint: Paint): Canvas
Link copied to clipboard
fun drawCircle(x: Float, y: Float, radius: Float, paint: Paint): Canvas
Link copied to clipboard
fun drawDrawable(drawable: Drawable): Canvas

Draws Drawable drawable using clip and matrix.

fun drawDrawable(drawable: Drawable, matrix: Matrix33?): Canvas

Draws Drawable drawable using clip and matrix, concatenated with optional matrix.

fun drawDrawable(drawable: Drawable, x: Float, y: Float): Canvas

Draws Drawable drawable using clip and matrix, offset by (x, y).

Link copied to clipboard
fun drawDRRect(outer: RRect, inner: RRect, paint: Paint): Canvas
Link copied to clipboard
fun drawImage(image: Image, left: Float, top: Float): Canvas
fun drawImage(image: Image, left: Float, top: Float, paint: Paint?): Canvas
Link copied to clipboard
fun drawImageNine(image: Image, center: IRect, dst: Rect, filterMode: FilterMode, paint: Paint?): Canvas
Link copied to clipboard
fun drawImageRect(image: Image, dst: Rect): Canvas
fun drawImageRect(image: Image, dst: Rect, paint: Paint?): Canvas
fun drawImageRect(image: Image, src: Rect, dst: Rect): Canvas
fun drawImageRect(image: Image, src: Rect, dst: Rect, paint: Paint?): Canvas
fun drawImageRect(image: Image, src: Rect, dst: Rect, paint: Paint?, strict: Boolean): Canvas
fun drawImageRect(image: Image, src: Rect, dst: Rect, samplingMode: SamplingMode, paint: Paint?, strict: Boolean): Canvas
Link copied to clipboard
fun drawLine(x0: Float, y0: Float, x1: Float, y1: Float, paint: Paint): Canvas
Link copied to clipboard
fun drawLines(coords: Array<Point>, paint: Paint): Canvas
fun drawLines(coords: FloatArray, paint: Paint): Canvas

Draws pts using clip, Matrix and Paint paint.

Link copied to clipboard
fun drawOval(r: Rect, paint: Paint): Canvas
Link copied to clipboard
fun drawPaint(paint: Paint): Canvas
Link copied to clipboard
fun drawPatch(cubics: Array<Point>, colors: IntArray, texCoords: Array<Point>? = null, blendMode: BlendMode, paint: Paint): Canvas

Draws a Coons patch: the interpolation of four cubics with shared corners, associating a color, and optionally a texture SkPoint, with each corner.

Link copied to clipboard
fun drawPath(path: Path, paint: Paint): Canvas
Link copied to clipboard
fun drawPicture(picture: Picture, matrix: Matrix33? = null, paint: Paint? = null): Canvas
Link copied to clipboard
fun drawPoint(x: Float, y: Float, paint: Paint): Canvas
Link copied to clipboard
fun drawPoints(coords: Array<Point>, paint: Paint): Canvas
fun drawPoints(coords: FloatArray, paint: Paint): Canvas

Draws pts using clip, Matrix and Paint paint.

Link copied to clipboard
fun drawPolygon(coords: Array<Point>, paint: Paint): Canvas
fun drawPolygon(coords: FloatArray, paint: Paint): Canvas

Draws pts using clip, Matrix and Paint paint.

Link copied to clipboard
fun drawRect(r: Rect, paint: Paint): Canvas
Link copied to clipboard
fun drawRectShadow(r: Rect, dx: Float, dy: Float, blur: Float, color: Int): Canvas
fun drawRectShadow(r: Rect, dx: Float, dy: Float, blur: Float, spread: Float, color: Int): Canvas
Link copied to clipboard
fun drawRectShadowNoclip(r: Rect, dx: Float, dy: Float, blur: Float, spread: Float, color: Int): Canvas
Link copied to clipboard
fun drawRegion(r: Region, paint: Paint): Canvas
Link copied to clipboard
fun drawRRect(r: RRect, paint: Paint): Canvas
Link copied to clipboard
fun drawString(s: String, x: Float, y: Float, font: Font?, paint: Paint): Canvas
Link copied to clipboard
fun drawTextBlob(blob: TextBlob, x: Float, y: Float, paint: Paint): Canvas

Draw a text blob with baseline starting at x with paint

Link copied to clipboard
fun drawTextLine(line: TextLine, x: Float, y: Float, paint: Paint): Canvas

Draw a text line with baseline starting at x with paint

Link copied to clipboard
fun drawTriangleFan(positions: Array<Point>, colors: IntArray? = null, texCoords: Array<Point>? = null, indices: ShortArray? = null, blendMode: BlendMode, paint: Paint): Canvas

Draws a triangle fan mesh, using clip and Matrix.

Link copied to clipboard
fun drawTriangles(positions: Array<Point>, colors: IntArray? = null, texCoords: Array<Point>? = null, indices: ShortArray? = null, blendMode: BlendMode, paint: Paint): Canvas

Draws a triangle mesh, using clip and Matrix.

Link copied to clipboard
fun drawTriangleStrip(positions: Array<Point>, colors: IntArray? = null, texCoords: Array<Point>? = null, indices: ShortArray? = null, blendMode: BlendMode, paint: Paint): Canvas

Draws a triangle strip mesh, using clip and Matrix.

Link copied to clipboard
fun drawVertices(vertexMode: VertexMode, positions: FloatArray, colors: IntArray? = null, texCoords: FloatArray? = null, indices: ShortArray? = null, blendMode: BlendMode, paint: Paint): Canvas

Draws a triangle, triangle strip or triangle fan mesh, using clip and Matrix.

Link copied to clipboard
fun readPixels(bitmap: Bitmap, srcX: Int, srcY: Int): Boolean

Copies Rect of pixels from Canvas into bitmap. Matrix and clip are ignored.

Link copied to clipboard

Sets SkMatrix to the identity matrix. Any prior matrix state is overwritten.

Link copied to clipboard
Link copied to clipboard
fun restoreToCount(saveCount: Int): Canvas
Link copied to clipboard
fun rotate(deg: Float): Canvas
fun rotate(deg: Float, x: Float, y: Float): Canvas
Link copied to clipboard
fun save(): Int
Link copied to clipboard
fun saveLayer(bounds: Rect?, paint: Paint?): Int

Saves Matrix and clip, and allocates a Bitmap for subsequent drawing. Calling restore() discards changes to Matrix and clip, and draws the Bitmap.

fun saveLayer(left: Float, top: Float, right: Float, bottom: Float, paint: Paint?): Int
Link copied to clipboard
fun scale(sx: Float, sy: Float): Canvas
Link copied to clipboard
fun setMatrix(matrix: Matrix33): Canvas

Replaces Matrix with matrix. Unlike concat(), any prior matrix state is overwritten.

Link copied to clipboard
fun skew(sx: Float, sy: Float): Canvas
Link copied to clipboard
expect open override fun toString(): String
Link copied to clipboard
fun translate(dx: Float, dy: Float): Canvas
Link copied to clipboard
fun writePixels(bitmap: Bitmap, x: Int, y: Int): Boolean

Copies Rect from pixels to Canvas. Matrix and clip are ignored. Source Rect corners are (0, 0) and (bitmap.width(), bitmap.height()).