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 › Create a rect, put it on top of another
Page Index Toggle Pages: 1
Create a rect, put it on top of another? (Read 841 times)
Create a rect, put it on top of another?
Dec 9th, 2009, 1:56pm
 
Can I assign a layer number/attribute to a rect or quad so that I can put certain shapes in front of (above) others?
Re: Create a rect, put it on top of another?
Reply #1 - Dec 9th, 2009, 2:20pm
 
its just the order you draw them in your draw loop.

if you write

ellipse(x,y,10,10);
rect(x,y,10,10);

the rect is above the circle.

rect(x,y,10,10);
ellipse(x,y,10,10);

or the other way...
Re: Create a rect, put it on top of another?
Reply #2 - Dec 9th, 2009, 2:54pm
 
I did find a 'layers' library the other day; though it looked like you had to jump through some hoops to make it work...  Still, might be interesting as I've yet to see a satisfactory way of changing the order of layers on-the-fly.  I suppose you could put things into a container and iterate through that calling the objects' draw methods; and change the order of the objects in the container as necessary...   Undecided
Re: Create a rect, put it on top of another?
Reply #3 - Dec 9th, 2009, 3:16pm
 
i remembered the library too but i thought it might be too much in this case. but true, if you want to change the order it might be useful

here it is : http://processing.org/discourse/yabb2/num_1259116487.html#1
Re: Create a rect, put it on top of another?
Reply #4 - Dec 9th, 2009, 3:47pm
 
Cedric wrote on Dec 9th, 2009, 3:16pm:
i remembered the library too but i thought it might be too much in this case.


Probably correct, but it's an issue worth discussing.  registerDraw(), which you can use to register a class's draw method with the sketch, apparently puts all registered objects into a simple array.  I've no idea if this array is exposed in any way or what would happen if you tried to change the order of its contents on-the-fly; but I'm curious to find out...
Re: Create a rect, put it on top of another?
Reply #5 - Dec 9th, 2009, 4:11pm
 
thanks guys, this should be more than adequate for what I want to achieve! Smiley
Page Index Toggle Pages: 1