Gabriela Correa: Lepidópteros

De Casiopea
Archivo:Lepidópteros.png
Gabriela Correa: Lepidópteros


TítuloGabriela Correa: Lepidópteros
Tipo de ProyectoProyecto de Curso
Palabras Clavetarea 7
AsignaturaTaller Inicial 1ª y 2ª Etapa,
Del CursoImagen Escrita 2012,
CarrerasDiseño Gráfico"Diseño Gráfico" is not in the list (Arquitectura, Diseño, Magíster, Otra) of allowed values for the "Carreras Relacionadas" property.
Alumno(s)Gabriela Correa
ProfesorHerbert Spencer

Instrucciones:

r = Regenerar aleatoriamente z = Acercar x = Alejar

__________________________________________________________________________

Insect[] ins; float margin = 55;

void setup() {

 size(650, 800);
 int column = 5;
 int row = 5;
 ins = new Insect[column * row];
 float yins = (height - (2 * margin)) / ((float)column - 1);
 float xins = (width - (2 * margin)) / ((float)row - 1);
 int c = 0;
 for (float y = margin; y <= height - margin; y += yins) {
   for (float x = margin; x <= width - margin; x += xins) {
     ins[c] = new Insect(x, y);
     c++;
   }
 } 
 smooth();

}


void draw() {

 background(#0893C6);
 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(5, 10));
   v = new float[vn][3];
   tam = 80;
   init();
 }
 void init() {
   w = tam/1.5;
   h = tam;
   for (int i = 0; i < vn; i++) {
     v[i][1] = random(w);
     v[1][0] = random(h);
   }
 }
 void trace() {
   noFill();
   stroke(#7E37C7, 70);
   strokeCap(ROUND);
   strokeWeight(2);
   smooth();
   beginShape();
   vertex(v[0][0], v[0][1]);
   for (int i = 0; i < vn; i++) {
     curveVertex(v[i][0], v[i][1]);
   }
   vertex(v[vn-1][0], v[vn-1][1]);
   endShape();
 }
 void render() {
   pushMatrix();
   {
     translate(x, y);
     trace();
     scale(-1, 1);
     trace();
   }
   popMatrix();
 }

}

void keyPressed() {

 if (key == 'r') {
   for (int i = 0; i < ins.length; i++) {
     ins[i].init();
   }
 }
 if (key == 'z') {
   for (int i = 0; i < ins.length; i++) {
     ins[i].tam++;
     ins[i].init();
   }
 }
 if (key == 'x') {
   for (int i = 0; i < ins.length; i++) {
     ins[i].tam--;
     ins[i].init();
   }
 }

}