Anchor
Functions to aid in anchor creation when defining custom elements.
border
border() -> vector or none
Calculates a border anchor at the given angle by testing for an intersection between a line and the given drawables. Returns none
if no intersection is found for better error reporting.
Drawables to test for an intersection against. Ideally should be of type path but all others are ignored.
setup
setup(callback: functionauto,anchor-names: array,default: strnone,transform: matrixnone,name: strnone,offset-anchor: strnone,border-anchors: bool,path-anchors: bool,radii: nonearray,path: nonedrawable,nested-anchors: ,) -> array
Setup an anchor calculation and handling function for an element. Unifies anchor error checking and calculation of the offset transform.
A tuple of a transformation matrix and function will be returned.
The transform is calculated by translating the given transform by the distance between the position of offset-anchor
and default
. It can then be used to correctly transform an element's drawables. If either are none the calculation won't happen but the transform will still be returned.
The function can be used to get the transformed anchors of an element by passing it a string. An empty array can be passed to get the list of valid anchors.
The function to call to get a named anchor's position. The anchor's name will be passed and it should return a vector (str => vector
). If no named anchors exist on the element auto
can be given instead of a function.
A list of valid anchor names. This list will be used to validate an anchor exists before callback
is used.
The current transformation matrix to apply to an anchor's position before returning it. If offset-anchor
and default
is set, it will be first translated by the distance between them.
The name of the element, this is only used in the error message in the event an anchor is invalid.