2011/08/27

標準的每個都看的懂,加起來就看不懂.

float NoiseScale = 0.005;
float NoiseOffsetX = 0;
float NoiseOffsetY = 0;


void setup() { 
  size(600,800,P2D);
  background(255);
  smooth();
  noFill();
  stroke(#5A5AAD,30);
  noiseSeed(22);


  for (int i=0; i<300; i++) {
    NoiseOffsetX += 5;
    NoiseOffsetY += 6;
    drawOneStream();
  }
 
  //saveFrame("01.jpg");
}


void drawOneStream() {
  float px = 0;
  float py = height/2;
  float vx = 1;
  float vy = 0;
  int pcnt = 0;


  while ((px >= 0) && (px < width) && (py < height) && (py >= 0)){
    px += vx;
    py += vy;
    pcnt += 1;
    point(px, py);
 
    float xNoise = noise((pcnt + NoiseOffsetX) * NoiseScale);
    float yNoise = noise((pcnt + NoiseOffsetY) * NoiseScale);
 
    vx = ((2*vx) + 1 + map(xNoise, 0, 1, -1, 1))/4;
    vy = ((3*vy) + map(yNoise, 0, 1, -1, 1))/4;
    }
}

1 則留言: