canvas_core_runtime library

Classes

CanvasAppearance
Appearance shared by text and icon sources.
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:
CanvasSourceUnderlay
Ordered paint that derives independently from the original source silhouette and is painted before the authored foreground.
CanvasUrlAssetRef
Network URL reference.
CanvasViewportPlanner
CanvasViewportTransform
CircleSource
ComputedScene
Computed document/render geometry in document units; these maps are not serialized.
ContentBoundsPolicy
Generic runtime policy for content-bounds calculations.
ContentBoundsSpec
Runtime-owned spec for custom content-bounds computation.
CoreServices
DrawImageOp
DrawItem
DrawPathUnderlaysOp
Ordered source-derived underlays for one resolved path-icon silhouette.
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

Constants

currentCanvasSceneFormatVersion → const int
Current persisted Canvas scene format; independent of package version.
shadowBlurExtentInSigmas → const double
Practical Gaussian-tail estimate, not a hard pixel-enclosure guarantee. Raster padding remains a separate export policy.

Functions

aabbOfTransformedRect(Rect2D r, Matrix4 m) → Rect2D
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 current, versioned persisted scene JSON.
encodeCanvasScene(CanvasSceneDocument scene) → Map<String, Object?>
Encodes a runtime scene as current, versioned persisted JSON.
estimateAppearancePaintBounds({required Rect2D? sourceBounds, required bool foregroundPresent, required Iterable<CanvasSourceUnderlay> underlays}) → Rect2D?
Estimates visible paint for a text/icon appearance.
estimateSourceUnderlayPaintBounds(Rect2D sourceBounds, CanvasSourceUnderlay underlay) → Rect2D?
Returns the paint estimate produced by one underlay from the ORIGINAL source bounds.
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.
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.
shadowContributesToPaint(ShadowEffect shadow) → bool
Invalid numeric/color values are skipped defensively by bounds/rendering. The document validator still reports invalid authored data, including for disabled effects.
sourceUnderlayContributesToPaint(CanvasSourceUnderlay underlay) → bool
upgradeCanvasScene(Map<String, Object?> json, {bool legacyUnversioned = false, bool? resolveLegacyIconWasGlyph(String iconRef)?}) → Map<String, Object?>
Brings persisted scene JSON to the current Canvas scene format.
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.