canvas_core_runtime
library
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.