Exit Full View

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 :

LeftOperatorRight=Comments
Dimension2+ or -Dimension2Dimension2
Dimension2* or /DoubleDimension2
Dimension2* or /Vector2Dimension2
Dimension2/Dimension2Vector2

Fields

NameTypeComments
XDimension
YDimension
LengthDimension
AngleAngleThe angle of this point from the origin.

Methods

NameParametersReturn TypeComments
normalisenoneVector2A unit vector in the same direction as the Dimension2.
rotateAngleDimension2
toStringnoneString
formatStringStringUses Java's DecimalFormat
toUnitsUnitsDimension2Converts to different units.
clampmin : Dimension2, max : Dimension2Dimension2
minother : Dimension2Dimension2Dimension2(min( this.X, other.X) , min ( this.y, other.Y))
maxother : Dimension2Dimension2