Advertisement
xeromino

circlenoise

Apr 27th, 2016
668
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.32 KB | None | 0 0
  1. float theta, nsX, nsY, incr = 0.02;
  2. int frms = 120, rez = 2, radius = 75;
  3. color black = color(34);
  4. color white = color(238,240);
  5. color red = color(225, 76, 69);
  6. ArrayList<Dot> dots = new ArrayList<Dot>();
  7.  
  8. void setup() {
  9.   size(540, 540);
  10.   for (int x = -radius; x<radius; x += rez) {
  11.     nsY = 0;
  12.     for (int y = -radius; y<radius; y+= rez) {
  13.       float distance = dist(x, y, 0, 0);
  14.       nsY += incr;
  15.       if (distance<radius) {
  16.         PVector start = new PVector(x, y);
  17.         PVector end = PVector.mult(start, 2);
  18.         float ns = noise(nsX, nsY);
  19.         dots.add(new Dot(start, end, ns));
  20.       }
  21.     }
  22.     nsX += incr;
  23.   }
  24. }
  25.  
  26. void draw() {
  27.   background(black);
  28.   translate(width/2, height/2);
  29.   for (Dot d : dots) {
  30.     d.update();
  31.     d.show();
  32.   }
  33.   theta += TWO_PI/frms;
  34.   //if (frameCount<=frms) saveFrame("image-###.gif");
  35. }
  36.  
  37. class Dot {
  38.  
  39.   PVector start, end, v;
  40.   float sz = 1;
  41.   float lerpValue, offSet;
  42.  
  43.   Dot(PVector _start, PVector _end, float _ns) {
  44.     start = _start;
  45.     end = _end;
  46.     offSet = map(_ns,.2,.8,0,TWO_PI);
  47.   }
  48.  
  49.   void update() {
  50.     lerpValue = map(sin(theta+offSet),-1,1,0,1);
  51.     v = PVector.lerp(start, end, lerpValue);
  52.   }
  53.  
  54.   void show() {
  55.     noStroke();
  56.     strokeWeight(0.9);
  57.     fill(white);
  58.     ellipse(v.x, v.y,sz,sz);
  59.  
  60.   }
  61.  
  62.  
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement