Displaying Text
To display text in Processing, there is the text()-function. This function takes at least three parameters:
- the text to be displayed
- the x-position (float)
- the y-position (float)
Basically, you can pass almost any variable type as the first parameter to the Text function. It then simply displays the value of the variable.
// Processing
String txt = "Hi!";
text(txt,width/2,height/2);
// p5.js
let txt = "Hi!";
text(txt,width/2,height/2);
// Processing
char c = "@";
text(c,width/2,height/2);
// p5.js
let c = "@";
text(c,width/2,height/2);
//Processing & P5.js
text("Hi!",width/2,height/2);
//Processing & P5.js
text(frameCount,width/2,height/2);
Language Comparison
Published by Tim on Saturday March 28, 2020
- Chars and Strings
- Displaying Text
- Styling Text
- Preloading (p5.js)
- Asset-Management
- Utilizing a font
- Text-Frames
- Line-Breaks
- Line-Height
- String Methods
- String Concatenation
- Getting the Text-Width
- Example: charArt
- Example: Newsticker
- Example: 3D Typography
- Example: Circular Distribution
- Addon: Letter Spacing
- Wrapping Up