Advertisement
xeromino

noise

Jun 1st, 2014
485
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.93 KB | None | 0 0
  1. // original code from Matt Pearson
  2.  
  3. float xstart, ystart, squaresize;
  4.  
  5. void setup() {
  6.   size(400, 400);
  7.   background(150);
  8.   xstart = random(10);
  9.   ystart = random(10);
  10.   squaresize = height/8;
  11. }
  12.  
  13. void draw() {
  14.   background(20);
  15.   noStroke();
  16.  
  17.   //stroke(0);
  18.   fill(150);
  19.  
  20.   xstart += 0.02;
  21.   ystart += 0.01;
  22.  
  23.   translate(width/2, height/2);
  24.   float ynoise = ystart;
  25.   for (float y = -squaresize; y <= squaresize; y+=3) {
  26.     ynoise += 0.02;
  27.     float xnoise = xstart;
  28.     for (float x = -squaresize; x <= squaresize; x+=3) {
  29.       xnoise += 0.02;
  30.       drawPoint(x, y, noise(sin(xnoise), cos(ynoise)));
  31.     }
  32.   }
  33.  
  34.   //if (frameCount%3==0 && frameCount < 314) saveFrame("image-####.gif");
  35. }
  36.  
  37. void drawPoint(float x, float y, float noiseFactor) {
  38.   pushMatrix();
  39.   translate(x * noiseFactor * 4, y * noiseFactor * 4);
  40.   float edgeSize = noiseFactor * 10;
  41.   ellipse(0, 0, edgeSize, edgeSize);
  42.   popMatrix();
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement