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
CanvasRawAssetRef
Bare/raw source reference with no recognized syntax.
CanvasRenderPipeline
Reusable runtime render pipeline.
CanvasSceneDocument
CanvasSchemeAssetRef
Opaque custom-scheme reference, such as:
CanvasUrlAssetRef
Network URL reference.
CanvasViewportPlanner
CanvasViewportPlanResult
Extra sizing info for export tight mode.
CanvasViewportPolicy
Generic runtime viewport policy.
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.
IconTextPayload
ImageData
ImageIntrinsics
ImagePlacement
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
TextMeasureCache
Cache for text measurements within a single layout/build/hit-test pass.
TextMeasurer
Transform2D
UnderlineSource
Vec2
2D point/vector.
Vec2Converter
---- Vec2 ----
Vec2ListNullableConverter
---- Vec2 list (nullable items) ----

Extensions

CanvasRenderPipelineCanonical on CanvasRenderPipeline
Compatibility helper for the generic runtime surface.
CanvasSceneDocumentPatterns on CanvasSceneDocument
Adds pattern-matching-related methods to CanvasSceneDocument.
NodeFields on Node
NodeMutations on Node
Internal helpers to centralize "switch-on-node-type + copyWith(...)" for common mutations.
Rect2DX on Rect2D

Functions

buildPaintOpsFromScene(CanvasSceneDocument doc, ComputedScene computed) List<PaintOp>
collectAllNodeIds({CanvasSceneDocument? doc, Node? root}) Set<NodeId>
Collect all node IDs from a document or a subtree root.
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).
computeViewportWithPadding({required double artboardW, required double artboardH, required double viewportW, required double viewportH, Rect2D? bounds, double paddingPx = 0, CanvasFit fit = CanvasFit.contain, double? minUniformScale, double? maxUniformScale}) CanvasViewportTransform
defaultSceneRenderBuilder(CanvasRenderPipeline pipeline, CanvasSceneDocument scene, {ContentBoundsSpec? contentBounds, TextMeasureCache? textMeasureCache}) RenderSnapshot
Default generic runtime render builder.
findById(CanvasSceneDocument doc, NodeId id) Node?
Find a node anywhere in the tree.
findParentOf(CanvasSceneDocument doc, NodeId 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, NodeId 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.
spacedText(String text, int n) String
Shared helper: inserts n hair spaces between characters. Pure Dart. No Flutter.
visitSceneNodes(CanvasSceneDocument doc, {bool includeHidden = false, required void visit(Node node)}) → void
Pure traversal: iterate all nodes (optionally skipping hidden subtrees).

Typedefs

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).
NodeId = ElementId
SceneRenderBuilder = RenderSnapshot Function(CanvasRenderPipeline pipeline, CanvasSceneDocument scene, {ContentBoundsSpec? contentBounds, TextMeasureCache? textMeasureCache})
Shared render-builder seam used by editors, thumbnails, exporters, and extension packages.