Utilities
Functions
value(number | Vec)The value to convert, number or Vec.
sourceUnit("in" | "ft" | "mm" | "cm" | "m" | "px" | "pc" | "pt")The unit of the value.
targetUnit("in" | "ft" | "mm" | "cm" | "m" | "px" | "pc" | "pt")The unit to convert to.
Returns an SVGRenderer for an external SVG, or undefined while the SVG is
loading. The renderer uses the current project's units.
ref(string | SVG)Converts any number, array or object to a string.
Numbers with very long fractional parts that are very close to a shorter number will be rounded.
For example: toString(0.9999999999999) = "1"
valueunknownAny number or object to convert
startnumberThe first number in the array
stopnumberThe number to stop at. Note that this number will not be included in the array.
stepnumber1The increment. Keep this as 1 for integer ranges.
Returns An array of numbers from start to stop, in increments of step.
The array is not inclusive of end.
Pairs-up elements in an array.
let a = [1, 2, 3];
pairs(a); // [[1, 2], [2, 3]]
If loop is set true the array of pairs will include a pair of the last
and first elements, completing the cycle.
let a = [1, 2, 3];
pairs(a, true); // [[1, 2], [2, 3], [3, 1]]
arrayT[]loopbooleanfalse
Converts a value in source units to a value in the target units.