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
font String The TTF font file name (searched in the resource folder of the instrument)
size Number The font size (in px)
color String The color, can be color string like "red", "blue", "cyan", etc. etc. Can also be a hex value, "#FFFFFF"
halign String The horizontal alignment of the text within the text box. Can be "left", "center" or "right".
valign String The vertical alignment of the text within the text box. Can be "top", "center" or "bottom". Available from AM/AP 3.5.
visible Boolean Should the text be visible. Available from AM/AP 3.5.
background_color String Show a background color, with the dimensions of the text box. Available from AM/AP 3.6.

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")