basic library

Basic public API exports for iwb_canvas_engine.

This entrypoint is intended for the common "happy path" integration:

Low-level building blocks (custom painting, hit testing, pointer tracking, etc.) are intentionally omitted. For the full API, import package:iwb_canvas_engine/advanced.dart.

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

Extensions

ActionCommittedDelta on ActionCommitted

Constants

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.
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.
encodeSceneToJson(Scene scene) String
Encodes scene to a JSON string.
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.