Rac.Text. Format

Determines the alignment, angle, font, and size for drawing a Text object.

instance.Text.Format

Instances of Rac contain a convenience rac.Text.Format function to create Text.Format objects from primitive values. This function also contains ready-made convenience objects, like rac.Text.Format.topLeft, listed under instance.Text.Format.

Example
let rac = new Rac()
let angle = rac.Angle(1/8)
// new instance with constructor
let format = new Rac.Text.Format(rac, 'left', 'baseline', angle)
// or convenience function
let otherFormat = rac.Text.Format('left', 'baseline', 1/8)
See also:

Constructor

new Format(rac, hAlign, vAlign, angleopt, fontopt, sizeopt)

Creates a new Text.Format instance.

Parameters:
Name Type Attributes Default Description
rac Rac

Instance to use for drawing and creating other objects

hAlign String

The horizontal alignment, left-to-right; one of the values from horizontalAlign

vAlign String

The vertical alignment, top-to-bottom; one of the values from verticalAlign

angle Rac.Angle <optional>
rac.Angle.zero

The angle towards which the text is drawn

font String <optional>
null

The font name

size Number <optional>
null

The font size

Members

(static) horizontalAlign :Object

Supported values for hAlign which dermines the left-to-right alignment of the drawn Text in relation to its text.point.

Properties:
Name Type Description
left String

aligns text.point to the left edge of the drawn text

center String

aligns text.point to the center, from side to

right String

aligns text.point to the right edge of the drawn text

(static) verticalAlign :Object

Supported values for vAlign which dermines the top-to-bottom alignment of the drawn Text in relation to its text.point.

Properties:
Name Type Description
top String

aligns text.point to the top edge of the drawn text

center String

aligns text.point to the center, from top to bottom, of the drawn text

baseline String

aligns text.point to the baseline of the drawn text

bottom String

aligns text.point to the bottom edge of the drawn text

angle :Rac.Angle

The angle towards which the text is drawn.

An angle of zero wil draw the text towards the right of the screen.

(nullable) font :String

The font name of the text to draw.

When set to null the font defined in rac.textFormatDefaults.font is used instead upon drawing.

hAlign :String

The horizontal alignment, left-to-right, to position a Text relative to its point.

Supported values are available through the horizontalAlign object.

rac :Rac

Instance of Rac used for drawing and passed along to any created object.

(nullable) size :Number

The font size of the text to draw.

When set to null the size defined in rac.textFormatDefaults.size is used instead upon drawing.

vAlign :String

The vertical alignment, top-to-bottom, to position a Text relative to its point.

Supported values are available through the verticalAlign object.

Methods

equals(otherFormat) → {Boolean}

Returns true when all members, except rac, of both formats are equal, otherwise returns false.

When otherFormat is any class other that Rac.Text.Format, returns false.

See also:
Parameters:
Name Type Description
otherFormat Rac.Text.Format

A Text.Format to compare

reverse() → {Rac.Text.Format}

Returns a new Text.Format that will draw a text reversed, upside-down, in generally the same position as this would draw the same text.

toString(digitsopt) → {String}

Returns a string representation intended for human consumption.

Parameters:
Name Type Attributes Default Description
digits Number <optional>
null

The number of digits to print after the decimal point, when ommited all digits are printed

Example
// returns: 'Text.Format(ha:left va:top a:0.5 f:"sans" s:14)'
rac.Text.Format('left', 'top', 0.5, 'sans', 14)).toString()

withAngle(newAngle) → {Rac.Text.Format}

Returns a new Text.Format with angle set to the Angle derived from newAngle.

Parameters:
Name Type Description
newAngle Rac.Angle | Number

The angle for the new Text.Format

withFont(newFontnullable) → {Rac.Text.Format}

Returns a new Text.Format with font set to newFont.

Parameters:
Name Type Attributes Description
newFont String <nullable>

The font name for the new Text.Format; can be set to null.

withSize(newSizenullable) → {Rac.Text.Format}

Returns a new Text.Format with size set to newSize.

Parameters:
Name Type Attributes Description
newSize Number <nullable>

The font size for the new Text.Format; can be set to null.