Reputation: 2618
I am trying to align a string of text and an ellipse vertically in Processing. Although both textAlign
and ellipseMode
are all set to CENTER
, there is still a slight offset between the text and the ellipse.
void setup()
{
size(200, 200);
background(255);
textAlign(CENTER);
ellipseMode(CENTER);
noStroke();
smooth();
fill(0);
text("Document 1.txt", 60, 20);
fill(255, 0, 0);
ellipse(120, 20, 10, 10);
}
Upvotes: 2
Views: 1308
Reputation: 2618
Instead of textAlign(CENTER)
, which specifies horizontal alignment, I used textAlign(CENTER, CENTER)
, which guarantees that the text is aligned both horizontally, and vertically.
Upvotes: 2