This sketch is created with an older version of Processing,
and doesn't work on browsers anymore.
xxxxxxxxxx
//Samuel Bravo. Santiago, Chile, 2008. http://terreno.wordpress.com
float c= 0;
float crece=0;
// array
int pastoCount = 10;
Pasto[]pastos = new Pasto[pastoCount];
float[]x = new float[pastoCount];
float[]y = new float[pastoCount];
float[]rx = new float[pastoCount];
float[]ry = new float[pastoCount];
float[]spd = new float[pastoCount];
float[]rot = new float[pastoCount];
void setup(){
//initialize arrays with random values
for (int i=0; i<pastoCount; i++){
pastos[i] = new Pasto();
x[i] = random(20, 40);//rango de altura
y[i] = random(4, 4.5);//tamaño de los tramos
rx[i] =random(55);
ry[i] = random(-55, 55);
spd[i] = random(.1, 3.75);
rot[i] = random(-.85, .85);
frameRate (24);
size(600, 600);
}
}
void draw(){
c=c+.06;
translate (width/2,height);
background(245);
for (int i=0; i<pastoCount; i++){
float d=rot[i];
float ph=-x[i];
if(crece<y[i]){
crece=crece+.001;
}
translate(ry[i],0);
pushMatrix();
rotate(-PI);
float _rot= cos(c)+d;
for (float tramo=crece; tramo>0;tramo=tramo-.1){
pastos[i].linea( tramo*spd[i], _rot, rx[i]);
}
popMatrix();
}
// saveFrame("anim3/pasto-####.png");
}
class Pasto{
// properties
float offsetX, offsetY;
// constructors
Pasto(){
}
// methods
void linea(float h,float rot, float _ph){
rotate(rot/h*.2);
for (float z=0;z<h;z=z+3){
float e=10-((-_ph)/(-_ph*1.1-z));
strokeWeight(e*+h*.3);
stroke(240-1/(e*+h*.0001),40,70+rot*600,18);
point (0,z);
strokeWeight(e*+h*.05);
stroke(250,50);
point (0,z);
}
translate (0,h);
}
}