Advertisement
xeromino

circles

Dec 7th, 2016
727
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int incr = 4;
  2. int radius = 3;
  3. int num = 3, n=2;
  4. PGraphics myMask, layer;
  5.  
  6. void setup() {
  7.   size(1080, 720);
  8.   float maxHeight = height*.45;
  9.   myMask = createGraphics(width, height);
  10.   layer = createGraphics(width, height);
  11.  
  12.   myMask.beginDraw();
  13.   myMask.background(0);
  14.   myMask.fill(255);
  15.   myMask.noStroke();
  16.   myMask.ellipse(width/2, height/2, maxHeight*1.9, maxHeight*1.9);
  17.   myMask.endDraw();
  18.  
  19.   layer.beginDraw();
  20.   layer.background(238);
  21.   layer.noStroke();
  22.   layer.fill(34);
  23.   while (radius < maxHeight) {
  24.     for (int i=0; i<num; i++) {
  25.       float angle = PI/2+TWO_PI/num*i;
  26.       float x = width/2 + cos(angle)*radius;
  27.       float y = height/2 + sin(angle)*radius;
  28.       float a = map(radius, 0, maxHeight, -1, 7);
  29.       float sz = incr+a;
  30.       layer.ellipse(x, y, sz, sz);
  31.     }
  32.     num += n;
  33.     radius += incr;
  34.   }
  35.   layer.endDraw();
  36.   layer.mask(myMask);
  37.   image(layer, 0, 0);
  38. }
  39.  
  40. void draw() {
  41. }
  42.  
  43. void keyPressed() {
  44.   if (key == 's') save(n+".png");
  45. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement