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 › background() layering question
Page Index Toggle Pages: 1
background() layering question (Read 444 times)
background() layering question
Jan 21st, 2006, 4:04am
 
Hello all, new to processing and this forum.

I am having trouble understanding how the 'layering' works in processing.

I am calling 3 different functions, some of them i would like to redraw (not show previous iterations), and some of them i want to iterate (shadow effect).

Whatever i do however seems to cause a global change in all three functions.

Here is my code... thanks!!

void setup() {
 size(300, 300);
}

void myshape(int x, int y) {
 ellipse(x+20, y+0, 10,10);
 ellipse(x+30, y+20, 10,10);
 ellipse(x+10, y+30, 10,10);
 ellipse(x+0, y+10, 10,10);
 }

void mypattern(int x, int y) {
 for (int i=0; i<10; i++) {
   for (int j=0; j<10; j++) {
     noStroke();
     myshape(x + 30*i, y + 30*j);
   }
 }
}


void myclocksecond(int v, int w) {
 int h = hour();
 int m = minute();
 int s = second();
 
 translate(width/2, height/2);
 rotate((PI/30)*s);
 stroke(0);
 fill(21.25*h,4.25*s,4.25*m); // why is this effecting myclockhourminute in void draw()?
 line(0,0,150,150);  
}


void myclockhourminute (int t, int u) {
 int h2 = hour();
 int m2 = minute();
 int s2 = second();

 ellipse(h2*(300/24),265,20,20);
 ellipse(m2*(300/60),285,10,10);
 ellipse(s2*(300/60),295,5,5);
}

void draw() {
 myclockhourminute(0,0);
 mypattern(0,0);
 myclocksecond(0,0);


}

Re: background() layering question
Reply #1 - Jan 21st, 2006, 8:33am
 
There are no distinctive layers in your sketch, like you might have in Flash, where a symbol can occupy a z-index and have it's own rendering attributes. In Processing, the order of  drawing calls and the rendering state controls what gets painted. If you call fill(255) all future shapes will be filled with white, until you call fill() again or noFill().
Page Index Toggle Pages: 1