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 › dynamic space evenly horizontally
Page Index Toggle Pages: 1
dynamic space evenly horizontally (Read 863 times)
dynamic space evenly horizontally
Aug 25th, 2009, 1:44am
 
Hi,

I am trying to figure out how to space even horizontally object of different width, any ideas?

Cheers
rS
Re: dynamic space evenly horizontally
Reply #1 - Aug 25th, 2009, 1:55am
 
Maybe this post can help
http://processing.org/discourse/yabb2/?num=1223416980
Re: dynamic space evenly horizontally
Reply #2 - Aug 25th, 2009, 2:03am
 
Pseudo-code:
Code:
pos = 0
for (each object)
{
draw(object, pos)
pos += object.width + spacing
}

If you need to fit a given width, you have spacing = (wantedWidth - totalObjectWidth) / (objectNb - 1)
Re: dynamic space evenly horizontally
Reply #3 - Aug 25th, 2009, 2:14am
 
Hi PhiLo,

What is (objectNb - 1)? is it the current object in the for loop?

Cheers
rS
Re: dynamic space evenly horizontally
Reply #4 - Aug 25th, 2009, 2:46am
 
Spacing is fixed, so you must compute it beforehand. objectNb is just the number of objects.
Page Index Toggle Pages: 1