Sofia López insectos
De Casiopea
Título | Tarea 7 de insectos |
---|---|
Tipo de Proyecto | Proyecto de Curso |
Palabras Clave | tarea 7 |
Período | 2012- |
Asignatura | Taller Inicial 1ª y 2ª Etapa, |
Del Curso | Imagen Escrita 2012, |
Carreras | Arquitectura |
Alumno(s) | Sofia López |
Profesor | Herbert Spencer |
Insect[] ins; float margin = 2;
void setup() {
size(800, 800);
int ynum = 11; int xnum = 9;
ins = new Insect[ynum* xnum];
float ysp = (height - (.5 * margin)) / ((float)ynum - .5); float xsp = (width - (.5 * margin)) / ((float)xnum - .5);
int c = 0; // counter
for (float y = margin; y <= height - margin; y+= ysp) { for (float x = margin; x <= width - margin; x += xsp) { ins[c] = new Insect(x, y); c++; } } smooth ();
}
void draw() {
background(#DE872B); for (int i = 0; i < ins.length; i=i+1) { ins[i].render();
}
}
class Insect {
float x, y; float[][]q; // vertices int vn; // número aleatorio de vértices float tama; // tamaño float w, h; // width, height
Insect(float x, float y) { this.x = x; this.y = y; vn =round (random(50,40)); q = new float[vn][6]; tama = 30; init(); }
void init() { w = tama/.7; h = tama/ .7; for (int i = 0; i < vn; i++) { q[i][0] = random(w); q[i][1] = random(-h/3, h/3); } }
void trace() { noFill(); stroke(#816346); strokeWeight(.50); beginShape(); vertex(q[0][0], q[0][1]); for (int i = 0; i < vn; i=i+2) { curveVertex(q[i][0], q[i][1]); } vertex(q[vn-1][0], q[vn-10][0]); endShape(); }
void render() { pushMatrix(); { translate(x, y); trace(); scale(1, -1); trace(); } popMatrix(); }
}
void keyPressed() { if (key == 'v') { for (int i = 0; i < ins.length; i++) { ins[i].tama++; ins[i].init(); } } }