Help with starting on mouseclick, keeping track of the number of ellipses and outputting blank images.
              in 
             Programming Questions 
              •  
              1 year ago    
            
 
           
             Hey all,
            
             
            
            
             
            
            
             
            
            
             
            
            
             
            
            
             
              
             
             
              
             
             
              
             
             
                
             
             
              
             
             
              
             
             
              
             
             
            
             
            
            
 
            
           
             I'm a real beginner. So far I love programming. 
            
            
             My sketch outputs inkblot tests in a sequential order as jpegs. They are created by the user moving the mouse. It works very well :)
            
            
             I was wondering how I might make it so that the ellipses in the inkblots don't start being made until the user clicks, and how I might avoid outputting a blank image every 600 frames by keeping a count of how many ellipses have been made so far. Ex: If less than 20 ellipses have been made it would not output an image. That way there aren't a ton of empty images in my folder :)
            
            
             Here is my code:
            
            
              String myFile = new String(); //String remnaming var
             
             
              int i = 0; //Int i for counting up naming var
             
             
              // Setup
             
             
              void setup() {
             
             
                 size (600, 600); //Makes sketch dimension same as width and height
             
             
                 background(255); //Nice clean background
             
             
                 smooth(); //Smoothes it out
             
             
              }
             
             
              // Get the motor running   
             
             
              void draw() {
             
             
                 float ray = random(50); //Provides diameter for ellipses
             
             
                 fill(10, 100); //Gives fill
             
             
                 noStroke(); //Kills stroke
             
             
                 ellipse(mouseX, mouseY-20, ray, ray); //Draws ellipses for one side
             
             
                 ellipse(600-mouseX, mouseY-20, ray, ray);// Mirrors ellipses for other side
             
             
                 //Sets up output by watching the framecount.
             
             
                 if (frameCount % 600 == 0) { //Every 600 frames
             
             
                    myFile = String.format("image%02d.jpeg", i++); //Output file naming structure
             
             
                    println(myFile); //Outputs the name of file to be used
             
             
                    save(myFile);   //Saves out jpegs in sketch folder
             
             
                    background(255); //Resets to blank background
             
             
                 }
             
             
              }
             
            
             I appreciate anyone giving this a look. Thank you.
            
 
            
              
              1  
            
 
            