AddText

Modified in version 4.0

AddText ( xAnchor ;​ yAnchor ;​ text ;​ font ;​ size ;​ style ;​ color ;​ hAlignment ;​ vAlignment ;​ orientation ;​ maxWidth ;​ maxHeight ;​ ellipsisPosition ;​ shadowEffect ;​ shadowColor )

Argument Type Range Default Note
xAnchor num -inf..+inf (required)
yAnchor num -inf..+inf (required)
text str 0..10000 "" Max. 10000 chars.
font str 0..1000 ApplFont
size num 0..1000 9 Dimension:[pt]
style int 0..7 plain
color rgba 0..255 black
hAlignment int 1..3 left
vAlignment int 1..4 baseline
orientation num -360..+360 0 Dimension:[deg]
maxWidth num -1..10000 -1 Dimension:[pt]
maxHeight num -1..10000 -1 Dimension:[pt]
ellipsisPosition int 0..4 3
shadowEffect num[] -1000..1000 0
shadowColor rgba 0..255 #888a
Examples

AddText(10;​20;​"X2max Software")

AddText(282;​295;​"X2max Software";​Arial;​10;​bold;​blue)

AddText(205;​155;​"Element-2";​Times New Roman;​16;​bold+underline;​red)

Description

For left-justified texts (default) the left border of the text is defined by xAnchor, for centered texts (hAlignment = center) xAnchor defines the center of the text and for right-justified texts (hAlignment = right) xAnchor defines the right border of the text. By using the argument yAnchor, the vertical position of the first line of text can be defined; to put it more precisely, the base line of the first line of text. If vAlignment = baseline is set (default), then yAnchor refers to the base line of the first text line. When vAlignment = top, the upper border of the text is defined by yAnchor; when vAlignment = center, yAnchor defines the vertical center of the text; when vAlignment = bottom, yAnchor defines the lower border of the text. Texts consisting of several lines can be created by inserting a line break (\n).

ADD_TEXT_01
1

OpenDrawing(300;​80)

2

AddText( 10;​20;​"Default Font")

3

AddText(125;​20;​"Courier";​Courier;​12)

4

AddText(190;​20;​"Times New Roman";​Times New Roman;​13)

5

AddText(10;​40;​"Multiple-line\ntext left\njustified";​Verdana;​12;​;​red)

6

AddText(150;​40;​"Multiple-line\ntext\ncentered";​Verdana;​12;​italic;​green;​center)

7

AddText(290;​40;​"Multiple-line\ntext right\njustified";​Verdana;​12;​underline;​blue;​right)

8

CloseDrawing()

ADD_TEXT_01
ADD_TEXT_02
1

OpenDrawing(200;​40)

2

AddText(10;​30;​ /* Anchor point. */

3

"こんにちは世界";​ /* Text. */

4

ヒラギノ角ゴ Pro W3;​ /* Font. */

5

25.5;​ /* Font size. */

6

plain;​ /* Text style. */

7

white;​ /* Text color. */

8

left;​ /* Horizontal alignment. */

9

baseline;​ /* Vertical alignment. */

10

0;​ /* Orientation [degree]. */

11

-1;​ /* Max. width. */

12

-1;​ /* Max. height. */

13

3;​ /* Ellipsis position. */

14

2 2 5;​ /* x/y-shadow offsets and blur. */

15

darkBlue) /* Shadow color. */

16

CloseDrawing()

ADD_TEXT_02

When orientation =​ 0 (in degrees), the text is laid out horizontally (default). When orientation > 0, the text is turned clockwise; when orientation < 0, it is turned counter-clockwise.

ADD_TEXT_03
1

OpenDrawing(200;​120)

2

AddText(100;​60;​ /* Anchor point. */

3

"Hello World.";​ /* Text. */

4

Verdana;​ /* Font. */

5

28;​ /* Font size. */

6

bold;​ /* Text style. */

7

1 90 1 0.0 49 56 12 255 0.5 176 198 52 255 1.0 49 56 12 255;​ /* Text color gradient. */

8

center;​ /* Horizontal alignment. */

9

center;​ /* Vertical alignment. */

10

-20) /* Orientation (in degrees). */

11

CloseDrawing()

ADD_TEXT_03
ADD_TEXT_04
1

OpenDrawing(120;​120)

2

AddText(60;​60;​"rotated text";​Verdana;​18;​;​255 0 0 255;​center;​center;​-60)

3

AddText(60;​60;​"rotated text";​Verdana;​18;​;​255 0 0 210;​center;​center;​-30)

4

AddText(60;​60;​"rotated text";​Verdana;​18;​;​255 0 0 170;​center;​center;​ 0)

5

AddText(60;​60;​"rotated text";​Verdana;​18;​;​255 0 0 140;​center;​center;​ 30)

6

AddText(60;​60;​"rotated text";​Verdana;​18;​;​255 0 0 120;​center;​center;​ 60)

7

AddText(60;​60;​"rotated text";​Verdana;​18;​;​255 0 0 80;​center;​center;​ 90)

8

CloseDrawing()

ADD_TEXT_04

When setting a maximum width, i.e. maxWidth > 0, a longer multi-line text can be issued as continuous text with automatic word wraparound. The height of the text block can be controlled by the argument maxHeight. Texts which do not completely fit into the area predefined by maxWidth and maxHeight will be shortened according to the setting by the argument ellipsisPosition. 5 options are available:

ellipsisPosition Truncation Ellipsis
0 end (No ellipsis)
1 begin ...text
2 middle text...text
3 end text... (Default)
4 begin + end ...text...
ADD_TEXT_05
1

OpenDrawing(200;​120)

2

AddText(10;​10;​"For left-justified texts the left border of the text is defined by xAnchor, for centered texts xAnchor defines the center of the text and for right-justified texts xAnchor defines the right border of the text.";​Verdana;​9;​bold;​olive;​left;​top;​0;​90;​100)

3

AddText(100;​25;​"When orientation=0 (in degrees), the text is laid out horizontally (default). When orientation>0, the text is turned clockwise; when orientation<0, it is turned counter-clockwise.";​Verdana;​9;​plain;​darkRed;​left;​;​-90;​100;​90;​2)

4

CloseDrawing()

ADD_TEXT_05

As the default, maxWidth =​ –1 and maxHeight =​ –1 are set, i.e. no width and height constraints and, thus, no automatic word wraparound support.

Scroll to Top
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×