mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-24 11:23:43 +01:00
Scripts get the global UnitValue constructor: a number with one of the length units (inches, feet, yards, miles, millimeters, centimeters, meters, kilometers, points, picas, traditional points and picas, ciceros), pixels or percent. as() and convert() give or change the unit, baseUnit sets what one pixel and 100% measure, and the arithmetic, comparison and unary operators calculate with the object's number. With two objects the right one is converted to the left one's unit. Conversions go through exact ratios to the inch, so 1 in is exactly 72 pt. An unknown unit or text makes an invalid object; converting it or using it with an operator, a result that is not finite and a comparison with a number that is not finite throw a RangeError. A realm without UnitValue keeps the standard operators. docs/mcp.md describes the class.