text(str, x, y);
Draw text on the screen.
Arguments
str
String to renderx
The x position of the start of the texty
The y position of the top of the textFonts are not yet implemented
function setup()
createWindow(200, 200);
end
function draw()
background('purple');
text('Hello from lu5!', 25, 110);
end
Output
textFont(font);
Set a font family.
Arguments
font
The font value returned when using loadFont
function setup()
createWindow(200, 200);
end
function draw()
background('purple');
textFont('Monospace');
text('Hello from lu5!', 5, 110);
end
Output
loadFont(path);
Load a font.
Arguments
path
The font path on the local systemReturns
font
The image reference-- For Web
function setup()
createWindow(200, 200);
-- loadFont is not needed here...
end
function draw()
background('purple');
textFont('Verdana');
text('Hello from lu5!', 35, 110);
end
Output
-- For native
function setup()
createWindow(200, 200);
font = loadFont('/path/to/myfont.ttf');
end
function draw()
background('purple');
textFont(font);
text('Hello from lu5!', 35, 110);
end
textSize(size);
Set a font size.
Arguments
size
The size of the font in pixelsIf this is called using fonts, make sure to call textSize
after calling textFont
function setup()
createWindow(200, 200);
end
function draw()
background('purple');
textSize(48); -- Larger text
text('Hello lu5!', 0, 120);
end
Output
textAlign(mode);
Set a font alignment.
Arguments
mode
CENTER
, LEFT
, RIGHT
function setup()
createWindow(200, 200);
textAlign(CENTER);
end
function draw()
background('purple');
text('Hello lu5!', width/2, height/2);
point(width/2, height/2);
end
Output