Determines the alignment, angle, font, size, and padding 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, nullable, sizeopt, nullable, hPaddingopt, vPaddingopt)
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
|
||
vAlign |
String
|
The vertical alignment, top-to-bottom; one of the values from
|
||
angle |
Rac.Angle
|
<optional> |
rac.Angle.zero
|
The angle towards which the text is drawn |
font |
String
|
<optional> <nullable> |
null
|
The font name |
size |
Number
|
<optional> <nullable> |
null
|
The font size |
hPadding |
Number
|
<optional> |
0
|
The horizontal padding, left-to-right |
vPadding |
Number
|
<optional> |
0
|
The vertical padding, top-to-bottom |
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 |
center |
String
|
aligns |
right |
String
|
aligns |
(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 |
center |
String
|
aligns |
baseline |
String
|
aligns |
bottom |
String
|
aligns |
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.
hPadding :Number
The horizontal padding, left-to-right, to distance a Text
relative to its point.
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.
vPadding :String
The vertical padding, top-to-bottom, to distance a Text relative
to its point.
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 |
reverse() → {Rac.Text.Format}
Returns a new Text.Format that formats a text reversed, upside-down,
generally in the same position as this.
The resulting Format will be oriented towards the
inverse of angle; alignments for left
becomes right and viceversa; top becomes bottom and viceversa;
center and baseline remain the same.
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
rac.Text.Format('left', 'top', 0.2, 'sans', 14, 7, 5)).toString()
// returns: 'Text.Format(ha:left va:top a:0.2 f:"sans" s:14 p:(7,5))'
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 |
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 |
withPaddings(hPadding, vPaddingopt) → {Rac.Text.Format}
Returns a new Text.Format with paddings set to the given values.
When only hPadding is provided, that value is used for both
horizontal and vertical padding.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
hPadding |
Number
|
The horizontal padding for the new |
||
vPadding |
Number
|
<optional> |
null
|
The vertical padding for the new |
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 |