Loading...
Logo
Processing Forum
i have a quick question about the way processing works. how come this doesnt work:

Copy code
  1. size(500, 500);
  2. background(255);
  3. strokeWeight(5);
  4. smooth();
  5. noFill();

  6. for(int i = 1; i <= 3; i++){
  7.   int colorSelect = i;
  8.   
  9.   switch(colorSelect){
  10.     case 1:
  11.       stroke(#FF0000);
  12.     case 2:
  13.       stroke(#00FF00);
  14.     case 3:
  15.       stroke(#0000FF);
  16.   }
  17.   ellipse(height / 2, width / 2, i * 50, i * 50);
  18. }
But this does:

Copy code
  1. size(500, 500);
  2. background(255);
  3. strokeWeight(5);
  4. smooth();
  5. noFill();

  6. for(int i = 1; i <= 3; i++){
  7.   int colorSelect = i;
  8.   
  9.   if(i == 1){
  10.     stroke(#FF0000);
  11.   }
  12.   else if(i == 2){
  13.     stroke(#00FF00);
  14.   }
  15.   else{
  16.     stroke(#0000FF);
  17.   }
  18.   ellipse(height / 2, width / 2, i * 50, i * 50);
  19. }
Thanks!

Replies(2)

You forgot to add break; at the end of each case.
ha. i knew it would be something dumb like that. thank you