We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › textAlign in 0125 question
Page Index Toggle Pages: 1
textAlign in 0125 question (Read 665 times)
textAlign in 0125 question
Jul 22nd, 2007, 7:35pm
 
Hi all,

I try to use the 2nd parameter of textAlign() as introduced in 0125, such as textAlign( CENTER, CENTER);

It works really well with the three-parameter version of text().

e.g. text("Example", 100, 100);

And the text would be centered at (100, 100);

However, it doesn't seem to work very well with the five-parameter version of text().

e.g. text("Example", 100, 100, 50, 50);

I suppose the text should be centered at (125, 125);

However, it is centered at (125, 100) instead.

Does anyone know why or is this a bug?
Re: textAlign in 0125 question
Reply #1 - Jul 22nd, 2007, 11:45pm
 
from the reference:
"The vertical alignment setting is ignored with the variation of text() that draws text inside a box. Text in a box is always drawn with the equivalent of TOP as its vertical alignment."
http://processing.org/reference/textAlign_.html
Re: textAlign in 0125 question
Reply #2 - Feb 10th, 2008, 11:17pm
 
That raises the question of _why_ that is the behavior.  Being able to center text within a box seems to be a reasonably common thing to want to do.  Moreover, there doesn't seem to be any way to figure out how high a piece of text will be once word-wrapping, line-breaks, and so on are rendered.
Re: textAlign in 0125 question
Reply #3 - Feb 11th, 2008, 8:19pm
 
l33tminion wrote on Feb 10th, 2008, 11:17pm:
That raises the question of _why_ that is the behavior.

oh that's an easy one. i haven't had time to implement it, and nobody else has taken the time to do it themselves and contribute a fix.
Re: textAlign in 0125 question
Reply #4 - Feb 11th, 2008, 9:52pm
 
Got it.  Is there a ticket for this issue already?  I'll try looking at the source and see if I can figure things out.
Page Index Toggle Pages: 1