Loading...
Logo
Processing Forum
Hi there, 

I am trying to draw shape behind each other every loop, while using the z value of the translate works (and decrementing by -1 each draw loop), I loose a lot of control for the look of the shape (srokeJoin for example). Is there a way to draw behind the previous draw loop, instead of always drawing on top without using 3d?




Replies(2)

You cannot use the z value of translate in 2D!
Idea 1: usually you redraw everything in the sketch on each draw() call. Thus, you can act on the drawing order: first drawn is behind, last drawn is in front.
Idea 2: maybe you make one of these sketches that doesn't call background() at the start of each draw(), cumulating drawings over time. In this case, you have to draw everything on a PGraphics with transparency (in JAVA2D mode, the default). Each new shape must be done on a new PGraphics, then you draw the previous one over that, and display that.
Thanks phi.lho,

From your answer I see that my main problem is on relying on the draw loop too, from which I cannot dictate the order in which the shapes are drawn... 

I am trying to create an algorithm that represent how I draw by hand, and when you draw by hand you normally do not draw on top of each of your drawing, you use the illusion of drawing behind the shapes (i.e. you draw a character then you draw the background 'behind' him) . So that's what I am trying to experiment with. 

The algorithm that I want to create will generate shape (rounded rectangle) - I understand now that it would be better to load them in an array first and then display that array in the reverse that it was created. 

Thanks !