advanced library

Advanced public API exports for iwb_canvas_engine.

This entrypoint exposes the full API surface, including low-level building blocks (custom painting, hit-testing, pointer tracking).

Prefer package:iwb_canvas_engine/basic.dart unless you need low-level APIs.

Classes

ActionCommitted
A committed action with stable actionId and affected nodeIds.
Background
Background visual settings: solid color and optional grid.
Camera
Viewport state for converting between view and scene coordinates.
EditTextRequested
Request from the engine to edit a TextNode at position.
GridSettings
Grid rendering configuration.
ImageNode
Raster image node referenced by imageId and drawn at size.
Layer
A z-ordered collection of nodes.
LineNode
Straight segment node defined by start and end points.
PathNode
SVG-path based vector node.
PointerInputSettings
Thresholds and timings used by PointerInputTracker.
PointerInputTracker
Converts PointerSample input into a stream of PointerSignals.
PointerSample
A single pointer sample in view/screen coordinates.
PointerSignal
A derived pointer signal (including tap and double tap).
RectNode
Box node with optional fill and stroke.
Scene
A mutable scene graph used by the canvas engine.
SceneController
Mutable controller that owns the scene editing state and tool logic.
SceneDefaults
Default values used by the engine for palettes and tool settings.
SceneNode
Base class for all nodes stored in a Scene.
ScenePainter
A CustomPainter that renders a Scene to a Flutter Canvas.
ScenePalette
Palette presets for tool colors and background/grid options.
SceneStaticLayerCache
Cache for the static scene layer (background + grid).
SceneStrokePathCache
LRU cache for built Path instances for StrokeNode geometry.
SceneTextLayoutCache
LRU cache for TextPainter layout results for TextNode.
SceneView
A self-contained widget that renders a SceneController and feeds it input.
StrokeNode
Freehand polyline stroke node.
TextNode
Text node with a fixed layout box (size) and basic styling.
Transform2D
A 2D affine transform represented as a 2×3 matrix.

Enums

ActionType
Discrete actions emitted by SceneController for app-level undo/redo.
CanvasMode
Public input types for the canvas controller.
DrawTool
Active drawing tool when CanvasMode.draw is enabled.
NodeType
Supported node variants in a Scene.
PathFillRule
Fill rule for PathNode geometry.
PointerPhase
Low-level pointer lifecycle phases.
PointerSignalType
High-level signals derived from PointerSample input.

Extensions

ActionCommittedDelta on ActionCommitted

Constants

kHitSlop → const double
Extra hit-test tolerance applied by this package, in scene units.
schemaVersionsRead → const Set<int>
JSON schema versions accepted by this package.
schemaVersionWrite → const int
JSON schema version written by this package.

Functions

aabbForTransformedRect({required Rect localRect, required Offset position, required double rotationDeg, required double scaleX, required double scaleY}) Rect
Computes an axis-aligned bounding box for a transformed rectangle.
aabbFromPoints(Iterable<Offset> points) Rect
Returns the axis-aligned bounding box for points.
decodeScene(Map<String, dynamic> json) Scene
Decodes a Scene from a JSON map (already parsed).
decodeSceneFromJson(String json) Scene
Decodes a Scene from a JSON string.
distancePointToSegment(Offset point, Offset a, Offset b) double
Returns the shortest distance from point to the segment a-b.
distanceSegmentToSegment(Offset a1, Offset a2, Offset b1, Offset b2) double
Returns the shortest distance between two line segments.
encodeScene(Scene scene) Map<String, dynamic>
Encodes scene into a JSON-serializable map.
encodeSceneToJson(Scene scene) String
Encodes scene to a JSON string.
hitTestLine(Offset point, Offset start, Offset end, double thickness) bool
Returns true if point is within thickness of the segment start-end.
hitTestNode(Offset point, SceneNode node) bool
Returns true if point hits node in scene coordinates.
hitTestRect(Offset point, Rect rect) bool
Returns true if point lies inside rect.
hitTestStroke(Offset point, List<Offset> points, double thickness, {double hitPadding = 0, double hitSlop = kHitSlop}) bool
Returns true if point hits the polyline points with thickness.
hitTestTopNode(Scene scene, Offset point) SceneNode?
Returns the top-most node hit by point, or null.
reflectPointHorizontal(Offset point, double axisY) Offset
Mirrors point across the horizontal axis that passes through axisY.
reflectPointVertical(Offset point, double axisX) Offset
Mirrors point across the vertical axis that passes through axisX.
rotatePoint(Offset point, Offset center, double degrees) Offset
Rotates point around center by degrees.
segmentsIntersect(Offset a1, Offset a2, Offset b1, Offset b2) bool
Returns true if segments a1-a2 and b1-b2 intersect.
toScene(Offset viewPoint, Offset cameraOffset) Offset
Converts a point from view/screen coordinates to scene coordinates.
toView(Offset scenePoint, Offset cameraOffset) Offset
Converts a point from scene coordinates to view/screen coordinates.

Typedefs

ImageResolver = Image? Function(String imageId)
Resolves an ImageNode.imageId to a decoded Image instance.
NodeId = String
Stable node identifier used for selection and action events.
SceneViewPointerSampleCallback = void Function(SceneController controller, PointerSample sample)
Callback invoked by SceneView for each pointer sample it processes.

Exceptions / Errors

SceneJsonFormatException
Thrown when scene JSON fails schema validation.