Fizzy / docs / ref / Dimension2.md
Dimension2
Many values in a Shape Sheet define a 2D Point, and rather than define the X and Y values in separate expressions, Fizzy uses one expression.
This makes many tasks simpler, for example, the center of a shape is given by the expression
Size / 2
Creation
The most verbose way e.g. :
Dimension2( 1mm, 2mm )
However, you can also simply use :
( 1mm, 2mm )
It is possible to leave the brackets off too, but that isn't recommended (for clarity).
The units do not have to be the same. e.g.
(10mm, 2 pt)
The X and Y values don't have to be constants. e.g. :
(Size.X / 2, Size.Y / 4)
Operators
Mathematical operators work as you might expect :
Left | Operator | Right | = | Comments |
---|---|---|---|---|
Dimension2 | + or - | Dimension2 | Dimension2 | |
Dimension2 | * or / | Double | Dimension2 | |
Dimension2 | * or / | Vector2 | Dimension2 | |
Dimension2 | / | Dimension2 | Vector2 |
Fields
Name | Type | Comments |
---|---|---|
X | Dimension | |
Y | Dimension | |
Length | Dimension | |
Angle | Angle | The angle of this point from the origin. |
Methods
Name | Parameters | Return Type | Comments |
---|---|---|---|
normalise | none | Vector2 | A unit vector in the same direction as the Dimension2. |
rotate | Angle | Dimension2 | |
toString | none | String | |
format | String | String | Uses Java's DecimalFormat |
toUnits | Units | Dimension2 | Converts to different units. |
clamp | min : Dimension2, max : Dimension2 | Dimension2 | |
min | other : Dimension2 | Dimension2 | Dimension2(min( this.X, other.X) , min ( this.y, other.Y)) |
max | other : Dimension2 | Dimension2 |