見出し画像

初心者のジェネラティブアート①

マット・ピアソンの「ジェネラティブ・アートーProcessingによる実践ガイド」を読みながら、ジェネラティブアートを勉強しています。
この本に載っているChapter5の「回転を使って視覚化された、2Dパーリンノイズ」をいじってみました。とりあえず公開してみます。

float xstart, xnoise, ynoise;	

void setup() {	
 size(400,400);
 noLoop();
 smooth();
}
 
void draw() {  
 xstart = random(10);
 xnoise = xstart;
 ynoise = random(10);
 
 for (int y = 0; y <= height; y+=5) {
   ynoise += 0.1;		
   xnoise = xstart;
   for (int x = 0; x <= width; x+=5) {
     xnoise += 0.1; 
     drawPoint(x, y, noise(xnoise, ynoise));  
   }
 } 
}

void drawPoint(float x, float y, float noiseFactor) {
 pushMatrix();
 translate(x,y);
 rotate(noiseFactor*2*PI);
 strokeWeight(random(1,10));
 stroke(random(255),random(255),random(255));
 line(0,0,random(5,30),0);
 popMatrix();
}

void keyPressed() {
 redraw(); 
} 


HSBカラーモードに変えてみます。

float xstart, xnoise, ynoise;	

void setup() {	
 size(400,400);
 colorMode(HSB, 360, 100, 100, 100);
 noLoop();
 smooth();
}
 
void draw() {  
 xstart = random(10);
 xnoise = xstart;
 ynoise = random(10);
 
 for (int y = 0; y <= height; y+=5) {
   ynoise += 0.1;		
   xnoise = xstart;
   for (int x = 0; x <= width; x+=5) {
     xnoise += 0.1; 
     drawPoint(x, y, noise(xnoise, ynoise));  
   }
 } 
}

void drawPoint(float x, float y, float noiseFactor) {
 pushMatrix();
 translate(x,y);
 rotate(noiseFactor*2*PI);
 strokeWeight(random(1,10));
 stroke(random(360),100,100);
 line(0,0,random(5,30),0);
 popMatrix();
}

void keyPressed() {
 redraw(); 
} 

この記事が気に入ったらサポートをしてみませんか?