🔍

Playing with the LEGO grid


simple random

random & x-mirror


random & x/y-mirror


color[] colors = {
  #FA0000, // red
  #F2CB02, // yellow
  #68B4E5, // light blue
  #2C5ABC, // dark blue
  #FF98FE, // pink
  #F0F0F0 // white
};

int gridsize = 8;
int gscl = 20;

PShape round_rect_shape;
PShape round_circ_shape;

void setup(){
  
  gscl = width/gridsize;

  size(400,400);
  background(0);
  frameRate(3);
  
  round_rect_shape = loadShape("round_rect.svg");
  round_circ_shape  = loadShape("round_quater_circ.svg");
  round_circ_shape.disableStyle();
  round_rect_shape.disableStyle();
   
 
}


void draw(){

    drawGrid();
     saveFrame("out/###_frame.gif");

}

void drawGrid(){
  
  noStroke();
  background(0);
  
  
  for(int y = 0; y<gridsize;y++){
    
    for(int x = 0; x<gridsize;x++){
          
      
      
      float n = noise( x*.4, y*.4, millis()*.001 ); //random(1);
       n = random(1.4);
      
            fill(colors[ int(random(colors.length))]);
      
            
            int rrot = int(random(4))*90;
            rrot = int(n*4)*90;
      
            pushMatrix();
                      translate( x*gscl + gscl/2,y*gscl + gscl/2);
                      rotate(radians(rrot));
                    
                    if(n>.56 && n<.8){
                       
                       shape(round_rect_shape, -gscl/2+1, -gscl/2+1, gscl-2,gscl-2);
                        
                    }else if( n<=.56){
                       shape(round_circ_shape, -gscl/2+1, -gscl/2+1,  gscl-2,gscl-2); 
                      
                    }else{
                      
                      fill(22);
                      circle(1,1,gscl*.6);
                    }
            popMatrix();
            
            /*
             pushMatrix();
                        translate(width - x*gscl + gscl/2 - gscl,y*gscl + gscl/2);
                        scale(-1,1);
                        rotate(radians(rrot));
                        
                      
                      if(n>.56 && n<.8){
                         
                         shape(round_rect_shape, -gscl/2+1, -gscl/2+1, gscl-2,gscl-2);
                          
                      }else if( n<=.56){
                         shape(round_circ_shape, -gscl/2+1, -gscl/2+1,  gscl-2,gscl-2); 
                        
                      }else{
                        
                        fill(22);
                        circle(1,1,gscl*.6);
                      }
                      
                
             popMatrix();
             
             
             
              pushMatrix();
                      translate( x*gscl + gscl/2, height - y*gscl + gscl/2-gscl);
                      scale(1,-1);
                      rotate(radians(rrot));
                    
                    if(n>.56 && n<.8){
                       
                       shape(round_rect_shape, -gscl/2+1, -gscl/2+1, gscl-2,gscl-2);
                        
                    }else if( n<=.56){
                       shape(round_circ_shape, -gscl/2+1, -gscl/2+1,  gscl-2,gscl-2); 
                      
                    }else{
                      
                      fill(22);
                      circle(1,1,gscl*.6);
                    }
            popMatrix();
            
            
             pushMatrix();
                      translate( width - x*gscl + gscl/2 -gscl, height - y*gscl + gscl/2-gscl);
                      scale(-1,-1);
                      rotate(radians(rrot));
                    
                    if(n>.56 && n<.8){
                       
                       shape(round_rect_shape, -gscl/2+1, -gscl/2+1, gscl-2,gscl-2);
                        
                    }else if( n<=.56){
                       shape(round_circ_shape, -gscl/2+1, -gscl/2+1,  gscl-2,gscl-2); 
                      
                    }else{
                      
                      fill(22);
                      circle(1,1,gscl*.6);
                    }
            popMatrix();
            */
            
    }
  }

}