Classes
Import these from @grafloria/renderer.
Classes
CanvasStyleResolver
Resolves VNode props → concrete paint values, reproducing the SVG cascade. The CLASS-RULE layer is the export card's flattener; this adds priority order, inheritance and typed parsing on top.
tsclass CanvasStyleResolver
Properties
| Name | Type | Default | Description |
|---|---|---|---|
warnings | string[] | [] | Declarations dropped because a variable could not be resolved. |
Methods
constructor(options: StyleResolverOptions)setTheme(theme: Theme, varOverrides?: Record<string, string>): voidgetTheme(): ThemerootStyle(): ComputedStyle— The root style every diagram starts from (theme font, no paint inherited).resolve(props: VNodeProps | undefined, inherited: ComputedStyle): ComputedStyle— Compute an element's style: inherit from the parent, then apply presentation attributes < matched class rules < inline style.
DirtyRegionTracker
tsclass DirtyRegionTracker
Methods
invalidateAll(): void— Next frame repaints everything (camera moved, theme swapped, resized …).reset(): void— Forget everything (a new diagram, or a disposed renderer).diff(current: Map<string, VNode>, measure: (vnode: VNode) => Bounds | null): DirtyDiff— Diff this frame's entities against the last one.getBounds(key: string): Bounds | null | undefined— Bounds recorded for an entity on the last frame (testing / diagnostics).get size(): number
VNodePainter
Paints VNode trees. Stateless between frames apart from the colour-key allocator the caller injects.
tsclass VNodePainter
Methods
constructor(private readonly resolver: CanvasStyleResolver)paint(ctx: Canvas2DLike, root: VNode, options: PaintOptions): PaintResultmeasure(vnode: VNode, worldToDevice: Matrix = IDENTITY): Bounds | null— World bounds of a subtree, drawing nothing. Used by the dirty tracker to measure the entities that actually changed (and only those).
Was this page helpful?