Martin Araneda: tarea 7

De Casiopea


TítuloMartin Araneda: tarea 7
Palabras Clavetarea 7
Período2012-2012
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., Diseño Industrial"Diseño Industrial" is not in the list (Arquitectura, Diseño, Magíster, Otra) of allowed values for the "Carreras Relacionadas" property.
Alumno(s)Martin Araneda
ProfesorHerbert Spencer

Insect[] ins; float margin = 10;

void setup() {

size(400, 400);
int ynum = 4;
int xnum = 3;
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(#21819B);
for (int i = 0; i < ins.length; i=i+1) {
  ins[i].render();
}

}


class Insect {

float x, y;
float[][]q; 
int vn;  
float tama;  
float w, h;
Insect(float x, float y) {
  this.x = x;
  this.y = y;
  vn =round (random(20,30));
  q = new float[vn][8];
  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/6, h/6);
  }
}
void trace() {
  noFill();
  stroke(150);
  strokeWeight(1.50);
  beginShape();
  vertex(q[0][0], q[0][1]);
  for (int i = 0; i < vn; i=i+5) {
    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();
   
 }
}

}