CanvasRenderingContext2D

The CanvasRenderingContext2D interface, part of the Canvas API, provides the 2D rendering context for the drawing surface of a element. It is used for drawing shapes, text, images, and other objects.

MDN Reference

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
open fun arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double, counterclockwise: Boolean = definedExternally)
Link copied to clipboard
open fun arcTo(x1: Double, y1: Double, x2: Double, y2: Double, radius: Double)
Link copied to clipboard
abstract fun beginPath()
Link copied to clipboard
open fun bezierCurveTo(cp1x: Double, cp1y: Double, cp2x: Double, cp2y: Double, x: Double, y: Double)
Link copied to clipboard
abstract fun clearRect(x: Double, y: Double, w: Double, h: Double)
Link copied to clipboard
abstract fun clip(fillRule: CanvasFillRule = definedExternally)
abstract fun clip(path: Path2D, fillRule: CanvasFillRule = definedExternally)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
abstract fun createImageData(imagedata: ImageData): ImageData

abstract fun createImageData(sw: Int, sh: Int, settings: ImageDataSettings = definedExternally): ImageData
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
abstract fun drawFocusIfNeeded(element: Element)
abstract fun drawFocusIfNeeded(path: Path2D, element: Element)
Link copied to clipboard
abstract fun drawImage(image: CanvasImageSource, dx: Double, dy: Double)
abstract fun drawImage(image: CanvasImageSource, dx: Double, dy: Double, dw: Double, dh: Double)
abstract fun drawImage(image: CanvasImageSource, sx: Double, sy: Double, sw: Double, sh: Double, dx: Double, dy: Double, dw: Double, dh: Double)
Link copied to clipboard
open fun ellipse(x: Double, y: Double, radiusX: Double, radiusY: Double, rotation: Double, startAngle: Double, endAngle: Double, counterclockwise: Boolean = definedExternally)
Link copied to clipboard
abstract fun fill(fillRule: CanvasFillRule = definedExternally)
abstract fun fill(path: Path2D, fillRule: CanvasFillRule = definedExternally)
Link copied to clipboard
abstract fun fillRect(x: Double, y: Double, w: Double, h: Double)
Link copied to clipboard
abstract fun fillText(text: String, x: Double, y: Double, maxWidth: Double = definedExternally)
Link copied to clipboard
abstract fun getImageData(sx: Int, sy: Int, sw: Int, sh: Int, settings: ImageDataSettings = definedExternally): ImageData
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
abstract fun isPointInPath(x: Double, y: Double, fillRule: CanvasFillRule = definedExternally): Boolean
abstract fun isPointInPath(path: Path2D, x: Double, y: Double, fillRule: CanvasFillRule = definedExternally): Boolean
Link copied to clipboard
abstract fun isPointInStroke(x: Double, y: Double): Boolean
abstract fun isPointInStroke(path: Path2D, x: Double, y: Double): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
abstract fun putImageData(imagedata: ImageData, dx: Int, dy: Int)
abstract fun putImageData(imagedata: ImageData, dx: Int, dy: Int, dirtyX: Int, dirtyY: Int, dirtyWidth: Int, dirtyHeight: Int)
Link copied to clipboard
Link copied to clipboard
open fun rect(x: Double, y: Double, w: Double, h: Double)
Link copied to clipboard
abstract fun reset()
Link copied to clipboard
Link copied to clipboard
abstract fun restore()
Link copied to clipboard
abstract fun rotate(angle: Double)
Link copied to clipboard
open fun roundRect(x: Double, y: Double, w: Double, h: Double, radii: Any = definedExternally)
Link copied to clipboard
abstract fun save()
Link copied to clipboard
abstract fun scale(x: Double, y: Double)
Link copied to clipboard
Link copied to clipboard
abstract fun setTransform(transform: DOMMatrix2DInit = definedExternally)
abstract fun setTransform(transform: DOMMatrixReadOnly)

abstract fun setTransform(a: Double, b: Double, c: Double, d: Double, e: Double, f: Double)
Link copied to clipboard
abstract fun stroke()
abstract fun stroke(path: Path2D)
Link copied to clipboard
abstract fun strokeRect(x: Double, y: Double, w: Double, h: Double)
Link copied to clipboard
abstract fun strokeText(text: String, x: Double, y: Double, maxWidth: Double = definedExternally)
Link copied to clipboard
abstract fun transform(a: Double, b: Double, c: Double, d: Double, e: Double, f: Double)
Link copied to clipboard
abstract fun translate(x: Double, y: Double)