Daniela Reyes insectario

De Casiopea
Daniela Reyes insectario


TítuloDaniela Reyes insectario
Tipo de ProyectoProyecto de Curso
Palabras Clavetarea 7
Período2012-
AsignaturaTaller Inicial 1ª y 2ª Etapa,
Del CursoImagen Escrita 2012,
CarrerasArquitectura
Alumno(s)Daniela Reyes
ProfesorHerbert Spencer

//trabajo inspirado en el de Sofia Lopez. Insectario en que los elementos se alteran al hacer click en "w"

Insect[] ins; float margin = 10;

void setup() {

 size(700, 700);
 int ynum = 15;
 int xnum = 5;
 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(#FFE517);
 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(10,35));
   q = new float[vn][6];
   tama = 20;
   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(#FF1732);
   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 == 'w') {
  for (int i = 0; i < ins.length; i++) {
    ins[i].tama++;
    ins[i].init();
    
  }
 }
}