Having touble figuring out a grid problem
              in 
             Programming Questions 
              •  
              7 months ago    
            
 
           
             I want to take the grid and be able to change the inside of one of the rectangles to a random color when you click inside of it, have made many attempts but cannot figure out how it is done.     here is the grid i have.
            
             
            
            
             
            
            
             
            
            
             
            
            
             
            
            
             
            
            
             
            
            
             
            
            
 
            
           
             int boxsize = 50;
            
            
             int cols, rows;
            
            
             void setup() 
            
            
             {
            
            
               size(500, 500);
            
            
               textAlign(CENTER);
            
            
               textSize(24);
            
            
               cols = width/boxsize;
            
            
               rows = height/boxsize;
            
            
             } 
            
            
             void draw() {
            
            
               for (int i = 0; i < cols; i++) {
            
            
                 for (int j = 0; j < rows; j++) {
            
            
                   int x = i*boxsize;
            
            
                   int y = j*boxsize;
            
            
                   if (mouseX >= x && mouseX < x + boxsize &&
            
            
                     mouseY >= y && mouseY < y + boxsize) 
            
            
                   {
            
            
                     fill(#1AC4FF);
            
            
                   } 
            
            
                   else {
            
            
                     fill(255);
            
            
                   }
            
            
                   stroke(0);
            
            
                   rect(x, y, boxsize, boxsize);
            
            
                 }
            
            
               }
            
            
             }
            
            
             any help is appreciated.
            
 
            
              
              1  
            
 
            
 
 
           
 
            