Documentation / @ripl/svg / SVGContext
Class: SVGContext ​
Defined in: svg/src/context.ts:96
SVG rendering context implementation, mapping the unified API to SVG DOM elements via virtual-DOM reconciliation.
Extends ​
DOMContext<SVGSVGElement>
Constructors ​
Constructor ​
new SVGContext(
target,options?):SVGContext
Defined in: svg/src/context.ts:115
Parameters ​
| Parameter | Type |
|---|---|
target | string | HTMLElement |
options? | ContextOptions<Record<string, unknown>> |
Returns ​
SVGContext
Overrides ​
Properties ​
| Property | Modifier | Type | Default value | Description | Inherited from | Defined in |
|---|---|---|---|---|---|---|
currentState | protected | BaseState | undefined | - | DOMContext.currentState | core/src/context/context.ts:104 |
element | readonly | SVGSVGElement | undefined | The underlying DOM element the context renders into. | DOMContext.element | core/src/context/context.ts:111 |
height | public | number | undefined | Current height of the rendering surface, in logical pixels — CSS pixels, unaffected by the device pixel ratio. | DOMContext.height | core/src/context/context.ts:124 |
hitTestHonorsTransform | 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 Element.getWorldTransform. | DOMContext.hitTestHonorsTransform | core/src/context/context.ts:120 |
meta | readonly | TMeta | undefined | Arbitrary metadata attached to the context. | DOMContext.meta | core/src/context/context.ts:113 |
parent? | public | EventBus<ContextEventMap> | undefined | The parent event bus that emitted events bubble up to, if any. | DOMContext.parent | core/src/core/event-bus.ts:107 |
renderDepth | protected | number | 0 | - | DOMContext.renderDepth | core/src/context/context.ts:105 |
renderedElements | public | RenderElement[] | undefined | Elements rendered during the current pass, used for hit testing. | DOMContext.renderedElements | core/src/context/context.ts:132 |
renderElement? | public | RenderElement | undefined | The element currently being rendered, if any. | DOMContext.renderElement | core/src/context/context.ts:130 |
root | readonly | HTMLElement | undefined | The host DOM element that the context's rendering surface is mounted into. | DOMContext.root | dom/src/context.ts:48 |
saveDepth | protected | number | 0 | - | DOMContext.saveDepth | core/src/context/context.ts:106 |
scaleX | public | Scale<number, number> | undefined | Scale mapping logical x coordinates onto this backend's surface x coordinates. Drives drawing, not a conversion seam for callers — use Context.toSurfacePoint. | DOMContext.scaleX | core/src/context/context.ts:126 |
scaleY | public | Scale<number, number> | undefined | Scale mapping logical y coordinates onto this backend's surface y coordinates. Drives drawing, not a conversion seam for callers — use Context.toSurfacePoint. | DOMContext.scaleY | core/src/context/context.ts:128 |
states | protected | BaseState[] | undefined | - | DOMContext.states | core/src/context/context.ts:103 |
type | readonly | string | undefined | The context type identifier (e.g. canvas, svg). | DOMContext.type | core/src/context/context.ts:109 |
width | public | number | undefined | Current width of the rendering surface, in logical pixels — CSS pixels, unaffected by the device pixel ratio. | DOMContext.width | core/src/context/context.ts:122 |
defaultKey | readonly | typeof defaultKey | undefined | The key under which resources are retained when no explicit key is provided. | DOMContext.defaultKey | core/src/core/disposer.ts:11 |
Accessors ​
$events ​
Get Signature ​
get $events(): keyof
ContextEventMap[]
Defined in: core/src/context/context.ts:135
The event types a context can emit. See EventBus.$events.
Returns ​
keyof ContextEventMap[]
Inherited from ​
currentRenderElement ​
Get Signature ​
get currentRenderElement():
RenderElement|undefined
Defined in: core/src/context/context.ts:153
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:157
Parameters ​
| Parameter | Type |
|---|---|
element | RenderElement | undefined |
Returns ​
void
Inherited from ​
DOMContext.currentRenderElement
direction ​
Get Signature ​
get direction():
Direction
Defined in: core/src/context/context.ts:184
Directionality used when rendering text.
Returns ​
Set Signature ​
set direction(
value):void
Defined in: core/src/context/context.ts:188
Directionality used when rendering text.
Parameters ​
| Parameter | Type |
|---|---|
value | Direction |
Returns ​
void
Directionality used when rendering text.
Inherited from ​
fill ​
Get Signature ​
get fill():
string
Defined in: core/src/context/context.ts:166
Fill style (CSS color, gradient, or pattern) used to paint filled regions.
Returns ​
string
Set Signature ​
set fill(
value):void
Defined in: core/src/context/context.ts:170
Fill style (CSS color, gradient, or pattern) used to paint filled regions.
Parameters ​
| Parameter | Type |
|---|---|
value | string |
Returns ​
void
Fill style (CSS color, gradient, or pattern) used to paint filled regions.
Inherited from ​
filter ​
Get Signature ​
get filter():
string
Defined in: core/src/context/context.ts:175
CSS filter string applied to subsequent drawing operations (e.g. blur(4px)).
Returns ​
string
Set Signature ​
set filter(
value):void
Defined in: core/src/context/context.ts:179
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)).
Inherited from ​
font ​
Get Signature ​
get font():
string
Defined in: core/src/context/context.ts:193
CSS font shorthand used when rendering text.
Returns ​
string
Set Signature ​
set font(
value):void
Defined in: core/src/context/context.ts:197
CSS font shorthand used when rendering text.
Parameters ​
| Parameter | Type |
|---|---|
value | string |
Returns ​
void
CSS font shorthand used when rendering text.
Inherited from ​
fontKerning ​
Get Signature ​
get fontKerning():
FontKerning
Defined in: core/src/context/context.ts:202
Whether font kerning is applied when rendering text.
Returns ​
Set Signature ​
set fontKerning(
value):void
Defined in: core/src/context/context.ts:206
Whether font kerning is applied when rendering text.
Parameters ​
| Parameter | Type |
|---|---|
value | FontKerning |
Returns ​
void
Whether font kerning is applied when rendering text.
Inherited from ​
globalCompositeOperation ​
Get Signature ​
get globalCompositeOperation():
unknown
Defined in: core/src/context/context.ts:220
Compositing operation controlling how new drawing is blended with existing content.
Returns ​
unknown
Set Signature ​
set globalCompositeOperation(
value):void
Defined in: core/src/context/context.ts:224
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.
Inherited from ​
DOMContext.globalCompositeOperation
lineCap ​
Get Signature ​
get lineCap():
LineCap
Defined in: core/src/context/context.ts:229
Cap style drawn at the endpoints of stroked lines.
Returns ​
Set Signature ​
set lineCap(
value):void
Defined in: core/src/context/context.ts:233
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.
Inherited from ​
lineDash ​
Get Signature ​
get lineDash():
number[]
Defined in: core/src/context/context.ts:238
Dash pattern as alternating stroke and gap lengths; empty for a solid line.
Returns ​
number[]
Set Signature ​
set lineDash(
value):void
Defined in: core/src/context/context.ts:242
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.
Inherited from ​
lineDashOffset ​
Get Signature ​
get lineDashOffset():
number
Defined in: core/src/context/context.ts:247
Distance into the line dash pattern at which dashing begins.
Returns ​
number
Set Signature ​
set lineDashOffset(
value):void
Defined in: core/src/context/context.ts:251
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.
Inherited from ​
lineJoin ​
Get Signature ​
get lineJoin():
LineJoin
Defined in: core/src/context/context.ts:256
Join style drawn where two stroked segments meet.
Returns ​
Set Signature ​
set lineJoin(
value):void
Defined in: core/src/context/context.ts:260
Join style drawn where two stroked segments meet.
Parameters ​
| Parameter | Type |
|---|---|
value | LineJoin |
Returns ​
void
Join style drawn where two stroked segments meet.
Inherited from ​
lineWidth ​
Get Signature ​
get lineWidth():
number
Defined in: core/src/context/context.ts:265
Width, in pixels, of stroked lines.
Returns ​
number
Set Signature ​
set lineWidth(
value):void
Defined in: core/src/context/context.ts:269
Width, in pixels, of stroked lines.
Parameters ​
| Parameter | Type |
|---|---|
value | number |
Returns ​
void
Width, in pixels, of stroked lines.
Inherited from ​
miterLimit ​
Get Signature ​
get miterLimit():
number
Defined in: core/src/context/context.ts:274
Miter length limit ratio applied to miter line joins.
Returns ​
number
Set Signature ​
set miterLimit(
value):void
Defined in: core/src/context/context.ts:278
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.
Inherited from ​
opacity ​
Get Signature ​
get opacity():
number
Defined in: core/src/context/context.ts:211
Global alpha applied to everything drawn, from 0 to 1. Assignment replaces the current alpha; element and group opacity instead composite multiplicatively through CONTEXT_OPERATIONS.
Returns ​
number
Set Signature ​
set opacity(
value):void
Defined in: core/src/context/context.ts:215
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.
Inherited from ​
rotation ​
Get Signature ​
get rotation():
Rotation
Defined in: core/src/context/context.ts:391
Rotation applied to the element's transform, as radians or a deg/rad string.
Returns ​
Set Signature ​
set rotation(
value):void
Defined in: core/src/context/context.ts:395
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.
Inherited from ​
shadowBlur ​
Get Signature ​
get shadowBlur():
number
Defined in: core/src/context/context.ts:283
Gaussian blur radius applied to drawn shadows.
Returns ​
number
Set Signature ​
set shadowBlur(
value):void
Defined in: core/src/context/context.ts:287
Gaussian blur radius applied to drawn shadows.
Parameters ​
| Parameter | Type |
|---|---|
value | number |
Returns ​
void
Gaussian blur radius applied to drawn shadows.
Inherited from ​
shadowColor ​
Get Signature ​
get shadowColor():
string
Defined in: core/src/context/context.ts:292
Color of drawn shadows.
Returns ​
string
Set Signature ​
set shadowColor(
value):void
Defined in: core/src/context/context.ts:296
Color of drawn shadows.
Parameters ​
| Parameter | Type |
|---|---|
value | string |
Returns ​
void
Color of drawn shadows.
Inherited from ​
shadowOffsetX ​
Get Signature ​
get shadowOffsetX():
number
Defined in: core/src/context/context.ts:301
Horizontal offset, in pixels, of drawn shadows.
Returns ​
number
Set Signature ​
set shadowOffsetX(
value):void
Defined in: core/src/context/context.ts:305
Horizontal offset, in pixels, of drawn shadows.
Parameters ​
| Parameter | Type |
|---|---|
value | number |
Returns ​
void
Horizontal offset, in pixels, of drawn shadows.
Inherited from ​
shadowOffsetY ​
Get Signature ​
get shadowOffsetY():
number
Defined in: core/src/context/context.ts:310
Vertical offset, in pixels, of drawn shadows.
Returns ​
number
Set Signature ​
set shadowOffsetY(
value):void
Defined in: core/src/context/context.ts:314
Vertical offset, in pixels, of drawn shadows.
Parameters ​
| Parameter | Type |
|---|---|
value | number |
Returns ​
void
Vertical offset, in pixels, of drawn shadows.
Inherited from ​
stroke ​
Get Signature ​
get stroke():
string
Defined in: core/src/context/context.ts:319
Stroke style (CSS color, gradient, or pattern) used to paint outlines.
Returns ​
string
Set Signature ​
set stroke(
value):void
Defined in: core/src/context/context.ts:323
Stroke style (CSS color, gradient, or pattern) used to paint outlines.
Parameters ​
| Parameter | Type |
|---|---|
value | string |
Returns ​
void
Stroke style (CSS color, gradient, or pattern) used to paint outlines.
Inherited from ​
supportsPathCaching ​
Get Signature ​
get supportsPathCaching():
boolean
Defined in: core/src/context/context.ts:733
Whether cached ContextPaths may be safely reused across render cycles. false by default; backends whose Context.createPath is free of per-frame side effects (e.g. canvas) override this to true. SVG, for example, returns false because createPath registers the path into a per-frame virtual DOM tree.
Returns ​
boolean
Inherited from ​
DOMContext.supportsPathCaching
textAlign ​
Get Signature ​
get textAlign():
TextAlignment
Defined in: core/src/context/context.ts:328
Horizontal alignment of text relative to the drawing position.
Returns ​
Set Signature ​
set textAlign(
value):void
Defined in: core/src/context/context.ts:332
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.
Inherited from ​
textBaseline ​
Get Signature ​
get textBaseline():
TextBaseline
Defined in: core/src/context/context.ts:337
Vertical baseline used when positioning text.
Returns ​
Set Signature ​
set textBaseline(
value):void
Defined in: core/src/context/context.ts:341
Vertical baseline used when positioning text.
Parameters ​
| Parameter | Type |
|---|---|
value | TextBaseline |
Returns ​
void
Vertical baseline used when positioning text.
Inherited from ​
transformOriginX ​
Get Signature ​
get transformOriginX():
TransformOrigin
Defined in: core/src/context/context.ts:400
Horizontal origin about which rotation and scaling are applied.
Returns ​
Set Signature ​
set transformOriginX(
value):void
Defined in: core/src/context/context.ts:404
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.
Inherited from ​
transformOriginY ​
Get Signature ​
get transformOriginY():
TransformOrigin
Defined in: core/src/context/context.ts:409
Vertical origin about which rotation and scaling are applied.
Returns ​
Set Signature ​
set transformOriginY(
value):void
Defined in: core/src/context/context.ts:413
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.
Inherited from ​
transformScaleX ​
Get Signature ​
get transformScaleX():
number
Defined in: core/src/context/context.ts:373
Horizontal scale factor applied to the element's transform.
Returns ​
number
Set Signature ​
set transformScaleX(
value):void
Defined in: core/src/context/context.ts:377
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.
Inherited from ​
transformScaleY ​
Get Signature ​
get transformScaleY():
number
Defined in: core/src/context/context.ts:382
Vertical scale factor applied to the element's transform.
Returns ​
number
Set Signature ​
set transformScaleY(
value):void
Defined in: core/src/context/context.ts:386
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.
Inherited from ​
translateX ​
Get Signature ​
get translateX():
number
Defined in: core/src/context/context.ts:355
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:359
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.
Inherited from ​
translateY ​
Get Signature ​
get translateY():
number
Defined in: core/src/context/context.ts:364
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:368
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.
Inherited from ​
zIndex ​
Get Signature ​
get zIndex():
number
Defined in: core/src/context/context.ts:346
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:350
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.
Inherited from ​
Methods ​
applyClip() ​
applyClip(
path,fillRule?):void
Defined in: svg/src/context.ts:700
Clips subsequent drawing operations to the given path by opening a <g clip-path> scope and nesting them inside it, so the clip is expressed in the user space it was authored in rather than the referencing leaf's (which every intervening <g transform> would displace). Nesting the scopes is also what makes a second clip intersect the first, as ctx.clip() does, instead of replacing it. The scope closes with the enclosing restore() or popGroup(), and the backing <clipPath> def is swept once no render pass uses it.
Parameters ​
| Parameter | Type |
|---|---|
path | SVGPath |
fillRule? | FillRule |
Returns ​
void
Overrides ​
applyFill() ​
applyFill(
element,fillRule?):void
Defined in: svg/src/context.ts:739
Fills the given element using the current fill style, resolving linear and radial gradients into <defs>. Conic gradients have no SVG equivalent and degrade to a solid fill using the color stop nearest the middle of the gradient.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
element | SVGContextElement | The element to stamp the resolved fill onto. |
fillRule? | FillRule | Winding rule the fill is evaluated with; emitted as fill-rule. |
Returns ​
void
Overrides ​
applyGroupPaint() ​
protectedapplyGroupPaint(group):void
Defined in: core/src/context/context.ts:603
Applies a group's own inherited paint (fill, stroke, opacity, font, line, shadow, text) to the context so descendants pick it up from the copied state. Transforms are applied separately, so they are skipped here.
Two boundary semantics are fixed here and every backend must honour them:
- Opacity composites multiplicatively. CONTEXT_OPERATIONS multiplies rather than assigns, so nested groups compound and a leaf's own alpha stacks under its ancestors' instead of replacing it.
- A group's gradient or pattern resolves against the group's own box. The group is the Context.currentRenderElement for the duration of the boundary, so a paint that bakes geometry at set time (canvas) and one that resolves it per leaf (SVG) agree on the same reference box:
group.getBoundingBox(true), never a sibling's and never the surface.
Parameters ​
| Parameter | Type |
|---|---|
group | Element |
Returns ​
void
Inherited from ​
applyStroke() ​
applyStroke(
element):void
Defined in: svg/src/context.ts:751
Strokes the given element using the current stroke style and line properties, resolving linear and radial gradients into <defs>. Conic gradients have no SVG equivalent and degrade to a solid stroke using the color stop nearest the middle of the gradient.
Parameters ​
| Parameter | Type |
|---|---|
element | SVGContextElement |
Returns ​
void
Overrides ​
batch() ​
batch<
TResult>(body):TResult
Defined in: core/src/context/context.ts:534
Clears the rendering surface and brackets the callback in markRenderStart/markRenderEnd, returning the callback's result. On exit the state stack is unwound to the depth captured on entry, giving the scene root the same guarantee Context.popGroup gives a group: a root-level clip: true shape deliberately skips its own restore() so the clip persists to later siblings, and with no enclosing group to absorb it that save would otherwise leak one state per frame, unbounded.
The surface is only cleared at render depth 0: a pass entered while an outer one is open continues it (matching Context.markRenderStart) rather than wiping what it drew.
Type Parameters ​
| Type Parameter | Default type |
|---|---|
TResult | void |
Parameters ​
| Parameter | Type |
|---|---|
body | () => TResult |
Returns ​
TResult
Inherited from ​
clear() ​
clear():
void
Defined in: core/src/context/context.ts:483
Clears the entire rendering surface.
Returns ​
void
Inherited from ​
createPath() ​
createPath(
id?):SVGPath
Defined in: svg/src/context.ts:499
Creates a new SVGPath and adds it to the virtual DOM tree.
Parameters ​
| Parameter | Type |
|---|---|
id? | string |
Returns ​
Overrides ​
createText() ​
createText(
options):ContextText
Defined in: svg/src/context.ts:507
Creates a new SVGText element from the given options, wiring up text-on-a-path when path data is supplied.
Parameters ​
| Parameter | Type |
|---|---|
options | TextOptions |
Returns ​
Overrides ​
destroy() ​
destroy():
void
Defined in: svg/src/context.ts:795
Destroys the context, releasing the reconciler's node cache, every <defs> cache, and the virtual tree it retained.
Returns ​
void
Overrides ​
disableInteraction() ​
disableInteraction():
void
Defined in: dom/src/context.ts:388
Disables DOM interaction events, unwinding any hover with a final mouseleave per element.
Returns ​
void
Inherited from ​
dispose() ​
protecteddispose(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 ​
| Parameter | Type |
|---|---|
key? | PropertyKey |
Returns ​
void
Inherited from ​
drawImage() ​
drawImage(
image,x,y,width?,height?):void
Defined in: svg/src/context.ts:549
Draws an image onto the SVG surface at the given position and optional size.
Parameters ​
| Parameter | Type |
|---|---|
image | CanvasImageSource |
x | number |
y | number |
width? | number |
height? | number |
Returns ​
void
Overrides ​
emit() ​
Call Signature ​
emit<
TEvent>(event):TEvent
Defined in: core/src/core/event-bus.ts:185
Emits an event, invoking all matching handlers and bubbling to the parent if applicable. Handlers for the event's own type run first, then EVENT_WILDCARD subscriptions.
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: core/src/core/event-bus.ts:186
Emits an event, invoking all matching handlers and bubbling to the parent if applicable. Handlers for the event's own type run first, then EVENT_WILDCARD subscriptions.
Type Parameters ​
| Type Parameter |
|---|
TEvent extends keyof ContextEventMap |
Parameters ​
| Parameter | Type |
|---|---|
type | TEvent |
data | ContextEventMap[TEvent] |
Returns ​
Event<ContextEventMap[TEvent]>
Inherited from ​
enableInteraction() ​
enableInteraction():
void
Defined in: dom/src/context.ts:344
Enables DOM interaction events (mouse enter, leave, move, down, up, click, drag) with element hit testing.
Returns ​
void
Inherited from ​
export() ​
export():
ContextExport
Defined in: svg/src/context.ts:473
Captures a snapshot of the SVG surface and returns format-specific exporters (see ContextExport). Every object URL handed out by toURL() is tracked and revoked by release().
Returns ​
Overrides ​
getDefaultState() ​
protectedgetDefaultState():BaseState
Defined in: core/src/context/context.ts:446
Returns ​
Inherited from ​
has() ​
has(
type):boolean
Defined in: core/src/core/event-bus.ts:123
Returns whether there are any listeners registered for the given event type. Wildcard subscriptions (EVENT_WILDCARD) are not listeners for any concrete type, so a bus observed only through the wildcard still reports false here.
Parameters ​
| Parameter | Type |
|---|---|
type | keyof ContextEventMap |
Returns ​
boolean
Inherited from ​
hitTest() ​
protectedhitTest(events,x,y):RenderElement[]
Defined in: core/src/context/context.ts:808
Tests which rendered elements intersect the given point for the given event types, returning them topmost-first — the exact reverse of the order they were painted in.
The point is in logical space — the space pointer event payloads report — so a handler passes the coordinates it was given straight through.
Paint order is the sole key. Context.renderedElements already records the resolved stacking order (groups paint as contiguous stacking contexts), whereas RenderElement.zIndex is additive across the parent chain and so says nothing about two descendants of different groups; sorting by it discarded correct information.
Parameters ​
| Parameter | Type |
|---|---|
events | string[] |
x | number |
y | number |
Returns ​
Inherited from ​
init() ​
protectedinit():void
Defined in: dom/src/context.ts:85
Returns ​
void
Inherited from ​
invalidateTrackedElements() ​
invalidateTrackedElements(
event?):void
Defined in: core/src/context/context.ts:496
Clears the cached list of tracked elements for interaction, forcing a rebuild on the next hit test.
Parameters ​
| Parameter | Type |
|---|---|
event? | string |
Returns ​
void
Inherited from ​
DOMContext.invalidateTrackedElements
isPointInPath() ​
isPointInPath(
path,x,y,fillRule?):boolean
Defined in: svg/src/context.ts:774
Tests whether a point lies inside the filled region of a path.
Parameters ​
| Parameter | Type |
|---|---|
path | SVGPath |
x | number |
y | number |
fillRule? | FillRule |
Returns ​
boolean
Overrides ​
isPointInStroke() ​
isPointInStroke(
path,x,y):boolean
Defined in: svg/src/context.ts:779
Tests whether a point lies on the stroked outline of a path.
Parameters ​
| Parameter | Type |
|---|---|
path | SVGPath |
x | number |
y | number |
Returns ​
boolean
Overrides ​
layer() ​
layer<
TResult>(body):TResult
Defined in: core/src/context/context.ts:472
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
Inherited from ​
markRenderEnd() ​
markRenderEnd():
void
Defined in: svg/src/context.ts:458
Signals the end of a render pass, reconciling the virtual DOM tree to the SVG surface and then sweeping the <defs> entries the pass left unused, at the outermost depth.
Returns ​
void
Overrides ​
markRenderStart() ​
markRenderStart():
void
Defined in: svg/src/context.ts:442
Signals the start of a render pass; resets the virtual DOM tree, group-nesting pointer, and <defs> usage tracking at the outermost depth.
Returns ​
void
Overrides ​
measureText() ​
measureText(
text,font?):TextMetrics
Defined in: svg/src/context.ts:764
Measures text dimensions using the context's current font, alignment, and baseline, or an optional font override.
Parameters ​
| Parameter | Type |
|---|---|
text | string |
font? | string |
Returns ​
TextMetrics
Overrides ​
off() ​
off<
TEvent>(type,handler):void
Defined in: core/src/core/event-bus.ts:144
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: core/src/core/event-bus.ts:131
Subscribes a handler to the given event type and returns a disposable for cleanup. Pass EVENT_WILDCARD to receive every event emitted on the bus regardless of type.
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: core/src/core/event-bus.ts:159
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: svg/src/context.ts:641
Closes the most recently opened group boundary, restoring state and ascending the <g> pointer.
Returns ​
void
Overrides ​
pushGroup() ​
pushGroup(
group):void
Defined in: svg/src/context.ts:596
Opens a group boundary as a nested <g> element: descends the reconciliation pointer into a <g> keyed by the group's id and stamps the group's own transform onto it, so descendants nest under the <g> and inherit the group transform via SVG's native cascade. Resets the accumulated transform afterwards so leaves carry only their own transform (avoiding a double application of the group transform).
A gradient or pattern the group carries is resolved once here, against the group's own box, and stamped on the <g>; descendants inherit the resolved url(#…) rather than re-resolving the paint against their own box, which is what makes the group ramp continuously across its children and match what the canvas backend paints.
Parameters ​
| Parameter | Type |
|---|---|
group | Element |
Returns ​
void
Overrides ​
requestRender() ​
requestRender():
void
Defined in: core/src/context/context.ts:505
Requests that the bound scene repaint on the next frame, for context-level changes (e.g. a 3D camera move) that mutate no element and so would otherwise be skipped by the renderer's dirty check.
Returns ​
void
Inherited from ​
rescale() ​
protectedrescale(width,height):void
Defined in: svg/src/context.ts:309
Parameters ​
| Parameter | Type |
|---|---|
width | number |
height | number |
Returns ​
void
Overrides ​
reset() ​
reset():
void
Defined in: svg/src/context.ts:784
Resets the context to its initial state, dropping the accumulated transform, the open clip scopes, and the group nesting alongside the base drawing state.
Returns ​
void
Overrides ​
restore() ​
restore():
void
Defined in: svg/src/context.ts:654
Restores the most recently saved drawing state, transform, and clip scope from their stacks.
Returns ​
void
Overrides ​
retain() ​
protectedretain(value,key?):void
Defined in: 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: svg/src/context.ts:666
Applies a rotation transformation, in radians.
Parameters ​
| Parameter | Type |
|---|---|
angle | number |
Returns ​
void
Overrides ​
save() ​
save():
void
Defined in: svg/src/context.ts:647
Saves the current drawing state, transform, and clip scope onto their stacks.
Returns ​
void
Overrides ​
scale() ​
scale(
x,y):void
Defined in: svg/src/context.ts:671
Applies a scale transformation.
Parameters ​
| Parameter | Type |
|---|---|
x | number |
y | number |
Returns ​
void
Overrides ​
setTransform() ​
setTransform(
a,b,c,d,e,f):void
Defined in: svg/src/context.ts:682
Replaces the current transformation with the given matrix values.
Parameters ​
| Parameter | Type |
|---|---|
a | number |
b | number |
c | number |
d | number |
e | number |
f | number |
Returns ​
void
Overrides ​
toLogicalPoint() ​
toLogicalPoint(
x,y): [number,number]
Defined in: core/src/context/context.ts:697
Maps a point from surface space — this backend's own drawing coordinates, as produced by Context.scaleX and Context.scaleY — into the logical space elements are authored in and every public coordinate is expressed in.
Backends disagree on what surface space is: canvas maps logical coordinates onto device pixels while SVG leaves them identity, so a backend has to invert what this context actually does rather than assume the device pixel ratio.
This is a seam for backend implementors, not for consumers — nothing crossing the public API is in surface space, so a caller holding a pointer coordinate already has a logical one.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
x | number | X coordinate in surface space. |
y | number | Y coordinate in surface space. |
Returns ​
[number, number]
The [x, y] pair in logical space.
Inherited from ​
toSurfacePoint() ​
toSurfacePoint(
x,y): [number,number]
Defined in: core/src/context/context.ts:710
Maps a point from the logical space elements are authored in into this backend's own drawing coordinates. The inverse of Context.toLogicalPoint, and likewise a seam for backend implementors rather than consumers.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
x | number | X coordinate in logical space. |
y | number | Y coordinate in logical space. |
Returns ​
[number, number]
The [x, y] pair in surface space.
Inherited from ​
transform() ​
transform(
a,b,c,d,e,f):void
Defined in: svg/src/context.ts:688
Multiplies the current transformation by the given matrix values.
Parameters ​
| Parameter | Type |
|---|---|
a | number |
b | number |
c | number |
d | number |
e | number |
f | number |
Returns ​
void
Overrides ​
translate() ​
translate(
x,y):void
Defined in: svg/src/context.ts:676
Applies a translation transformation.
Parameters ​
| Parameter | Type |
|---|---|
x | number |
y | number |
Returns ​
void