ProcessingでGenerative art#32
ランダムウォークです。
Nature of codeで一応やったんですけど、PVectorとArrayListをほとんど使っえてなかったので、身につけるために使って行こうかな思います。
Code
ArrayList<Particle> p;
void setup(){
size(700, 600);
pixelDensity(2);
colorMode(HSB, 360, 100, 100, 100);
blendMode(ADD);
stroke(200, 80, 30, 40);
strokeWeight(0.5);
background(200, 2, 5);
p = new ArrayList<Particle>();
for(int i = 0; i < 1000; i++){
p.add(new Particle());
}
}
void draw(){
for(Particle particle: p){
particle.update();
particle.display();
}
}
void keyPressed(){
if(key ==' ')saveFrame("####.png");
}
class Particle{
PVector pos, pPos;
float theta;
Particle(){
theta = random(PI*2);
pos = new PVector(width/2 + 200 * cos(theta), height/2 + 200 * sin(theta));
}
void update(){
pPos = pos;
pos = PVector.add(pos, new PVector(random(-2, 2), random(-2, 2)));
}
void display(){
line(pPos.x, pPos.y, pos.x, pos.y);
}
}
応援してくださる方!いつでもサポート受け付けてます!