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

The CanvasRenderingContext2D.canvas property, part of the Canvas API, is a read-only reference to the HTMLCanvasElement object that is associated with a given context. It might be null if there is no associated element.

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
Link copied to clipboard
open fun bezierCurveTo(cp1x: Double, cp1y: Double, cp2x: Double, cp2y: Double, x: Double, y: Double)
Link copied to clipboard
Link copied to clipboard
open fun clip(fillRule: CanvasFillRule = definedExternally)
open fun clip(path: Path2D, fillRule: CanvasFillRule = definedExternally)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun createImageData(imageData: ImageData): ImageData

open 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
open fun drawFocusIfNeeded(element: Element)
open fun drawFocusIfNeeded(path: Path2D, element: Element)
Link copied to clipboard
open fun drawImage(image: CanvasImageSource, dx: Double, dy: Double)
open fun drawImage(image: CanvasImageSource, dx: Double, dy: Double, dw: Double, dh: Double)
open 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
open fun fill(fillRule: CanvasFillRule = definedExternally)
open fun fill(path: Path2D, fillRule: CanvasFillRule = definedExternally)
Link copied to clipboard
Link copied to clipboard
open fun fillText(text: String, x: Double, y: Double, maxWidth: Double = definedExternally)
Link copied to clipboard
open 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
open fun isPointInPath(x: Double, y: Double, fillRule: CanvasFillRule = definedExternally): Boolean
open fun isPointInPath(path: Path2D, x: Double, y: Double, fillRule: CanvasFillRule = definedExternally): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun putImageData(imageData: ImageData, dx: Int, dy: Int)
open 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
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun rotate(angle: Double)
Link copied to clipboard
open fun roundRect(x: Double, y: Double, w: Double, h: Double, radii: JsAny = definedExternally)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun setTransform(transform: DOMMatrixReadOnly = definedExternally)

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