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 › activating and deactivating the drawing of shapes
Page Index Toggle Pages: 1
activating and deactivating the drawing of shapes (Read 471 times)
activating and deactivating the drawing of shapes
Feb 13th, 2006, 5:41am
 
Hi,

I am drawing a swarm of these shapes on the screen with a forloop:

     stroke(valr, valg, valb, alpha_1);
     fill(valr, valg, valb, alpha_1);
     beginShape(POLYGON);
       vertex(23, 12, -20);
       vertex(7, 16, -15);
       vertex(12, 9, -12);
       vertex(2, 3, 2);
     endShape();

     stroke(valr, valg, valb, alpha_2);
     fill(valr, valg, valb, alpha_2);
     ellipse(0, 0, 40, 40);

But I would like to (with key press - that I know how to do) to deactivate the drawing of the polygon shape in the forloop and instead draw the circles.

I realize that it is not enough to put the alpha channel down to 0 in order to 'deactivate' the polygons, because the draw function is still using power to draw the invisible polygons, while the circles are being shown ...

how do I deactivate the drawing of the polygons completely while the circles are being drawn?
Re: activating and deactivating the drawing of sha
Reply #1 - Feb 13th, 2006, 6:43am
 
top of sketch:
declare a flag ( boolean variable)
something like:  
boolean isPolySafe = true;

in draw:
if (isPolySafe){
 poly drawing code here
}
// add an else clause here if you want to draw only
// polygons OR ellipses, but not both.
stroke(valr, valg, valb, alpha_2);
fill(valr, valg, valb, alpha_2);
ellipse(0, 0, 40, 40);


in  keyPressed:
 if(value == someValue) {
  isPolySafe = false;
 } else {
   isPolySafe = true;
 }


Page Index Toggle Pages: 1