Anchor.fromPos constructor
Implementation
factory Anchor.fromPos(AnchorPos pos, double width, double height) {
if (pos.anchor case final Anchor anchor?) return anchor;
if (pos.alignment case final AnchorAlign alignment?) {
return Anchor(
switch (alignment._x) {
-1 => 0,
1 => width,
_ => width / 2,
},
switch (alignment._y) {
1 => 0,
-1 => height,
_ => height / 2,
},
);
}
throw Exception();
}