Anchor¶
Package name: jitx/anchor
Rectangle Anchor Example¶
val r = Rectangle(SW, -3.0, 5.0)
- The anchor
SWspecifies that the bottom left corner of the rectangle will be at the origin.
TODO - Add Example Image Here
Summary¶
Anchor¶
Enum Definition for the Anchor type
Functions¶
| Function | Description |
|---|---|
| vertical-flip | Flip an anchor vertically across the horizontal axis |
| horizontal | Retrieve the horizontal component of an anchor |
| vertical | Retrieve the vertical component of an anchor |
| components | Split an anchor into its constituent vertical and horizontal components |
| horizontal-flip | Flip an anchor horizontally across the vertical axis |
| join | Combine a vertical anchor and a horizontal anchor into one combined anchor |
| flip | Flip an anchor about the vertical & horizontal axis. |
Definitions¶
Anchor¶
Enum Definition for the Anchor type
public defenum Anchor <: Equalable & Hashable
-
N -
S -
E -
W -
NE -
SE -
SW -
NW -
C
This definition defines 9 unique values including:
- The cardinal directions
- The centered marker
Functions¶
vertical-flip¶
Flip an anchor vertically across the horizontal axis
public defn vertical-flip (a:Anchor) -> Anchor
a: Anchor- The anchor to flip- Returns
Anchor- The transformed anchor - All values are possible depending on the input anchora
The horizontal alignment for this anchor a will be preserved
and only the vertical component will be transformed.
horizontal¶
Retrieve the horizontal component of an anchor
public defn horizontal (a:Anchor) -> Anchor
a: Anchor- The Anchor to Split- Returns
Anchor- The horizontal component of that anchor with possible values selected fromC,E, orW.
This function is a utility for spliting the anchor into its constituent parts. This is often useful when attempting to construct a Pose that will shift the associated shape or object into the right alignment position.
References¶
vertical¶
Retrieve the vertical component of an anchor
public defn vertical (a:Anchor) -> Anchor
a: Anchor- The Anchor to Split- Returns
Anchor- The vertical component of that anchor with possible values selected fromC,N, orS.
This function is a utility for spliting the anchor into its constituent parts. This is often useful when attempting to construct a Pose that will shift the associated shape or object into the right alignment position.
References¶
components¶
Split an anchor into its constituent vertical and horizontal components
public defn components (a:Anchor) -> [Anchor, Anchor]
a: Anchor- The anchor to split- Returns
[Anchor, Anchor]- Tuple of the two components in the order[Vertical, Horizontal]
This is combination of the vertical and horizontal functions and is a useful shortcut.
Example¶
val a = NW
val [vert, horz] = components(a)
println("V: %_ H: %_" % [vert, horz])
; Should print:
; V: N H: W
horizontal-flip¶
Flip an anchor horizontally across the vertical axis
public defn horizontal-flip (a:Anchor) -> Anchor
a: Anchor- The anchor to flip- Returns
Anchor- The transformed anchor - All values are possible depending on the input anchora
The vertical alignment for this anchor a will be preserved
and only the horizontal component will be transformed.
For example, horizontal-flip(NW) will return NE
join¶
Combine a vertical anchor and a horizontal anchor into one combined anchor
public defn join (v:Anchor, h:Anchor)
v: Anchor- The vertical anchor to combine. Must beN,S, orCh: Anchor- The horizontal anchor to combine. Must beE,W, orC- Throws
Fatal- ifvis not a valid vertical anchor orhis not a valid horizontal anchor
For example, join(S, W) will return SW
flip¶
Flip an anchor about the vertical & horizontal axis.
public defn flip (a:Anchor) -> Anchor
a: Anchor- The anchor to flip- Returns
Anchor- The transformed anchor - All values are possible depending on the input anchora
This function transforms an anchor by mirroring it across the vertical or horizontal axis, respectively.
For example, flip(NW) will produce SE.
The C value will be unchanged and return C.
Related Packages¶
Forwarded by package: jitx