Skip to content

Commit 3fbb751

Browse files
committed
Miscellaneous updates
- Add & operator for Vec. - Add aspectRatio getter for ComponentData.
1 parent 117902e commit 3fbb751

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

lib/src/api/custom_component.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ class ComponentData with EquatableMixin, SerializableMixin {
104104
/// Returns containing rect of the component.
105105
RectC get rect => RectC.fromLTWH(0, 0, width, height);
106106

107+
/// Returns aspect ratio of the component.
108+
double get aspectRatio => width / height;
109+
107110
/// Default constructor to create new instances.
108111
ComponentData({
109112
required this.width,

lib/src/api/models/vec.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import 'package:equatable/equatable.dart';
77
import 'package:json_annotation/json_annotation.dart';
88

99
import '../mixins.dart';
10+
import 'rect.dart';
1011
import 'size.dart';
1112

1213
part 'vec.g.dart';
@@ -106,6 +107,9 @@ class Vec with SerializableMixin, EquatableMixin {
106107
double distanceToSq(Vec other) =>
107108
pow(x - other.x, 2) + pow(y - other.y, 2).toDouble();
108109

110+
RectC operator &(SizeC size) =>
111+
RectC.fromLTRB(x, y, x + size.width, y + size.height);
112+
109113
/// The length is the distance from the origin to this [Vec].
110114
///
111115
/// It is equivalent to [distanceTo] but as if you had passed [Vec.zero] as

lib/src/api/nodes/frame_node.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class FrameNode extends DefaultShapeNode
5454
super.edgePins,
5555
super.aspectRatioLock,
5656
super.positioningMode,
57+
super.parentID,
5758
// [ClipMixin] properties.
5859
bool clipsContent = true,
5960
// [ScrollableMixin] properties.

0 commit comments

Comments
 (0)