Visualize Your Ideas With Code
feat(2d): universal getter for cardinal points (#988)
Jacobf7e53ecbb3ac
diff --git a/packages/2d/src/lib/components/Layout.ts b/packages/2d/src/lib/components/Layout.tsindex 7677f4c8..e1d683f2 100644--- a/packages/2d/src/lib/components/Layout.ts+++ b/packages/2d/src/lib/components/Layout.ts@@ -1,6 +1,7 @@import {BBox,boolLerp,+ Direction,InterpolationFunction,modify,Origin,@@ -627,6 +628,38 @@ export class Layout extends Node {@originSignal(Origin.BottomRight)public declare readonly bottomRight: SimpleVector2Signal<this>;+ /**+ * Get the cardinal point corresponding to the given origin.+ *+ * @param origin - The origin or direction of the point.+ */+ public cardinalPoint(origin: Origin | Direction): SimpleVector2Signal<this> {+ switch (origin) {+ case Origin.TopLeft:+ return this.topLeft;+ case Origin.TopRight:+ return this.topRight;+ case Origin.BottomLeft:+ return this.bottomLeft;+ case Origin.BottomRight:+ return this.bottomRight;+ case Origin.Top:+ case Direction.Top:+ return this.top;+ case Origin.Bottom:+ case Direction.Bottom:+ return this.bottom;+ case Origin.Left:+ case Direction.Left:+ return this.left;+ case Origin.Right:+ case Direction.Right:+ return this.right;+ default:+ return this.middle;+ }+ }+@initial(false)@signal()public declare readonly clip: SimpleSignal<boolean, this>;