Skip to content

Commit 63614f1

Browse files
committed
Add NodeBox.fromCenter method.
1 parent e6acb94 commit 63614f1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/src/api/models/node_box.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,14 @@ class NodeBox with EquatableMixin, DynamicSerializableMixin {
167167
NodeBox.fromRect(RectC rect)
168168
: this(rect.left, rect.top, rect.width, rect.height);
169169

170+
/// Creates a new [NodeBox] from a [SizeC] object.
171+
NodeBox.fromCenter({
172+
required Vec center,
173+
required double width,
174+
required double height,
175+
}) : this(center.x - width / 2, center.y - height / 2, width.toDouble(),
176+
height.toDouble());
177+
170178
/// Creates a new [NodeBox] using the current values of this [NodeBox], and
171179
/// optionally allows different values. The new [NodeBox] immediately
172180
/// pre-computes its values.

0 commit comments

Comments
 (0)