Advertisement
xeromino

grid

May 9th, 2016
286
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int cellSize = 50;
  2. int edge = 50;
  3.  
  4. void setup() {
  5.   size(1200,900, P2D);
  6.   smooth(8);
  7.   rectMode(CENTER);
  8.   background(238);
  9.   for (int x=edge+cellSize/2; x<=width-edge; x+=cellSize) {
  10.     for (int y=edge+cellSize/2; y<=height-edge; y+=cellSize){
  11.       //if (random(1)>0.1)
  12.       drawThing(x,y);
  13.     }
  14.   }
  15. }
  16.  
  17. void draw() {
  18. }
  19.  
  20. void keyPressed() {
  21.   if (key =='s') save(random(1234)+".png");
  22. }
  23.  
  24. void drawThing(float x, float y) {
  25.   float sz = map(y,0,height,cellSize*1, cellSize*0.5);
  26.   sz = cellSize*0.8;
  27.   float sz2 = map(y,0,height,cellSize*.1, cellSize*1);
  28.   sz2 = cellSize*.7;
  29.   float r = map(y,0,height, 5,25 );
  30.   float px = map(x,0,width,-cellSize/3,cellSize/3);
  31.   float py = map(y,0,height,-cellSize/3,cellSize/3);
  32.   float offSet = map(y,0,height, 0,PI);
  33.   noStroke();
  34.   fill(35);
  35.   int num = 8;
  36.   for (int i=0; i<num; i++) {
  37.     pushMatrix();
  38.     translate(x,y);
  39.     rotate(radians(r));
  40.     stroke(35);
  41.     noFill();
  42.     rect(0,0,sz,sz);
  43.     rect(0,0,sz/2,sz/2);
  44.     noStroke();
  45.     fill(238);
  46.     ellipse(px,py,sz2, sz2);
  47.     popMatrix();
  48.   }
  49.  
  50. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement