Processing : Layers

Layers are possible in Processing too, just like having layers in Photoshop, so we can have different stuff on different layers without interrupting.

We will need this layers library from nootropic design called Processing Layers. There’s also a quick tutorial at the page to get us started to use the library.

I’ve tested a bit for the layers and it’s pretty easy to add layers in processing.

In the main sketch:


import com.nootropic.processing.layers.*; // import layers library
AppletLayers layers;

void setup() {
..
layers = new AppletLayers(this);
layers.addLayer(new Layer1(this));
layers.addLayer(new Layer2(this));
}

void paint(java.awt.Graphics g) {
// This method MUST be present in your sketch for layers to be rendered!
if (layers != null) {
layers.paint(this);
} else {
super.paint(g);
}
}

void draw() {
background(0, 0); // clear the background every time, but be transparent
// now draw something
...
}
...
}

In layers tabs (image below shows how to add new tab) :
Add new tab


class Layer1 extends Layer {

Layer1(PApplet parent) {
super(parent); // This is necessary!
}

That is some basic it should get the layers running~