Zooming In and Zooming Out
              in 
             Programming Questions 
              •  
              8 months ago    
            
 
           
             Hello, everyone.
            
            
I'm just learning Processing. I want to create a Processing sketch that does this:
            
 
            
           I'm just learning Processing. I want to create a Processing sketch that does this:
- If I press the left mouse button, the rectangle gets zoomed in
 - If I press the right mouse button, it gets zoomed out
 
             Here is the code:
             
             
             
             
            
 
           - int zoom = 1;
 - void setup()
 - {
 -   size(240, 240);
 -   background(204);
 -   smooth();
 -   rectMode(CENTER);
 - }
 - void draw()
 - {
 -   if(mousePressed)
 -   {
 -     if(mouseButton == LEFT)
 -     {
 -       zoom += 0.01;
 -     }
 -     if(mouseButton == RIGHT)
 -     {
 -       zoom -= 0.01;
 -     }
 -     scale(zoom);
 -   }
 -   rect(width/2, height/2, 30, 30);
 - }
 
              
              
              1  
            
 
            