Text in 2D and 3D

Happy Coding written with colourful background

Text in 2D:


In the draw function, the textSize()is for the size of the text, textFont()takes the web save font, textAlign() aligns the text in right, left or center.

The text(), takes the parameters of string or variable, x and y positions.
e.g.

push();
textSize(20);
textFont("Arial");
textAlign(CENTER);
text("Happy Coding", 400, 400 );
pop();

coloured background coloured background

Text in 3D:

Make a variable (art). In the setup function, this variable will store the value from createGraphics(width, height), which is required to make the 2D text appear on the 3D object as the texture.
e.g.

art = createGraphics(800, 800);

coloured background

In the function draw, make the one pair of push() and pop() and use the 2D text properties like textSize(), textFont() and textAlign() with the text() join each with the art variable.
e.g.

push();
art . textSize(20);
art . textFont("Arial");
art . textAlign(CENTER);
art . text("You Win", 400, 400 );
pop();

coloured background


In the other pair of push()and pop()use the texture() with the variable (art) storing createGraphics() value to texture the 3D object.
e.g.

push();
texture(art);
plane(800, 800);
pop();

coloured background

Result:

coloured background

Continue Reading

Texturing 3D

Learn More

Web Editor

Learn More

Coordinates

Learn More