canvas_core_runtime library

Classes

CanvasAssetRef
CanvasBlobUrlAssetRef
Browser blob URL reference.
CanvasDataUriAssetRef
Inline data URI reference.
CanvasFieldKey
Stable identity for a runtime-editable canvas field.
CanvasFieldKeyConverter
Serializes CanvasFieldKey as its stable string value.
CanvasFields
Built-in field keys for properties that exist in the base canvas_core runtime scene model.
CanvasFileAssetRef
Local file reference.
CanvasFill
Single source-of-truth fill for runtime. No backward-compat: only accepts the new {type: ...} JSON shape.
CanvasFillConverter
CanvasFillGradient
CanvasFillNone
CanvasFillSolid
CanvasIconData
CanvasImageAsset
Backing source and optional natural dimensions for a document image.
CanvasImageAssetResolver
Resolves logical canvas image source references for the current host.
CanvasRawAssetRef
Bare/raw source reference with no recognized syntax.
CanvasRenderPipeline
Reusable runtime render pipeline.
CanvasSceneDocument
CanvasSceneValidationIssue
One deterministic validation diagnostic for a CanvasSceneDocument.
CanvasSchemeAssetRef
Opaque custom-scheme reference, such as:
CanvasUrlAssetRef
Network URL reference.
CanvasViewportPlanner
CanvasViewportTransform
CircleSource
ComputedScene
ContentBoundsPolicy
Generic runtime policy for content-bounds calculations.
ContentBoundsSpec
Runtime-owned spec for custom content-bounds computation.
CoreServices
DrawImageOp
DrawItem
DrawTextOp
EllipseSource
FillPathGradientOp
FillPathOp
FillRectGradientOp
FillRectOp
GroupBehaviorRef
Generic runtime-owned behavior envelope for optional group semantics.
IconResolver
Sync resolver: the core pipeline (layout + paint op build) is synchronous. Any async download/fetch happens outside core (app/editor layer), then you provide a resolver that can answer synchronously.
ImageData
ImageIntrinsics
Synchronous intrinsic-image lookup used by core scene computation.
LinearGradientSpec
Linear gradient parameters in core space.
LinearGradientSpecConverter
---- LinearGradientSpec ----
Node
Runtime scene-graph node (hierarchical TRS).
NodeGeometry
NullableSize2DConverter
NullableVec2Converter
PaintOp
PathCmd
PathData
PathIR
Canonical compiled representation used everywhere internally.
PathSource
PathSourceConverter
---- PathSource ---- Use Object? as raw type to avoid brittle generic casts on web.
PathStyle
PillSource
PolylineSource
Rect2D
RectSource
RegularPolygonSource
RenderSnapshot
Runtime render snapshot.
ResolvedIcon
ResolvedIconPath
Vector-backed icon (future-proof). Contract for now: the returned PathData should be normalized to your icon origin convention (ideally centered around (0,0) like Text baseline-center behavior).
ResolvedIconText
Font-backed icon (glyph in a font family).
ResolvedLinearGradient
RestoreOp
RoundRectSource
SaveOp
SceneTreeOps
SetTransformOp
Size2D
2D size (width/height).
Size2DConverter
---- Size2D ----
StarSource
StrokePathOp
SvgPathSource
TextData
TextMeasurer
Synchronous text measurement used by core scene computation.
Transform2D
UnderlineSource
Vec2
2D point/vector.
Vec2Converter
---- Vec2 ----
Vec2ListNullableConverter
---- Vec2 list (nullable items) ----

Enums

CanvasFit
CanvasSceneValidationCode
Stable machine-readable categories returned by scene validation.
FillRule
ImageFit
OriginKind
PathVerb
StrokeCap
StrokeJoin

Extensions

CanvasImageAssetPatterns on CanvasImageAsset
Adds pattern-matching-related methods to CanvasImageAsset.
CanvasSceneDocumentPatterns on CanvasSceneDocument
Adds pattern-matching-related methods to CanvasSceneDocument.
NodeEditingX on Node
Common immutable edits that preserve node identity and tree structure.
NodeFields on Node
Rect2DX on Rect2D

Functions

buildPaintOpsFromScene(CanvasSceneDocument doc, ComputedScene computed) List<PaintOp>
collectAllNodeIds({CanvasSceneDocument? doc, Node? root}) Set<ElementId>
Collect all node IDs from a document or a subtree root.
collectSceneFontFamilies(CanvasSceneDocument scene, {Iterable<String> fallbackFontFamilies = const <String>[], IconResolver? icons}) Set<String>
Collects logical font-family dependencies referenced by a scene.
computePaddedContentBounds({required CanvasSceneDocument scene, required ComputedScene computed, ContentBoundsPolicy policy = const ContentBoundsPolicy(), double paddingPx = 0}) Rect2D?
computeScene(CanvasSceneDocument doc, CoreServices services) ComputedScene
computeViewport({required double artboardW, required double artboardH, required double targetW, required double targetH, Rect2D? bounds, double bleed = 0, CanvasFit fit = CanvasFit.contain, double? minUniformScale, double? maxUniformScale}) CanvasViewportTransform
Fits either the artboard (bounds=null) or a world-space bounds rect into a target, with optional "bleed" (outer margin).
decodeCanvasScene(Map<String, Object?> json) CanvasSceneDocument
Decodes persisted or externally supplied scene JSON.
encodeCanvasScene(CanvasSceneDocument scene) Map<String, Object?>
Encodes a scene for persistence or external interchange.
findById(CanvasSceneDocument doc, ElementId id) Node?
Find a node anywhere in the tree.
findParentOf(CanvasSceneDocument doc, ElementId id) → ParentRef?
Find parent + child-index of node id. If the node is a root child, returns (parent: null, index: i).
nodesInFrontToBackOrder(List<Node> children) List<Node>
Layer panels typically show frontmost first.
nodesInPaintOrder(List<Node> children) List<Node>
Sibling order is paint order:
parseCanvasAssetRef(String input) CanvasAssetRef
replaceById(CanvasSceneDocument doc, ElementId id, Node updated) CanvasSceneDocument
Replace node id with updated anywhere in the tree. If id does not exist, returns doc unchanged.
resolveLinearGradient(LinearGradientSpec spec, Size2D size, {double opacity = 1.0}) ResolvedLinearGradient
Resolve editor semantics into renderer-agnostic data:
rewritePostOrder(Node n, Node fn(Node), {bool skip(Node)?, bool prune(Node)?}) Node
Post-order tree rewrite:
rewriteSceneDocument(CanvasSceneDocument doc, Node rewriteRoot(Node)) CanvasSceneDocument
Rewrite every root subtree in a scene document and preserve identity when no root changed.
selectionGeometry(Iterable<ElementId> ids, {required Rect2D? getBounds(ElementId id)}) → MultiSelectGeometry?
Convenience wrapper that builds MultiSelectGeometry from element bounds.
selectionUnionBounds(Iterable<ElementId> ids, {required Rect2D? getBounds(ElementId id)}) Rect2D?
Axis-aligned union of the provided ids' bounds.
validateCanvasSceneDocument(CanvasSceneDocument document) List<CanvasSceneValidationIssue>
Validate generic runtime-scene integrity without interpreting component semantics.
visitSceneNodes(CanvasSceneDocument doc, {bool includeHidden = false, required void visit(Node node)}) → void
Pure traversal: iterate all nodes (optionally skipping hidden subtrees).

Typedefs

CanvasAssetId = String
Document-local identifier for an entry in a scene's asset registry.
Color32 = int
32-bit ARGB color. Same layout as Flutter's Color under the hood: 0xAARRGGBB (e.g., 0xFF112233).
ContentBoundsElementSelector = ElementId? Function(CanvasSceneDocument scene)
ContentBoundsFallbackSelector = Iterable<ElementId> Function(CanvasSceneDocument scene)
ElementId = String
FontWeightNum = int
Numeric font weight (100, 200, …, 900). Common values: 400 (normal), 700 (bold).
ImagePlacement = ({Rect2D dst, Rect2D src})
ScenePreparer = CanvasSceneDocument Function(CanvasSceneDocument scene, CoreServices services)
Pure, synchronous transformation from one runtime scene to another.