RectNode.fromTopLeftWorld constructor
- required NodeId id,
- required Size size,
- required Offset topLeftWorld,
- Color? fillColor,
- Color? strokeColor,
- double strokeWidth = 1,
- double hitPadding = 0,
- double opacity = 1,
- bool isVisible = true,
- bool isSelectable = true,
- bool isLocked = false,
- bool isDeletable = true,
- bool isTransformable = true,
Creates a rect node positioned by its axis-aligned world top-left corner.
This helper is AABB-based: rotation/shear affects boundsWorld, so
topLeftWorld is intended for UI-like positioning (selection box).
Implementation
factory RectNode.fromTopLeftWorld({
required NodeId id,
required Size size,
required Offset topLeftWorld,
Color? fillColor,
Color? strokeColor,
double strokeWidth = 1,
double hitPadding = 0,
double opacity = 1,
bool isVisible = true,
bool isSelectable = true,
bool isLocked = false,
bool isDeletable = true,
bool isTransformable = true,
}) {
final centerWorld = topLeftWorld + Offset(size.width / 2, size.height / 2);
return RectNode(
id: id,
size: size,
fillColor: fillColor,
strokeColor: strokeColor,
strokeWidth: strokeWidth,
hitPadding: hitPadding,
transform: Transform2D.translation(centerWorld),
opacity: opacity,
isVisible: isVisible,
isSelectable: isSelectable,
isLocked: isLocked,
isDeletable: isDeletable,
isTransformable: isTransformable,
);
}