Advertisement
xeromino

Noisy grid

Oct 13th, 2013
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1. float xstart, ystart, xnoise, ynoise;
  2. float xstartnoise, ystartnoise;
  3. int maxSize;
  4. int step = 20;
  5.  
  6. void setup() {
  7.   size(490, 305);
  8.   background(0);
  9.   rectMode(CENTER);
  10.   //noFill();
  11.   noStroke();
  12.  
  13.   xstartnoise = random(20);
  14.   ystartnoise = random(20);
  15.   xstart = random(10);
  16.   ystart = random(10);
  17. }
  18.  
  19. void draw() {
  20.   background(0);
  21.  
  22.   maxSize = 20;
  23.   xstartnoise += 0.01;
  24.   ystartnoise += 0.01;
  25.   xstart += (noise(xstartnoise)*0.05)-0.025;
  26.   ystart += (noise(ystartnoise)*0.05)-0.025;
  27.  
  28.   xnoise=xstart;
  29.   ynoise=ystart;
  30.  
  31.   for (int y=maxSize/2; y < height-maxSize/4; y+=step) {
  32.     ynoise += 0.1;
  33.     xnoise = xstart;
  34.     for (int x=maxSize/2; x < width-maxSize/4; x+=step) {
  35.       xnoise += 0.1;
  36.       drawPoint(x, y, noise(xnoise, ynoise));
  37.     }
  38.   }
  39. }
  40.  
  41. void drawPoint(float x, float y, float noiseFactor) {
  42.   float sz = noiseFactor * maxSize;
  43.   float a = 100 + int(noiseFactor *155);
  44.   fill(255, a);
  45.   pushMatrix();
  46.   translate(x, y);
  47.   rotate(noiseFactor*TAU);
  48.   rect(0,0,sz,sz);
  49.   popMatrix();
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement