Problem with a very simple code
              in 
             Programming Questions 
              •  
              7 months ago    
            
 
           
             Hello,
            
             
            
            
             
            
            
             
            
            
             
            
            
             
            
            
             
            
            
              
           
 
            
           
             I'm a very newbie with Processing and I have a problem that I don't understand.
            
            
             I will write a simple program with a specified background and a Polygon positioned in the correct coordinates. This Polygon have a dimension at start and in five steps must redimensioned (zoom out).
            
            
             The problem is that the drawPolygon() method called by draw() method, draw everything he found without consider the i variable. So i can't simulate a zoom out (i take the way where i draw 5 different polygon, when the first is the biggest).
            
            
             How can I resolve this problem?
            
            
             I'm sorry for the stupid question and probably a poor English.
            
            
             If you have more advice, do not hesitate.
            
            
             Thank you.
            
            
             Good Evening
            
            
             My code is:
            
            - PImage bg;
 - int startTime;
 - int totalTime=5000;
 - int i=1;
 - public void setup() {
 - size(900, 557);
 - bg = loadImage("MyImage");
 - }
 - public void draw() {
 - background(bg);
 - strokeWeight(4);
 - stroke(1);
 - noFill();
 - System.out.println("i -> " + i);
 - if ((millis()-startTime) > totalTime) {
 - startTime = millis();
 - drawPolygon(i);
 - i++;
 - if(i==6)
 - i=1;
 - }
 - }
 - private void drawPolygon(int i) {
 - switch(i) {
 - case 1:
 - beginShape();
 - ..............................
 - endShape();
 - case 2:
 - beginShape();
 - ..................
 - endShape();
 - case 3:
 - beginShape();
 - ........
 - case 4:
 - beginShape();
 - case 4:
 - beginShape();
 - ......
 - endShape();
 - case 5:
 - beginShape();
 - .............
 - endShape();
 - }
 
 
              
              1  
            
 
            