Txt add

From Sim Innovations Wiki
Jump to navigation Jump to search

Description

txt_id = txt_add(text,style, x,y,width,height)

txt_add is used to show a text on the specified location. The txt is also stored in memory for further references.


Info If you use AM 2.1.3 or older, please go to txt_add.

Return value

Argument Type Description
txt_id ID This value can be used for further reference. Functions such as txt_set can use this txt_id. Its good practice to store this txt_id in your logic code.

Arguments

# Argument Type Description
1 txt String This is the txt being shown
2 style String The style to use. See the paragraph below for available style arguments.
3 x Number This is the most left point of the canvas where your text should be shown.
4 y Number This is the most top point of the canvas where your text should be shown.
5 width Number The text width on the canvas.
6 height Number The text height on the canvas.

Style

Argument Type Description Version
font String The TTF font file name (searched in the resource folder of the instrument) AM 3.0/AP 3.0 and up
size Number The font size (in px) AM 3.0/AP 3.0 and up
color String The color, can be color string like "red", "blue", "cyan", etc. etc. Can also be a hex value, "#FFFFFF" AM 3.0/AP 3.0 and up
halign String The horizontal alignment of the text within the text box. Can be "left", "center" or "right". AM 3.0/AP 3.0 and up
valign String The vertical alignment of the text within the text box. Can be "top", "center" or "bottom". AM 3.5/AP 3.5 and up
visible Boolean Should the text be visible AM 3.5/AP 3.5 and up
background_color String Show a background color, with the dimensions of the text box AM 3.6/AP 3.6 and up
visible Boolean Set if node should be visible. AM 4.2/AP 4.2 and up
opacity Number Opacity level of the node, between 0.0 (not visible) to 1.0 (fully visible) AM 4.2/AP 4.2 and up
angle_z Number Rotational value in Z axis, in degrees. AM 4.2/AP 4.2 and up
viewport_rect N N N N Set rectangler viewport, node will not draw outside of this rectangle AM 4.2/AP 4.2 and up
opacity_animation_type String Set opacity animation, can be 'OFF', 'LINEAR' or 'LOG'. AM 4.2/AP 4.2 and up
opacity_animation_speed Number Set opacity animation speed, higher value will result in faster animation. AM 4.2/AP 4.2 and up
move_animation_type String Set move animation, can be 'OFF', 'LINEAR' or 'LOG'. AM 4.2/AP 4.2 and up
move_animation_speed Number Set move animation speed, higher value will result in faster animation. AM 4.2/AP 4.2 and up
rotate_animation_type String Set rotation animation, can be 'OFF', 'LINEAR' or 'LOG'. AM 4.2/AP 4.2 and up
rotate_animation_speed Number Set rotation animation speed, higher value will result in faster animation. AM 4.2/AP 4.2 and up
rotate_animation_direction String Set rotation animation direction. Can be 'DIRECT', 'CW', 'CCW', 'FASTEST' or 'SLOWEST'. AM 4.2/AP 4.2 and up

Included fonts

Font File name (used in style) Example Version
Arimo Regular arimo_regular.ttf example AM 3.6/AP 3.6 and up
Arimo Bold arimo_bold.ttf example AM 3.6/AP 3.6 and up
Digital 7 digital-7-mono.ttf example AM 3.0/AP 3.0 and up
Inconsolata Regular inconsolata_regular.ttf example AM 3.6/AP 3.6 and up
Inconsolata Bold inconsolata_bold.ttf example AM 3.6/AP 3.6 and up
Roboto Regular roboto_regular.ttf example AM 3.0/AP 3.0 and up
Roboto Bold roboto_bold.ttf example AM 3.0/AP 3.0 and up

Example

-- Load and display text and images
-- The myfont.ttf should be placed in the instrument resources folder
mytext1 = txt_add("hello world", "font:myfont.ttf; size:11; color: black; halign:left;", 0, 0, 200, 200)

-- rename text
txt_set(mytext1, "goodbye world")