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.
IndexDiscussionExhibition › Layering
Page Index Toggle Pages: 1
Layering (Read 665 times)
Layering
Jan 26th, 2010, 6:58am
 
First off, thank you for Processing !!
A great program, and support.  All hail open source!

That said I have read every tutorial, picked a few custom libraries and now have an expansive library of examples I conjured created since then.

More importantly..

Layering

I figured it would be pretty useless to develop a layering GUI since its just one more lib..

Thus I set out to do some basic laying using the standard Processing features.

My Basic results are below

Quote:
import processing.opengl.*;

void setup()
{  
 size (800, 600, OPENGL);  

 noStroke();
 fill(255,255,255,255);
 rect(0,0,width,height); // canvas
}

void draw()
{
 layer1();
 layer2();
 layer3();
 refreshLayers();
}

void layer1()
{
 noStroke();
 fill(255,0,0,255);
 rect(0,0,width,height);
 
 noStroke();
 fill(255,255,0,128);
 rect(10,10,width-20,height-20);
}

void layer2()
{
 noStroke();
 fill(0,255,0,255);
 rect(15,15,width-30,height-30);
 
 noStroke();
 fill(0,128,128,255);
 rect(70,70,width-140,height-140);
}

void layer3()
{
 noStroke();
 fill(0,0,255,255);
 rect(75,75,width-150,height-150);
}

void refreshLayers()
{
 noStroke();
 fill(255,10);
 rect(0,0,width,height); // canvas
}


Quite simply, every object Stacks onto the canvas/i.e. background.
I draw my biggest and farthest objects in my First layer(), and move progressively to the foreground.

If I write two rectangles that are beside each other
rect(10,10,10,10); rect(20,10,10,10);   ...right ?

The second rectangle is actually On Top of the first.  Processing has layered for us already.


How to update layers..

Change the content!
It will update automatically due to refreshLayers();



Good luck everyone!
Re: Layering
Reply #1 - Jan 26th, 2010, 8:25am
 
Nice job Smiley  nootropic, released a layering library that does something similar I think.

http://processing.org/discourse/yabb2/num_1259116487.html
Page Index Toggle Pages: 1