Hello everyone,
I coded a typewriter-like program and I would like to know if there is a way to center a string?
I want the typed text to be displayed in the center of my window, no matter how many characters the string contains.
Thanks for the help!
Answers
In the Reference page, look at the Typography section, particularly the Attributes sub-section, particularly the textWidth() function. After that, it is just simple arithmetic.
I believe you should use text() w/ bound rectangle coordinates & dimensions:
https://processing.org/reference/text_.html
Also specify
textAlign(CENTER, CENTER);
&rectMode(CENTER);
.thanks, I'll try this!