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 & HelpPrograms › Weird Flicker in Sketch
Page Index Toggle Pages: 1
Weird Flicker in Sketch (Read 351 times)
Weird Flicker in Sketch
Oct 30th, 2008, 4:15pm
 
I have a sketch stretching a bunch of colored vertical lines by a sinewave, however there is a weird flicker when I run it, as if the bottom of the sketch is getting updated after the top.  I'd really like to know what's at play here.  I tried buffering and that didn't seem to help, so if anyone can help me I'd appreciate it.  Thanks.

void setup() {
 size(800,800);
 
 colors = new int[1500];
 int j = 0;
 for (int i = 0; i<1500;i++) {
   if (random(1) < .5) {
     colors[i]= color((int)random(255)+000, (int)random(255)+000,(int)random(2550)+000);
   }
   else {
     colors[i]= color((int)random(2550)+000, (int)random(255)+000,(int)random(255)+000);      
   }
 }

 x = 0;
 
 frameRate(20);
 
}
color colors[];
int sc = 10;
int top = 600;
int bend = 000;
int jj=0;
void draw() {

 if (!tbool) {
    jj+=1;

   if (random(100) > 50) {
     bend++;
   }
   else {
     bend--;
   }

   if (random(100) < 5) {
     top+=5;
   }
   else {
     top-=5;
   }
   int j = jj;
   for (int i = 0; i<width+100;i+=abs(sin(x))*sc) {

     if (j >= 1500) {
      j = 0;
     }
     stroke(colors[j++]);      

     strokeWeight(abs(sin(x))*sc+1);
     
     x+=1.0/10;
     if (x > PI) {
       x = 0;
     }
     line(i, height, i, bend);
   }
}
 
}
float x;
boolean tbool;
void mousePressed() {
 tbool = !tbool;
}
Re: Weird Flicker in Sketch
Reply #1 - Oct 30th, 2008, 7:44pm
 
that, to me, just looks like standard image tearing caused by a discrepancy between your update rate and the screen's update rate.

http://www.hardforum.com/showthread.php?t=928593

search this forum for 'tearing' and 'flicker' and you'll find some suggestions (ie double buffering)

"I tried buffering and that didn't seem to help"

um...
Re: Weird Flicker in Sketch
Reply #2 - Oct 31st, 2008, 1:35pm
 
it could be your vertical sync on the graphics card needs switched on.
Page Index Toggle Pages: 1