Catalina Arellano: tarea 7, insectario.

De Casiopea
Catalina Arellano: Tarea 7, insectario.


TítuloCatalina Arellano: Tarea 7, insectario.
Tipo de ProyectoProyecto de Curso
Palabras Clavetarea 7
AsignaturaTaller Inicial 1ª y 2ª Etapa,
Del CursoImagen Escrita 2012,
CarrerasArquitectura
Alumno(s)Catalina Arellano
ProfesorHerbert Spencer

En la tarea se logra ver cómo los insectos (abstractos) cambian su posición mediante las teclas de comando.



Insect[] ins; float margin = 70;

void setup() {

 size(1000, 700);
 int ynum = 11;
 int xnum = 9;
 ins = new Insect[ynum * xnum];
 float ysp = (height - (2 * margin)) / ((float)ynum - 1);
 float xsp = (width - (2 * margin)) / ((float)xnum - 1);
 int c = 0; 
 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(255);
 for (int i = 0; i < ins.length; i++) {
   ins[i].render();
 }

}


class Insect {

 float x, y;
 float[][] v; 
 int vn; 
 float tam;  
 float w, h; 
 Insect(float x, float y) {
   this.x = x;
   this.y = y;
   vn = round(random(15,24));
   v = new float[vn][15];
   tam = 20;
   init();
 }
 void init() {
   w = tam/1;
   h = tam/1;
   for (int i = 0; i < vn; i++) {
     v[i][0] = random(w);
     v[i][1] = random(h/2, -h/2);
   }
 }
 void trace() {
   noFill();
   stroke(10);
   strokeWeight(0.25);
   beginShape();
   vertex(v[0][0], v[0][1]);
   for (int i = 0; i < vn/2; i++) {
     curveVertex(v[i][10], v[i][10]);
   }
   vertex(v[vn-1][1], v[vn-1][8]);
   ellipse(v[vn-1][1],v[0][0], v[0][1]+3, v[vn-1][8]+43);
   endShape();
 }
 void render() {
   pushMatrix();
   {
     translate(x, y);
     trace();
     scale(-1, 1);
     trace();
   }
   popMatrix();
 }

}

void keyPressed() {

 if (key == 't') {
   for (int i = 0; i < ins.length; i++) {
     ins[i].init();
   }
 }
 if (key == 'q') {
   for (int i = 0; i < ins.length; i++) {
     ins[i].tam--;
     ins[i].init();
   }
 }
 if (key == 'p') {
   for (int i = 0; i < ins.length; i++) {
     ins[i].tam++;
     ins[i].init();
   }
 }

}