Documentation / @ripl/core / Context
Abstract Class: Context<TElement, TMeta>
Defined in: packages/core/src/context/context.ts:111
Abstract rendering context providing a unified API for Canvas and SVG, with state management and coordinate scaling.
Extends
Extended by
Type Parameters
| Type Parameter | Default type |
|---|---|
TElement extends Element | Element |
TMeta extends Record<string, unknown> | Record<string, unknown> |
Implements
Constructors
Constructor
new Context<
TElement,TMeta>(type,element,options?):Context<TElement,TMeta>
Defined in: packages/core/src/context/context.ts:414
Parameters
| Parameter | Type |
|---|---|
type | string |
element | TElement |
options? | ContextOptions<TMeta> |
Returns
Context<TElement, TMeta>
Overrides
Properties
| Property | Modifier | Type | Default value | Description | Inherited from | Defined in |
|---|---|---|---|---|---|---|
buffer | public | boolean | false | Whether drawing is buffered rather than committed to the surface immediately. | - | packages/core/src/context/context.ts:121 |
currentState | protected | BaseState | undefined | - | - | packages/core/src/context/context.ts:144 |
element | readonly | TElement | undefined | The underlying DOM element the context renders into. | - | packages/core/src/context/context.ts:116 |
height | public | number | undefined | Current height, in pixels, of the rendering surface. | - | packages/core/src/context/context.ts:131 |
hitTestHonoursTransform | public | boolean | false | Whether 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. | - | packages/core/src/context/context.ts:127 |
meta | readonly | TMeta | undefined | Arbitrary metadata attached to the context. | - | packages/core/src/context/context.ts:118 |
parent? | public | EventBus<ContextEventMap> | undefined | The parent event bus that emitted events bubble up to, if any. | EventBus.parent | packages/core/src/core/event-bus.ts:89 |
renderDepth | protected | number | 0 | - | - | packages/core/src/context/context.ts:145 |
renderedElements | public | RenderElement[] | undefined | Elements rendered during the current pass, used for hit testing. | - | packages/core/src/context/context.ts:141 |
renderElement? | public | RenderElement | undefined | The element currently being rendered, if any. | - | packages/core/src/context/context.ts:139 |
saveDepth | protected | number | 0 | - | - | packages/core/src/context/context.ts:146 |
scaleDPR | public | Scale<number, number> | undefined | Scale mapping logical pixels to device pixels using the device pixel ratio. | - | packages/core/src/context/context.ts:137 |
scaleX | public | Scale<number, number> | undefined | Scale mapping domain x coordinates to surface x coordinates. | - | packages/core/src/context/context.ts:133 |
scaleY | public | Scale<number, number> | undefined | Scale mapping domain y coordinates to surface y coordinates. | - | packages/core/src/context/context.ts:135 |
states | protected | BaseState[] | undefined | - | - | packages/core/src/context/context.ts:143 |
type | readonly | string | undefined | The context type identifier (e.g. canvas, svg). | - | packages/core/src/context/context.ts:114 |
width | public | number | undefined | Current width, in pixels, of the rendering surface. | - | packages/core/src/context/context.ts:129 |
defaultKey | readonly | typeof defaultKey | undefined | The key under which resources are retained when no explicit key is provided. | EventBus.defaultKey | packages/core/src/core/disposer.ts:11 |
Accessors
currentRenderElement
Get Signature
get currentRenderElement():
RenderElement|undefined
Defined in: packages/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: packages/core/src/context/context.ts:154
Parameters
| Parameter | Type |
|---|---|
element | RenderElement | undefined |
Returns
void
direction
Get Signature
get direction():
Direction
Defined in: packages/core/src/context/context.ts:181
Directionality used when rendering text.
Returns
Set Signature
set direction(
value):void
Defined in: packages/core/src/context/context.ts:185
Directionality used when rendering text.
Parameters
| Parameter | Type |
|---|---|
value | Direction |
Returns
void
Directionality used when rendering text.
Implementation of
fill
Get Signature
get fill():
string
Defined in: packages/core/src/context/context.ts:163
Fill style (CSS colour, gradient, or pattern) used to paint filled regions.
Returns
string
Set Signature
set fill(
value):void
Defined in: packages/core/src/context/context.ts:167
Fill style (CSS colour, gradient, or pattern) used to paint filled regions.
Parameters
| Parameter | Type |
|---|---|
value | string |
Returns
void
Fill style (CSS colour, gradient, or pattern) used to paint filled regions.
Implementation of
filter
Get Signature
get filter():
string
Defined in: packages/core/src/context/context.ts:172
CSS filter string applied to subsequent drawing operations (e.g. blur(4px)).
Returns
string
Set Signature
set filter(
value):void
Defined in: packages/core/src/context/context.ts:176
CSS filter string applied to subsequent drawing operations (e.g. blur(4px)).
Parameters
| Parameter | Type |
|---|---|
value | string |
Returns
void
CSS filter string applied to subsequent drawing operations (e.g. blur(4px)).
Implementation of
font
Get Signature
get font():
string
Defined in: packages/core/src/context/context.ts:190
CSS font shorthand used when rendering text.
Returns
string
Set Signature
set font(
value):void
Defined in: packages/core/src/context/context.ts:194
CSS font shorthand used when rendering text.
Parameters
| Parameter | Type |
|---|---|
value | string |
Returns
void
CSS font shorthand used when rendering text.
Implementation of
fontKerning
Get Signature
get fontKerning():
FontKerning
Defined in: packages/core/src/context/context.ts:199
Whether font kerning is applied when rendering text.
Returns
Set Signature
set fontKerning(
value):void
Defined in: packages/core/src/context/context.ts:203
Whether font kerning is applied when rendering text.
Parameters
| Parameter | Type |
|---|---|
value | FontKerning |
Returns
void
Whether font kerning is applied when rendering text.
Implementation of
globalCompositeOperation
Get Signature
get globalCompositeOperation():
unknown
Defined in: packages/core/src/context/context.ts:217
Compositing operation controlling how new drawing is blended with existing content.
Returns
unknown
Set Signature
set globalCompositeOperation(
value):void
Defined in: packages/core/src/context/context.ts:221
Compositing operation controlling how new drawing is blended with existing content.
Parameters
| Parameter | Type |
|---|---|
value | unknown |
Returns
void
Compositing operation controlling how new drawing is blended with existing content.
Implementation of
BaseState.globalCompositeOperation
lineCap
Get Signature
get lineCap():
LineCap
Defined in: packages/core/src/context/context.ts:226
Cap style drawn at the endpoints of stroked lines.
Returns
Set Signature
set lineCap(
value):void
Defined in: packages/core/src/context/context.ts:230
Cap style drawn at the endpoints of stroked lines.
Parameters
| Parameter | Type |
|---|---|
value | LineCap |
Returns
void
Cap style drawn at the endpoints of stroked lines.
Implementation of
lineDash
Get Signature
get lineDash():
number[]
Defined in: packages/core/src/context/context.ts:235
Dash pattern as alternating stroke and gap lengths; empty for a solid line.
Returns
number[]
Set Signature
set lineDash(
value):void
Defined in: packages/core/src/context/context.ts:239
Dash pattern as alternating stroke and gap lengths; empty for a solid line.
Parameters
| Parameter | Type |
|---|---|
value | number[] |
Returns
void
Dash pattern as alternating stroke and gap lengths; empty for a solid line.
Implementation of
lineDashOffset
Get Signature
get lineDashOffset():
number
Defined in: packages/core/src/context/context.ts:244
Distance into the line dash pattern at which dashing begins.
Returns
number
Set Signature
set lineDashOffset(
value):void
Defined in: packages/core/src/context/context.ts:248
Distance into the line dash pattern at which dashing begins.
Parameters
| Parameter | Type |
|---|---|
value | number |
Returns
void
Distance into the line dash pattern at which dashing begins.
Implementation of
lineJoin
Get Signature
get lineJoin():
LineJoin
Defined in: packages/core/src/context/context.ts:253
Join style drawn where two stroked segments meet.
Returns
Set Signature
set lineJoin(
value):void
Defined in: packages/core/src/context/context.ts:257
Join style drawn where two stroked segments meet.
Parameters
| Parameter | Type |
|---|---|
value | LineJoin |
Returns
void
Join style drawn where two stroked segments meet.
Implementation of
lineWidth
Get Signature
get lineWidth():
number
Defined in: packages/core/src/context/context.ts:262
Width, in pixels, of stroked lines.
Returns
number
Set Signature
set lineWidth(
value):void
Defined in: packages/core/src/context/context.ts:266
Width, in pixels, of stroked lines.
Parameters
| Parameter | Type |
|---|---|
value | number |
Returns
void
Width, in pixels, of stroked lines.
Implementation of
miterLimit
Get Signature
get miterLimit():
number
Defined in: packages/core/src/context/context.ts:271
Miter length limit ratio applied to miter line joins.
Returns
number
Set Signature
set miterLimit(
value):void
Defined in: packages/core/src/context/context.ts:275
Miter length limit ratio applied to miter line joins.
Parameters
| Parameter | Type |
|---|---|
value | number |
Returns
void
Miter length limit ratio applied to miter line joins.
Implementation of
opacity
Get Signature
get opacity():
number
Defined in: packages/core/src/context/context.ts:208
Global alpha applied to everything drawn, from 0 to 1.
Returns
number
Set Signature
set opacity(
value):void
Defined in: packages/core/src/context/context.ts:212
Global alpha applied to everything drawn, from 0 to 1.
Parameters
| Parameter | Type |
|---|---|
value | number |
Returns
void
Global alpha applied to everything drawn, from 0 to 1.
Implementation of
rotation
Get Signature
get rotation():
Rotation
Defined in: packages/core/src/context/context.ts:388
Rotation applied to the element's transform, as radians or a deg/rad string.
Returns
Set Signature
set rotation(
value):void
Defined in: packages/core/src/context/context.ts:392
Rotation applied to the element's transform, as radians or a deg/rad string.
Parameters
| Parameter | Type |
|---|---|
value | Rotation |
Returns
void
Rotation applied to the element's transform, as radians or a deg/rad string.
Implementation of
shadowBlur
Get Signature
get shadowBlur():
number
Defined in: packages/core/src/context/context.ts:280
Gaussian blur radius applied to drawn shadows.
Returns
number
Set Signature
set shadowBlur(
value):void
Defined in: packages/core/src/context/context.ts:284
Gaussian blur radius applied to drawn shadows.
Parameters
| Parameter | Type |
|---|---|
value | number |
Returns
void
Gaussian blur radius applied to drawn shadows.
Implementation of
shadowColor
Get Signature
get shadowColor():
string
Defined in: packages/core/src/context/context.ts:289
Colour of drawn shadows.
Returns
string
Set Signature
set shadowColor(
value):void
Defined in: packages/core/src/context/context.ts:293
Colour of drawn shadows.
Parameters
| Parameter | Type |
|---|---|
value | string |
Returns
void
Colour of drawn shadows.
Implementation of
shadowOffsetX
Get Signature
get shadowOffsetX():
number
Defined in: packages/core/src/context/context.ts:298
Horizontal offset, in pixels, of drawn shadows.
Returns
number
Set Signature
set shadowOffsetX(
value):void
Defined in: packages/core/src/context/context.ts:302
Horizontal offset, in pixels, of drawn shadows.
Parameters
| Parameter | Type |
|---|---|
value | number |
Returns
void
Horizontal offset, in pixels, of drawn shadows.
Implementation of
shadowOffsetY
Get Signature
get shadowOffsetY():
number
Defined in: packages/core/src/context/context.ts:307
Vertical offset, in pixels, of drawn shadows.
Returns
number
Set Signature
set shadowOffsetY(
value):void
Defined in: packages/core/src/context/context.ts:311
Vertical offset, in pixels, of drawn shadows.
Parameters
| Parameter | Type |
|---|---|
value | number |
Returns
void
Vertical offset, in pixels, of drawn shadows.
Implementation of
stroke
Get Signature
get stroke():
string
Defined in: packages/core/src/context/context.ts:316
Stroke style (CSS colour, gradient, or pattern) used to paint outlines.
Returns
string
Set Signature
set stroke(
value):void
Defined in: packages/core/src/context/context.ts:320
Stroke style (CSS colour, gradient, or pattern) used to paint outlines.
Parameters
| Parameter | Type |
|---|---|
value | string |
Returns
void
Stroke style (CSS colour, gradient, or pattern) used to paint outlines.
Implementation of
textAlign
Get Signature
get textAlign():
TextAlignment
Defined in: packages/core/src/context/context.ts:325
Horizontal alignment of text relative to the drawing position.
Returns
Set Signature
set textAlign(
value):void
Defined in: packages/core/src/context/context.ts:329
Horizontal alignment of text relative to the drawing position.
Parameters
| Parameter | Type |
|---|---|
value | TextAlignment |
Returns
void
Horizontal alignment of text relative to the drawing position.
Implementation of
textBaseline
Get Signature
get textBaseline():
TextBaseline
Defined in: packages/core/src/context/context.ts:334
Vertical baseline used when positioning text.
Returns
Set Signature
set textBaseline(
value):void
Defined in: packages/core/src/context/context.ts:338
Vertical baseline used when positioning text.
Parameters
| Parameter | Type |
|---|---|
value | TextBaseline |
Returns
void
Vertical baseline used when positioning text.
Implementation of
transformOriginX
Get Signature
get transformOriginX():
TransformOrigin
Defined in: packages/core/src/context/context.ts:397
Horizontal origin about which rotation and scaling are applied.
Returns
Set Signature
set transformOriginX(
value):void
Defined in: packages/core/src/context/context.ts:401
Horizontal origin about which rotation and scaling are applied.
Parameters
| Parameter | Type |
|---|---|
value | TransformOrigin |
Returns
void
Horizontal origin about which rotation and scaling are applied.
Implementation of
transformOriginY
Get Signature
get transformOriginY():
TransformOrigin
Defined in: packages/core/src/context/context.ts:406
Vertical origin about which rotation and scaling are applied.
Returns
Set Signature
set transformOriginY(
value):void
Defined in: packages/core/src/context/context.ts:410
Vertical origin about which rotation and scaling are applied.
Parameters
| Parameter | Type |
|---|---|
value | TransformOrigin |
Returns
void
Vertical origin about which rotation and scaling are applied.
Implementation of
transformScaleX
Get Signature
get transformScaleX():
number
Defined in: packages/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: packages/core/src/context/context.ts:374
Horizontal scale factor applied to the element's transform.
Parameters
| Parameter | Type |
|---|---|
value | number |
Returns
void
Horizontal scale factor applied to the element's transform.
Implementation of
transformScaleY
Get Signature
get transformScaleY():
number
Defined in: packages/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: packages/core/src/context/context.ts:383
Vertical scale factor applied to the element's transform.
Parameters
| Parameter | Type |
|---|---|
value | number |
Returns
void
Vertical scale factor applied to the element's transform.
Implementation of
translateX
Get Signature
get translateX():
number
Defined in: packages/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: packages/core/src/context/context.ts:356
Horizontal translation, in pixels, applied to the element's transform.
Parameters
| Parameter | Type |
|---|---|
value | number |
Returns
void
Horizontal translation, in pixels, applied to the element's transform.
Implementation of
translateY
Get Signature
get translateY():
number
Defined in: packages/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: packages/core/src/context/context.ts:365
Vertical translation, in pixels, applied to the element's transform.
Parameters
| Parameter | Type |
|---|---|
value | number |
Returns
void
Vertical translation, in pixels, applied to the element's transform.
Implementation of
zIndex
Get Signature
get zIndex():
number
Defined in: packages/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: packages/core/src/context/context.ts:347
Stacking order used to sort elements during rendering; higher values draw on top.
Parameters
| Parameter | Type |
|---|---|
value | number |
Returns
void
Stacking order used to sort elements during rendering; higher values draw on top.
Implementation of
Methods
applyClip()
applyClip(
path,fillRule?):void
Defined in: packages/core/src/context/context.ts:650
Clips subsequent drawing operations to the given path.
Parameters
| Parameter | Type |
|---|---|
path | ContextPath |
fillRule? | FillRule |
Returns
void
applyFill()
applyFill(
path,fillRule?):void
Defined in: packages/core/src/context/context.ts:655
Fills the given path or text element using the current fill style.
Parameters
| Parameter | Type |
|---|---|
path | ContextElement |
fillRule? | FillRule |
Returns
void
applyGroupPaint()
protectedapplyGroupPaint(group):void
Defined in: packages/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
| Parameter | Type |
|---|---|
group | Element |
Returns
void
applyStroke()
applyStroke(
path):void
Defined in: packages/core/src/context/context.ts:660
Strokes the given path or text element using the current stroke style.
Parameters
| Parameter | Type |
|---|---|
path | ContextElement |
Returns
void
batch()
batch<
TResult>(body):TResult
Defined in: packages/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 Parameter | Default type |
|---|---|
TResult | void |
Parameters
| Parameter | Type |
|---|---|
body | () => TResult |
Returns
TResult
clear()
clear():
void
Defined in: packages/core/src/context/context.ts:481
Clears the entire rendering surface.
Returns
void
createPath()
createPath(
id?):ContextPath
Defined in: packages/core/src/context/context.ts:635
Creates a new path element, optionally reusing an id for SVG diffing efficiency.
Parameters
| Parameter | Type |
|---|---|
id? | string |
Returns
createText()
createText(
options):ContextText
Defined in: packages/core/src/context/context.ts:640
Creates a new text element from the given options.
Parameters
| Parameter | Type |
|---|---|
options | TextOptions |
Returns
destroy()
destroy():
void
Defined in: packages/core/src/context/context.ts:703
Destroys the context and disposes all resources.
Returns
void
Overrides
dispose()
protecteddispose(key?):void
Defined in: packages/core/src/core/disposer.ts:25
Disposes all resources under the given key, or all resources if no key is provided.
Parameters
| Parameter | Type |
|---|---|
key? | PropertyKey |
Returns
void
Inherited from
drawImage()
drawImage(
image,x,y,width?,height?):void
Defined in: packages/core/src/context/context.ts:645
Draws an image onto the rendering surface at the given position and optional size.
Parameters
| Parameter | Type |
|---|---|
image | CanvasImageSource |
x | number |
y | number |
width? | number |
height? | number |
Returns
void
emit()
Call Signature
emit<
TEvent>(event):TEvent
Defined in: packages/core/src/core/event-bus.ts:137
Emits an event, invoking all matching handlers and bubbling to the parent if applicable.
Type Parameters
| Type Parameter | Default type |
|---|---|
TEvent extends Event<undefined> | Event<undefined> |
Parameters
| Parameter | Type |
|---|---|
event | TEvent |
Returns
TEvent
Inherited from
Call Signature
emit<
TEvent>(type,data):Event<ContextEventMap[TEvent]>
Defined in: packages/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
| Parameter | Type |
|---|---|
type | TEvent |
data | ContextEventMap[TEvent] |
Returns
Event<ContextEventMap[TEvent]>
Inherited from
export()
export():
ContextExport
Defined in: packages/core/src/context/context.ts:698
Captures a snapshot of the current context surface and returns format-specific exporters (see ContextExport). The base implementation is unsupported; each context overrides this with the formats relevant to it (image, url, string).
Returns
getDefaultState()
protectedgetDefaultState():BaseState
Defined in: packages/core/src/context/context.ts:444
Returns
has()
has(
type):boolean
Defined in: packages/core/src/core/event-bus.ts:94
Returns whether there are any listeners registered for the given event type.
Parameters
| Parameter | Type |
|---|---|
type | keyof ContextEventMap |
Returns
boolean
Inherited from
hitTest()
protectedhitTest(events,x,y):RenderElement[]
Defined in: packages/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
| Parameter | Type |
|---|---|
events | string[] |
x | number |
y | number |
Returns
invalidateTrackedElements()
invalidateTrackedElements(
event?):void
Defined in: packages/core/src/context/context.ts:491
Clears the cached list of tracked elements for interaction, forcing a rebuild on the next hit test.
Parameters
| Parameter | Type |
|---|---|
event? | string |
Returns
void
isPointInPath()
isPointInPath(
path,x,y,fillRule?):boolean
Defined in: packages/core/src/context/context.ts:665
Tests whether a point is inside the filled region of a path.
Parameters
| Parameter | Type |
|---|---|
path | ContextPath |
x | number |
y | number |
fillRule? | FillRule |
Returns
boolean
isPointInStroke()
isPointInStroke(
path,x,y):boolean
Defined in: packages/core/src/context/context.ts:670
Tests whether a point is on the stroked outline of a path.
Parameters
| Parameter | Type |
|---|---|
path | ContextPath |
x | number |
y | number |
Returns
boolean
layer()
layer<
TResult>(body):TResult
Defined in: packages/core/src/context/context.ts:470
Executes a callback within a save/restore pair, returning the callback's result.
Type Parameters
| Type Parameter | Default type |
|---|---|
TResult | void |
Parameters
| Parameter | Type |
|---|---|
body | () => TResult |
Returns
TResult
markRenderEnd()
markRenderEnd():
void
Defined in: packages/core/src/context/context.ts:509
Signals the end of a render pass.
Returns
void
markRenderStart()
markRenderStart():
void
Defined in: packages/core/src/context/context.ts:500
Signals the start of a render pass; resets the rendered-elements list at depth 0.
Returns
void
measureText()
measureText(
text,font?):TextMetrics
Defined in: packages/core/src/context/context.ts:630
Measures text dimensions using the context's current font or an optional override.
Parameters
| Parameter | Type |
|---|---|
text | string |
font? | string |
Returns
TextMetrics
off()
off<
TEvent>(type,handler):void
Defined in: packages/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
| Parameter | Type |
|---|---|
type | TEvent |
handler | EventHandler<ContextEventMap[TEvent]> |
Returns
void
Inherited from
on()
on<
TEvent>(type,handler,options?):Disposable
Defined in: packages/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
| Parameter | Type |
|---|---|
type | TEvent |
handler | EventHandler<ContextEventMap[TEvent]> |
options? | EventSubscriptionOptions |
Returns
Inherited from
once()
once<
TEvent>(type,handler,options?):Disposable
Defined in: packages/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
| Parameter | Type |
|---|---|
type | TEvent |
handler | EventHandler<ContextEventMap[TEvent]> |
options? | EventSubscriptionOptions |
Returns
Inherited from
popGroup()
popGroup():
void
Defined in: packages/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
pushGroup()
pushGroup(
group):void
Defined in: packages/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
| Parameter | Type | Description |
|---|---|---|
group | Element | The group element whose boundary is being entered. |
Returns
void
rescale()
protectedrescale(width,height):void
Defined in: packages/core/src/context/context.ts:434
Parameters
| Parameter | Type |
|---|---|
width | number |
height | number |
Returns
void
reset()
reset():
void
Defined in: packages/core/src/context/context.ts:486
Resets the context to its initial state.
Returns
void
restore()
restore():
void
Defined in: packages/core/src/context/context.ts:460
Restores the most recently saved state from the stack.
Returns
void
retain()
protectedretain(value,key?):void
Defined in: packages/core/src/core/disposer.ts:14
Registers a disposable resource under an optional key for later cleanup.
Parameters
| Parameter | Type | Default value |
|---|---|---|
value | Disposable | undefined |
key | PropertyKey | Disposer.defaultKey |
Returns
void
Inherited from
rotate()
rotate(
angle):void
Defined in: packages/core/src/context/context.ts:587
Applies a rotation transformation.
Parameters
| Parameter | Type |
|---|---|
angle | number |
Returns
void
save()
save():
void
Defined in: packages/core/src/context/context.ts:453
Pushes the current state onto the stack and continues with a copy of it, so nested scopes inherit the enclosing drawing state (matching native canvas). This is what lets a group's paint, applied once at its boundary via Context.pushGroup, cascade to descendants.
Returns
void
scale()
scale(
x,y):void
Defined in: packages/core/src/context/context.ts:592
Applies a scale transformation.
Parameters
| Parameter | Type |
|---|---|
x | number |
y | number |
Returns
void
setTransform()
setTransform(
a,b,c,d,e,f):void
Defined in: packages/core/src/context/context.ts:611
Replaces the current transformation matrix with [a, b, c, d, e, f].
Parameters
| Parameter | Type | Description |
|---|---|---|
a | number | Horizontal scaling. |
b | number | Vertical skewing. |
c | number | Horizontal skewing. |
d | number | Vertical scaling. |
e | number | Horizontal translation. |
f | number | Vertical translation. |
Returns
void
transform()
transform(
a,b,c,d,e,f):void
Defined in: packages/core/src/context/context.ts:625
Multiplies the current transformation matrix by [a, b, c, d, e, f].
Parameters
| Parameter | Type | Description |
|---|---|---|
a | number | Horizontal scaling. |
b | number | Vertical skewing. |
c | number | Horizontal skewing. |
d | number | Vertical scaling. |
e | number | Horizontal translation. |
f | number | Vertical translation. |
Returns
void
translate()
translate(
x,y):void
Defined in: packages/core/src/context/context.ts:597
Applies a translation transformation.
Parameters
| Parameter | Type |
|---|---|
x | number |
y | number |
Returns
void