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 › seconds wont restart
Page Index Toggle Pages: 1
seconds wont restart (Read 337 times)
seconds wont restart
Jan 31st, 2009, 9:24am
 
hello, does anyone know why the seconds of this code won't restart? the minutes did just fine. thanks for your help!


float s;
float m;
float h;

void setup(){
 size(1200, 400);
 smooth();
}

void draw(){
 
 s = map(second(), 0, 60, 0, 360);
 m = map(minute() + norm(second(), 0, 60), 0, 60, 0, 360);
 h = map(hour() + norm(hour(), 0, 60), 0, 24, 0, 360);

 circleback();
 secdraw();
 mindraw();
 hourdraw();
}

//seconds wont restart??
void secdraw(){  
 for (int i = 0; i < s; i = i+6){
   stroke(255);
   noFill();
   strokeWeight(1);
   ellipse(width-200, height/2, i, i);
 }
 
}


void mindraw(){  
 for (int i = 0; i < m; i = i+6){
   stroke(#cccccc);
   noFill();
   strokeWeight(1);  
   ellipse(width/2, height/2, i, i);
 }
}

void hourdraw(){  
 for (int i = 0; i < h; i = i+15){
   stroke(#666666);
   noFill();
   strokeWeight(1);
   ellipse(width/3-200, height/2, i, i);
 }
}


void circleback(){
   color transwhite = color(255, 10);
   noStroke();
   fill(transwhite);  
   ellipse(width-200, height/2, 360, 360);
   ellipse(width/2, height/2, 360, 360);
   ellipse(width/3-200, height/2, 360, 360);
}
Re: seconds wont restart
Reply #1 - Jan 31st, 2009, 10:05am
 
Looks like you have the same problem as in the previous one: clock image won't restart...
Re: seconds wont restart
Reply #2 - Jan 31st, 2009, 7:50pm
 
thanks. it did remind me of my previous problem, but i didn't realize that you HAD to put background() in there! thanks again! sorry for the repeat question.
Re: seconds wont restart
Reply #3 - Feb 1st, 2009, 9:59am
 
No problem, I find interesting to see your variation on the theme... Smiley

As long as you redraw the whole graphics in draw(), it is safe and better to use background().
Page Index Toggle Pages: 1