This reference is for Processing 3.0+. If you have a previous version, use the reference included with your software in the Help menu. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Core Javadoc and Libraries Javadoc.

Name

text()

Examples
example pic
textSize(32);
text("word", 10, 30); 
fill(0, 102, 153);
text("word", 10, 60);
fill(0, 102, 153, 51);
text("word", 10, 90); 
example pic
size(100, 100, P3D);
textSize(32);
fill(0, 102, 153, 204);
text("word", 12, 45, -30);  // Specify a z-axis value
text("word", 12, 60);  // Default depth, no z-value specified
example pic
String s = "The quick brown fox jumps over the lazy dog.";
fill(50);
text(s, 10, 10, 70, 80);  // Text wraps within text box
Description Draws text to the screen. Displays the information specified in the first parameter on the screen in the position specified by the additional parameters. A default font will be used unless a font is set with the textFont() function and a default size will be used unless a font is set with textSize(). Change the color of the text with the fill() function. The text displays in relation to the textAlign() function, which gives the option to draw to the left, right, and center of the coordinates.

The x2 and y2 parameters define a rectangular area to display within and may only be used with string data. When these parameters are specified, they are interpreted based on the current rectMode() setting. Text that does not fit completely within the rectangle specified will not be drawn to the screen.

Note that Processing now lets you call text() without first specifying a PFont with textFont(). In that case, a generic sans-serif font will be used instead. (See the third example above.)
Syntax
text(c, x, y)
text(c, x, y, z)
text(str, x, y)
text(chars, start, stop, x, y)
text(str, x, y, z)
text(chars, start, stop, x, y, z)
text(str, x1, y1, x2, y2)
text(num, x, y)
text(num, x, y, z)
Parameters
c char: the alphanumeric character to be displayed
x float: x-coordinate of text
y float: y-coordinate of text
z float: z-coordinate of text
chars char[]: the alphanumberic symbols to be displayed
start int: array index at which to start writing characters
stop int: array index at which to stop writing characters
x1 float: by default, the x-coordinate of text, see rectMode() for more info
y1 float: by default, the y-coordinate of text, see rectMode() for more info
x2 float: by default, the width of the text box, see rectMode() for more info
y2 float: by default, the height of the text box, see rectMode() for more info
num int, or float: the numeric value to be displayed
Returnsvoid
RelatedtextAlign()
textFont()
textMode()
textSize()
textLeading()
textWidth()
textAscent()
textDescent()
rectMode()
fill()
String
Updated on January 1, 2021 03:38:08am EST