101



int num =300;
Spot[] sp = new Spot[num];

void setup(){
size(300,400);
smooth();
noStroke();
for(int i =0; i < num; i++){
sp[i]=new Spot(0,0,random(4,11),random(-0.32,0.32),
random(-0.32,0.32),random(width),random(height),random(-.008,.008),random(-.008,.008),0.0,0.0);
//sp = new Spot(33,50,30,1.0,1.2);
}
}
void draw(){
fill(0,3);
rect(0,0,width,height);
for(int i =0; i < num; i++){

sp[i].move();
sp[i].display();
}
}

void mousePressed(){
save("101.jpg");
}

class Spot{
float x,y,diameter,speedx,speedy,xoff,yoff,increment,incrementy,n,m;

Spot(float xpos, float ypos, float dia,float spdx,float spdy,float xo,float yo,float ic,float icy,float nn,float mm){
x = xpos;
y = ypos;
diameter = dia;
speedx = spdx;
speedy = spdy;
xoff = xo;
yoff = yo;
increment = ic;
incrementy = icy;
n = nn;
m = mm;
}

void move(){
xoff = xoff+increment;
n = noise(xoff)*width;
yoff = yoff+incrementy;
m = noise(yoff)*height;
if((x+diameter/2+n > width)||(x-diameter/2+n < 0)){
speedx = -speedx;
}
x += speedx;
if((y+diameter/2+m>height)||(y-diameter/2+m<0)){
speedy = -speedy;
}
y+=speedy;
}
void display(){
fill(255);
ellipse(x+n,y+m,diameter,diameter);
}
}

コメント