Skip to content

Documentation / @ripl/canvas / CanvasContext

Class: CanvasContext

Defined in: canvas/src/context.ts:115

Canvas 2D rendering context implementation, mapping the unified API to CanvasRenderingContext2D.

Extends

Constructors

Constructor

new CanvasContext(target, options?): CanvasContext

Defined in: canvas/src/context.ts:318

Parameters

ParameterType
targetstring | HTMLElement
options?ContextOptions<Record<string, unknown>>

Returns

CanvasContext

Overrides

DOMContext.constructor

Properties

PropertyModifierTypeDefault valueDescriptionInherited fromDefined in
bufferpublicbooleanfalseWhether drawing is buffered rather than committed to the surface immediately.DOMContext.buffercore/src/context/context.ts:121
contextprotectedCanvasRenderingContext2Dundefined--canvas/src/context.ts:117
currentStateprotectedBaseStateundefined-DOMContext.currentStatecore/src/context/context.ts:144
elementreadonlyHTMLCanvasElementundefinedThe underlying DOM element the context renders into.DOMContext.elementcore/src/context/context.ts:116
heightpublicnumberundefinedCurrent height, in pixels, of the rendering surface.DOMContext.heightcore/src/context/context.ts:131
hitTestHonoursTransformpublicbooleanfalseWhether this context's hit testing natively accounts for element and ancestor group transforms (as SVG does, via the DOM). When false (e.g. canvas), callers map the hit point into the element's local space before testing. See getWorldTransform.DOMContext.hitTestHonoursTransformcore/src/context/context.ts:127
metareadonlyTMetaundefinedArbitrary metadata attached to the context.DOMContext.metacore/src/context/context.ts:118
parent?publicEventBus<ContextEventMap>undefinedThe parent event bus that emitted events bubble up to, if any.DOMContext.parentcore/src/core/event-bus.ts:89
renderDepthprotectednumber0-DOMContext.renderDepthcore/src/context/context.ts:145
renderedElementspublicRenderElement[]undefinedElements rendered during the current pass, used for hit testing.DOMContext.renderedElementscore/src/context/context.ts:141
renderElement?publicRenderElementundefinedThe element currently being rendered, if any.DOMContext.renderElementcore/src/context/context.ts:139
rootreadonlyHTMLElementundefinedThe host DOM element that the context's rendering surface is mounted into.DOMContext.rootdom/src/context.ts:45
saveDepthprotectednumber0-DOMContext.saveDepthcore/src/context/context.ts:146
scaleDPRpublicScale<number, number>undefinedScale mapping logical pixels to device pixels using the device pixel ratio.DOMContext.scaleDPRcore/src/context/context.ts:137
scaleXpublicScale<number, number>undefinedScale mapping domain x coordinates to surface x coordinates.DOMContext.scaleXcore/src/context/context.ts:133
scaleYpublicScale<number, number>undefinedScale mapping domain y coordinates to surface y coordinates.DOMContext.scaleYcore/src/context/context.ts:135
statesprotectedBaseState[]undefined-DOMContext.statescore/src/context/context.ts:143
typereadonlystringundefinedThe context type identifier (e.g. canvas, svg).DOMContext.typecore/src/context/context.ts:114
widthpublicnumberundefinedCurrent width, in pixels, of the rendering surface.DOMContext.widthcore/src/context/context.ts:129
defaultKeyreadonlytypeof defaultKeyundefinedThe key under which resources are retained when no explicit key is provided.DOMContext.defaultKeycore/src/core/disposer.ts:11

Accessors

currentRenderElement

Get Signature

get currentRenderElement(): RenderElement | undefined

Defined in: core/src/context/context.ts:150

The element currently being rendered; setting a non-abstract element also records it in Context.renderedElements.

Returns

RenderElement | undefined

Set Signature

set currentRenderElement(element): void

Defined in: core/src/context/context.ts:154

Parameters
ParameterType
elementRenderElement | undefined
Returns

void

Inherited from

DOMContext.currentRenderElement


direction

Get Signature

get direction(): Direction

Defined in: canvas/src/context.ts:149

The current text direction.

Returns

Direction

Set Signature

set direction(value): void

Defined in: canvas/src/context.ts:153

Directionality used when rendering text.

Parameters
ParameterType
valueDirection
Returns

void

Directionality used when rendering text.

Overrides

DOMContext.direction


fill

Get Signature

get fill(): string

Defined in: canvas/src/context.ts:122

The current fill style — a colour or CSS gradient string.

Returns

string

Set Signature

set fill(value): void

Defined in: canvas/src/context.ts:126

Fill style (CSS colour, gradient, or pattern) used to paint filled regions.

Parameters
ParameterType
valuestring
Returns

void

Fill style (CSS colour, gradient, or pattern) used to paint filled regions.

Overrides

DOMContext.fill


filter

Get Signature

get filter(): string

Defined in: canvas/src/context.ts:140

The current filter applied to drawing operations.

Returns

string

Set Signature

set filter(value): void

Defined in: canvas/src/context.ts:144

CSS filter string applied to subsequent drawing operations (e.g. blur(4px)).

Parameters
ParameterType
valuestring
Returns

void

CSS filter string applied to subsequent drawing operations (e.g. blur(4px)).

Overrides

DOMContext.filter


font

Get Signature

get font(): string

Defined in: canvas/src/context.ts:158

The current font used for text rendering.

Returns

string

Set Signature

set font(value): void

Defined in: canvas/src/context.ts:162

CSS font shorthand used when rendering text.

Parameters
ParameterType
valuestring
Returns

void

CSS font shorthand used when rendering text.

Overrides

DOMContext.font


fontKerning

Get Signature

get fontKerning(): FontKerning

Defined in: canvas/src/context.ts:167

The current font kerning mode.

Returns

FontKerning

Set Signature

set fontKerning(value): void

Defined in: canvas/src/context.ts:171

Whether font kerning is applied when rendering text.

Parameters
ParameterType
valueFontKerning
Returns

void

Whether font kerning is applied when rendering text.

Overrides

DOMContext.fontKerning


globalCompositeOperation

Get Signature

get globalCompositeOperation(): unknown

Defined in: canvas/src/context.ts:185

The current compositing operation used when drawing.

Returns

unknown

Set Signature

set globalCompositeOperation(value): void

Defined in: canvas/src/context.ts:189

Compositing operation controlling how new drawing is blended with existing content.

Parameters
ParameterType
valueunknown
Returns

void

Compositing operation controlling how new drawing is blended with existing content.

Overrides

DOMContext.globalCompositeOperation


lineCap

Get Signature

get lineCap(): LineCap

Defined in: canvas/src/context.ts:194

The current line cap style for stroke endpoints.

Returns

LineCap

Set Signature

set lineCap(value): void

Defined in: canvas/src/context.ts:198

Cap style drawn at the endpoints of stroked lines.

Parameters
ParameterType
valueLineCap
Returns

void

Cap style drawn at the endpoints of stroked lines.

Overrides

DOMContext.lineCap


lineDash

Get Signature

get lineDash(): number[]

Defined in: canvas/src/context.ts:203

The current line dash pattern.

Returns

number[]

Set Signature

set lineDash(value): void

Defined in: canvas/src/context.ts:207

Dash pattern as alternating stroke and gap lengths; empty for a solid line.

Parameters
ParameterType
valuenumber[]
Returns

void

Dash pattern as alternating stroke and gap lengths; empty for a solid line.

Overrides

DOMContext.lineDash


lineDashOffset

Get Signature

get lineDashOffset(): number

Defined in: canvas/src/context.ts:212

The current offset into the line dash pattern.

Returns

number

Set Signature

set lineDashOffset(value): void

Defined in: canvas/src/context.ts:216

Distance into the line dash pattern at which dashing begins.

Parameters
ParameterType
valuenumber
Returns

void

Distance into the line dash pattern at which dashing begins.

Overrides

DOMContext.lineDashOffset


lineJoin

Get Signature

get lineJoin(): LineJoin

Defined in: canvas/src/context.ts:221

The current line join style for stroke corners.

Returns

LineJoin

Set Signature

set lineJoin(value): void

Defined in: canvas/src/context.ts:225

Join style drawn where two stroked segments meet.

Parameters
ParameterType
valueLineJoin
Returns

void

Join style drawn where two stroked segments meet.

Overrides

DOMContext.lineJoin


lineWidth

Get Signature

get lineWidth(): number

Defined in: canvas/src/context.ts:230

The current stroke width, in pixels.

Returns

number

Set Signature

set lineWidth(value): void

Defined in: canvas/src/context.ts:234

Width, in pixels, of stroked lines.

Parameters
ParameterType
valuenumber
Returns

void

Width, in pixels, of stroked lines.

Overrides

DOMContext.lineWidth


miterLimit

Get Signature

get miterLimit(): number

Defined in: canvas/src/context.ts:239

The current miter limit for stroke joins.

Returns

number

Set Signature

set miterLimit(value): void

Defined in: canvas/src/context.ts:243

Miter length limit ratio applied to miter line joins.

Parameters
ParameterType
valuenumber
Returns

void

Miter length limit ratio applied to miter line joins.

Overrides

DOMContext.miterLimit


opacity

Get Signature

get opacity(): number

Defined in: canvas/src/context.ts:176

The current global opacity applied to drawing operations.

Returns

number

Set Signature

set opacity(value): void

Defined in: canvas/src/context.ts:180

Global alpha applied to everything drawn, from 0 to 1.

Parameters
ParameterType
valuenumber
Returns

void

Global alpha applied to everything drawn, from 0 to 1.

Overrides

DOMContext.opacity


rotation

Get Signature

get rotation(): Rotation

Defined in: core/src/context/context.ts:388

Rotation applied to the element's transform, as radians or a deg/rad string.

Returns

Rotation

Set Signature

set rotation(value): void

Defined in: core/src/context/context.ts:392

Rotation applied to the element's transform, as radians or a deg/rad string.

Parameters
ParameterType
valueRotation
Returns

void

Rotation applied to the element's transform, as radians or a deg/rad string.

Inherited from

DOMContext.rotation


shadowBlur

Get Signature

get shadowBlur(): number

Defined in: canvas/src/context.ts:248

The current shadow blur radius.

Returns

number

Set Signature

set shadowBlur(value): void

Defined in: canvas/src/context.ts:252

Gaussian blur radius applied to drawn shadows.

Parameters
ParameterType
valuenumber
Returns

void

Gaussian blur radius applied to drawn shadows.

Overrides

DOMContext.shadowBlur


shadowColor

Get Signature

get shadowColor(): string

Defined in: canvas/src/context.ts:257

The current shadow colour.

Returns

string

Set Signature

set shadowColor(value): void

Defined in: canvas/src/context.ts:261

Colour of drawn shadows.

Parameters
ParameterType
valuestring
Returns

void

Colour of drawn shadows.

Overrides

DOMContext.shadowColor


shadowOffsetX

Get Signature

get shadowOffsetX(): number

Defined in: canvas/src/context.ts:266

The current horizontal shadow offset.

Returns

number

Set Signature

set shadowOffsetX(value): void

Defined in: canvas/src/context.ts:270

Horizontal offset, in pixels, of drawn shadows.

Parameters
ParameterType
valuenumber
Returns

void

Horizontal offset, in pixels, of drawn shadows.

Overrides

DOMContext.shadowOffsetX


shadowOffsetY

Get Signature

get shadowOffsetY(): number

Defined in: canvas/src/context.ts:275

The current vertical shadow offset.

Returns

number

Set Signature

set shadowOffsetY(value): void

Defined in: canvas/src/context.ts:279

Vertical offset, in pixels, of drawn shadows.

Parameters
ParameterType
valuenumber
Returns

void

Vertical offset, in pixels, of drawn shadows.

Overrides

DOMContext.shadowOffsetY


stroke

Get Signature

get stroke(): string

Defined in: canvas/src/context.ts:284

The current stroke style — a colour or CSS gradient string.

Returns

string

Set Signature

set stroke(value): void

Defined in: canvas/src/context.ts:288

Stroke style (CSS colour, gradient, or pattern) used to paint outlines.

Parameters
ParameterType
valuestring
Returns

void

Stroke style (CSS colour, gradient, or pattern) used to paint outlines.

Overrides

DOMContext.stroke


textAlign

Get Signature

get textAlign(): TextAlignment

Defined in: canvas/src/context.ts:301

The current horizontal text alignment.

Returns

TextAlignment

Set Signature

set textAlign(value): void

Defined in: canvas/src/context.ts:305

Horizontal alignment of text relative to the drawing position.

Parameters
ParameterType
valueTextAlignment
Returns

void

Horizontal alignment of text relative to the drawing position.

Overrides

DOMContext.textAlign


textBaseline

Get Signature

get textBaseline(): TextBaseline

Defined in: canvas/src/context.ts:310

The current vertical text baseline.

Returns

TextBaseline

Set Signature

set textBaseline(value): void

Defined in: canvas/src/context.ts:314

Vertical baseline used when positioning text.

Parameters
ParameterType
valueTextBaseline
Returns

void

Vertical baseline used when positioning text.

Overrides

DOMContext.textBaseline


transformOriginX

Get Signature

get transformOriginX(): TransformOrigin

Defined in: core/src/context/context.ts:397

Horizontal origin about which rotation and scaling are applied.

Returns

TransformOrigin

Set Signature

set transformOriginX(value): void

Defined in: core/src/context/context.ts:401

Horizontal origin about which rotation and scaling are applied.

Parameters
ParameterType
valueTransformOrigin
Returns

void

Horizontal origin about which rotation and scaling are applied.

Inherited from

DOMContext.transformOriginX


transformOriginY

Get Signature

get transformOriginY(): TransformOrigin

Defined in: core/src/context/context.ts:406

Vertical origin about which rotation and scaling are applied.

Returns

TransformOrigin

Set Signature

set transformOriginY(value): void

Defined in: core/src/context/context.ts:410

Vertical origin about which rotation and scaling are applied.

Parameters
ParameterType
valueTransformOrigin
Returns

void

Vertical origin about which rotation and scaling are applied.

Inherited from

DOMContext.transformOriginY


transformScaleX

Get Signature

get transformScaleX(): number

Defined in: core/src/context/context.ts:370

Horizontal scale factor applied to the element's transform.

Returns

number

Set Signature

set transformScaleX(value): void

Defined in: core/src/context/context.ts:374

Horizontal scale factor applied to the element's transform.

Parameters
ParameterType
valuenumber
Returns

void

Horizontal scale factor applied to the element's transform.

Inherited from

DOMContext.transformScaleX


transformScaleY

Get Signature

get transformScaleY(): number

Defined in: core/src/context/context.ts:379

Vertical scale factor applied to the element's transform.

Returns

number

Set Signature

set transformScaleY(value): void

Defined in: core/src/context/context.ts:383

Vertical scale factor applied to the element's transform.

Parameters
ParameterType
valuenumber
Returns

void

Vertical scale factor applied to the element's transform.

Inherited from

DOMContext.transformScaleY


translateX

Get Signature

get translateX(): number

Defined in: core/src/context/context.ts:352

Horizontal translation, in pixels, applied to the element's transform.

Returns

number

Set Signature

set translateX(value): void

Defined in: core/src/context/context.ts:356

Horizontal translation, in pixels, applied to the element's transform.

Parameters
ParameterType
valuenumber
Returns

void

Horizontal translation, in pixels, applied to the element's transform.

Inherited from

DOMContext.translateX


translateY

Get Signature

get translateY(): number

Defined in: core/src/context/context.ts:361

Vertical translation, in pixels, applied to the element's transform.

Returns

number

Set Signature

set translateY(value): void

Defined in: core/src/context/context.ts:365

Vertical translation, in pixels, applied to the element's transform.

Parameters
ParameterType
valuenumber
Returns

void

Vertical translation, in pixels, applied to the element's transform.

Inherited from

DOMContext.translateY


zIndex

Get Signature

get zIndex(): number

Defined in: core/src/context/context.ts:343

Stacking order used to sort elements during rendering; higher values draw on top.

Returns

number

Set Signature

set zIndex(value): void

Defined in: core/src/context/context.ts:347

Stacking order used to sort elements during rendering; higher values draw on top.

Parameters
ParameterType
valuenumber
Returns

void

Stacking order used to sort elements during rendering; higher values draw on top.

Inherited from

DOMContext.zIndex

Methods

applyClip()

applyClip(path, fillRule?): void

Defined in: canvas/src/context.ts:413

Clips subsequent drawing operations to the given path.

Parameters

ParameterType
pathCanvasPath
fillRule?FillRule

Returns

void

Overrides

DOMContext.applyClip


applyFill()

applyFill(element, fillRule?): void

Defined in: canvas/src/context.ts:423

Fills the given path or text element using the current fill style.

Parameters

ParameterType
elementContextText | CanvasPath
fillRule?FillRule

Returns

void

Overrides

DOMContext.applyFill


applyGroupPaint()

protected applyGroupPaint(group): void

Defined in: core/src/context/context.ts:558

Applies a group's own inherited paint (fill, stroke, font, line, shadow, text) to the context so descendants pick it up from the copied state. Transforms are applied separately and opacity is composited at the boundary, so both are skipped here.

Parameters

ParameterType
groupElement

Returns

void

Inherited from

DOMContext.applyGroupPaint


applyStroke()

applyStroke(element): void

Defined in: canvas/src/context.ts:428

Strokes the given path or text element using the current stroke style.

Parameters

ParameterType
elementContextText | CanvasPath

Returns

void

Overrides

DOMContext.applyStroke


batch()

batch<TResult>(body): TResult

Defined in: core/src/context/context.ts:514

Clears the rendering surface and brackets the callback in markRenderStart/markRenderEnd, returning the callback's result.

Type Parameters

Type ParameterDefault type
TResultvoid

Parameters

ParameterType
body() => TResult

Returns

TResult

Inherited from

DOMContext.batch


clear()

clear(): void

Defined in: canvas/src/context.ts:366

Clears the entire canvas surface.

Returns

void

Overrides

DOMContext.clear


createPath()

createPath(id?): CanvasPath

Defined in: canvas/src/context.ts:408

Creates a new CanvasPath, optionally reusing an id for diffing efficiency.

Parameters

ParameterType
id?string

Returns

CanvasPath

Overrides

DOMContext.createPath


createText()

createText(options): ContextText

Defined in: core/src/context/context.ts:640

Creates a new text element from the given options.

Parameters

ParameterType
optionsTextOptions

Returns

ContextText

Inherited from

DOMContext.createText


destroy()

destroy(): void

Defined in: dom/src/context.ts:304

Destroys the context, removing the DOM element and disposing all resources.

Returns

void

Inherited from

DOMContext.destroy


disableInteraction()

disableInteraction(): void

Defined in: dom/src/context.ts:292

Disables DOM interaction events and clears the active element set.

Returns

void

Inherited from

DOMContext.disableInteraction


dispose()

protected dispose(key?): void

Defined in: core/src/core/disposer.ts:25

Disposes all resources under the given key, or all resources if no key is provided.

Parameters

ParameterType
key?PropertyKey

Returns

void

Inherited from

DOMContext.dispose


drawImage()

drawImage(image, x, y, width?, height?): void

Defined in: canvas/src/context.ts:418

Draws an image onto the canvas at the given position and optional size.

Parameters

ParameterType
imageCanvasImageSource
xnumber
ynumber
width?number
height?number

Returns

void

Overrides

DOMContext.drawImage


emit()

Call Signature

emit<TEvent>(event): TEvent

Defined in: core/src/core/event-bus.ts:137

Emits an event, invoking all matching handlers and bubbling to the parent if applicable.

Type Parameters
Type ParameterDefault type
TEvent extends Event<undefined>Event<undefined>
Parameters
ParameterType
eventTEvent
Returns

TEvent

Inherited from

DOMContext.emit

Call Signature

emit<TEvent>(type, data): Event<ContextEventMap[TEvent]>

Defined in: core/src/core/event-bus.ts:138

Emits an event, invoking all matching handlers and bubbling to the parent if applicable.

Type Parameters
Type Parameter
TEvent extends keyof ContextEventMap
Parameters
ParameterType
typeTEvent
dataContextEventMap[TEvent]
Returns

Event<ContextEventMap[TEvent]>

Inherited from

DOMContext.emit


enableInteraction()

enableInteraction(): void

Defined in: dom/src/context.ts:264

Enables DOM interaction events (mouse enter, leave, move, click, drag) with element hit testing.

Returns

void

Inherited from

DOMContext.enableInteraction


export()

export(): ContextExport

Defined in: canvas/src/context.ts:443

Captures a snapshot of the canvas and returns format-specific exporters (see ContextExport).

Returns

ContextExport

Overrides

DOMContext.export


getDefaultState()

protected getDefaultState(): BaseState

Defined in: core/src/context/context.ts:444

Returns

BaseState

Inherited from

DOMContext.getDefaultState


has()

has(type): boolean

Defined in: core/src/core/event-bus.ts:94

Returns whether there are any listeners registered for the given event type.

Parameters

ParameterType
typekeyof ContextEventMap

Returns

boolean

Inherited from

DOMContext.has


hitTest()

protected hitTest(events, x, y): RenderElement[]

Defined in: core/src/context/context.ts:679

Tests which rendered elements intersect the given point for the given event types, returning them sorted by zIndex (highest first).

Parameters

ParameterType
eventsstring[]
xnumber
ynumber

Returns

RenderElement[]

Inherited from

DOMContext.hitTest


init()

protected init(): void

Defined in: dom/src/context.ts:81

Returns

void

Inherited from

DOMContext.init


invalidateTrackedElements()

invalidateTrackedElements(event?): void

Defined in: core/src/context/context.ts:491

Clears the cached list of tracked elements for interaction, forcing a rebuild on the next hit test.

Parameters

ParameterType
event?string

Returns

void

Inherited from

DOMContext.invalidateTrackedElements


isPointInPath()

isPointInPath(path, x, y, fillRule?): boolean

Defined in: canvas/src/context.ts:433

Tests whether a point lies inside the filled region of a path.

Parameters

ParameterType
pathCanvasPath
xnumber
ynumber
fillRule?FillRule

Returns

boolean

Overrides

DOMContext.isPointInPath


isPointInStroke()

isPointInStroke(path, x, y): boolean

Defined in: canvas/src/context.ts:438

Tests whether a point lies on the stroked outline of a path.

Parameters

ParameterType
pathCanvasPath
xnumber
ynumber

Returns

boolean

Overrides

DOMContext.isPointInStroke


layer()

layer<TResult>(body): TResult

Defined in: core/src/context/context.ts:470

Executes a callback within a save/restore pair, returning the callback's result.

Type Parameters

Type ParameterDefault type
TResultvoid

Parameters

ParameterType
body() => TResult

Returns

TResult

Inherited from

DOMContext.layer


markRenderEnd()

markRenderEnd(): void

Defined in: core/src/context/context.ts:509

Signals the end of a render pass.

Returns

void

Inherited from

DOMContext.markRenderEnd


markRenderStart()

markRenderStart(): void

Defined in: core/src/context/context.ts:500

Signals the start of a render pass; resets the rendered-elements list at depth 0.

Returns

void

Inherited from

DOMContext.markRenderStart


measureText()

measureText(text, font?): TextMetrics

Defined in: canvas/src/context.ts:403

Measures text dimensions using the canvas context's current font or an optional override.

Parameters

ParameterType
textstring
font?string

Returns

TextMetrics

Overrides

DOMContext.measureText


off()

off<TEvent>(type, handler): void

Defined in: core/src/core/event-bus.ts:112

Removes a previously registered handler for the given event type.

Type Parameters

Type Parameter
TEvent extends keyof ContextEventMap

Parameters

ParameterType
typeTEvent
handlerEventHandler<ContextEventMap[TEvent]>

Returns

void

Inherited from

DOMContext.off


on()

on<TEvent>(type, handler, options?): Disposable

Defined in: core/src/core/event-bus.ts:99

Subscribes a handler to the given event type and returns a disposable for cleanup.

Type Parameters

Type Parameter
TEvent extends keyof ContextEventMap

Parameters

ParameterType
typeTEvent
handlerEventHandler<ContextEventMap[TEvent]>
options?EventSubscriptionOptions

Returns

Disposable

Inherited from

DOMContext.on


once()

once<TEvent>(type, handler, options?): Disposable

Defined in: core/src/core/event-bus.ts:127

Subscribes a handler that is automatically removed after it fires once.

Type Parameters

Type Parameter
TEvent extends keyof ContextEventMap

Parameters

ParameterType
typeTEvent
handlerEventHandler<ContextEventMap[TEvent]>
options?EventSubscriptionOptions

Returns

Disposable

Inherited from

DOMContext.once


popGroup()

popGroup(): void

Defined in: core/src/context/context.ts:578

Closes the most recently opened group boundary, unwinding the state stack back to the depth captured at Context.pushGroup. This absorbs any dangling save() left by a group-scoped clip (which deliberately skips its own restore so the clip persists to later siblings), confining the clip to the group rather than leaking it to the scene.

Returns

void

Inherited from

DOMContext.popGroup


pushGroup()

pushGroup(group): void

Defined in: core/src/context/context.ts:538

Opens a group boundary: saves the current drawing state and applies the group's own transform, inherited paint, and opacity, so that descendant elements render within the group's coordinate system, inherit its paint through the copied state (the render-tree cascade), and composite under its opacity. Any group-scoped clip is confined to the group. Every Context.pushGroup must be balanced by a matching Context.popGroup. Backends that render hierarchy structurally (such as SVG) override this to nest descendants under a group node.

Parameters

ParameterTypeDescription
groupElementThe group element whose boundary is being entered.

Returns

void

Inherited from

DOMContext.pushGroup


rescale()

protected rescale(width, height): void

Defined in: canvas/src/context.ts:336

Parameters

ParameterType
widthnumber
heightnumber

Returns

void

Overrides

DOMContext.rescale


reset()

reset(): void

Defined in: canvas/src/context.ts:371

Resets the canvas context to its default state.

Returns

void

Overrides

DOMContext.reset


restore()

restore(): void

Defined in: canvas/src/context.ts:356

Restores the most recently saved drawing state from the stack.

Returns

void

Overrides

DOMContext.restore


retain()

protected retain(value, key?): void

Defined in: core/src/core/disposer.ts:14

Registers a disposable resource under an optional key for later cleanup.

Parameters

ParameterTypeDefault value
valueDisposableundefined
keyPropertyKeyDisposer.defaultKey

Returns

void

Inherited from

DOMContext.retain


rotate()

rotate(angle): void

Defined in: canvas/src/context.ts:376

Applies a rotation transformation, in radians.

Parameters

ParameterType
anglenumber

Returns

void

Overrides

DOMContext.rotate


save()

save(): void

Defined in: canvas/src/context.ts:350

Saves the current drawing state onto the state stack.

Returns

void

Overrides

DOMContext.save


scale()

scale(x, y): void

Defined in: canvas/src/context.ts:381

Applies a scale transformation.

Parameters

ParameterType
xnumber
ynumber

Returns

void

Overrides

DOMContext.scale


setTransform()

setTransform(a, b, c, d, e, f): void

Defined in: canvas/src/context.ts:392

Replaces the current transformation matrix with the given values.

Parameters

ParameterType
anumber
bnumber
cnumber
dnumber
enumber
fnumber

Returns

void

Overrides

DOMContext.setTransform


transform()

transform(a, b, c, d, e, f): void

Defined in: canvas/src/context.ts:398

Multiplies the current transformation matrix by the given values.

Parameters

ParameterType
anumber
bnumber
cnumber
dnumber
enumber
fnumber

Returns

void

Overrides

DOMContext.transform


translate()

translate(x, y): void

Defined in: canvas/src/context.ts:386

Applies a translation transformation.

Parameters

ParameterType
xnumber
ynumber

Returns

void

Overrides

DOMContext.translate