String, position and format to draw a text.
An instance of this object contains the string and a Point
used to
determine the location of the drawn text. The
Text.Format
object determines the font, size,
orientation angle, and the alignment relative to
point
to draw the text.
instance.Text
Instances of Rac
contain a convenience
rac.Text
function to create Text
objects with fewer
parameters. This function also contains ready-made convenience
objects, like rac.Text.hello
, listed under
instance.Text
.
Example
let rac = new Rac()
let point = rac.Point(55, 77)
let format = rac.Text.Format('left', 'baseline')
// new instance with constructor
let text = new Rac.Text(rac, point, 'black quartz', format)
// or convenience function
let otherText = rac.Text(55, 77, 'black quartz', format)
- See also:
Constructor
new Text(rac, point, string, format)
Creates a new Text
instance.
Parameters:
Name | Type | Description |
---|---|---|
rac |
Rac
|
Instance to use for drawing and creating other objects |
point |
Rac.Point
|
The location for the drawn text |
string |
String
|
The string to draw |
format |
Rac.Text.Format
|
The format for the drawn text |
Classes
Members
format :Rac.Text.Format
The alignment, angle, font, and size to use to draw the text.
point :Rac.Point
The location where the text will be drawn.
The text will be drawn relative to this point based on the
alignment and angle configuration of
format
.
rac :Rac
Instance of Rac
used for drawing and passed along to any created
object.
Methods
equals(otherText) → {Boolean}
Returns true
when the string
and point
of both texts are equal;
otherwise returns false
.
When otherText
is any class other that Rac.Text
, returns false
.
point
s are compared using point.equals
.
The format
objects are ignored in this comparison.
- See also:
Parameters:
Name | Type | Description |
---|---|---|
otherText |
Rac.Text
|
A |
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((55,77) "sphinx of black quartz")'
rac.Text(55, 77, 'sphinx of black quartz').toString()
withAngle(newAngle) → {Rac.Text}
Returns a new Text
and Format
with format.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}
Returns a new Text
and Format
with format.font
set to newFont
.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
newFont |
String
|
<nullable> |
The font name for the new |
withSize(newSizenullable) → {Rac.Text}
Returns a new Text
and Format
with format.size
set to newSize
.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
newSize |
Number
|
<nullable> |
The font size for the new |