Francisca Campos, vichos

De Casiopea
mariposa


Títulomariposa
Palabras Clavetarea 7
AsignaturaTaller Inicial 1ª y 2ª Etapa,
Del CursoImagen Escrita 2012,
CarrerasArquitectura
Alumno(s)Francisca Campos
ProfesorHerbert Spencer
  Insect[] ins;
float margin = 60;

void setup() {
  size(900, 900); // tamaño

  int ynum = 10;//cantidad de bichos en eje y
  int xnum = 10;//cantidad de bichos en x

  ins = new Insect[ynum * xnum];

  float ysp = (height - (2 * margin)) / ((float)ynum - 1);
  float xsp = (width - (2 * margin)) / ((float)xnum - 1);

  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(); // suavizado
}


void draw() {
  background(250); // color de fondo
for (int i = 0; i < ins.length; i++) {
    ins[i].render();
  }
}


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


// esta es otra pestaña donde aparecen los insectos
class Insect {
  float x, y;
  float[][] v; // vertices
  int vn;  // número aleatorio de vértices
  float tam;  // tamaño
  float w, h; // width, height

Insect(float x, float y) {
    this.x = x;
    this.y = y;
    vn = round(random(10, 10));
    v = new float[vn][5];
    tam = 50;
    init();
  }
  void init() {
    w = tam/2;
    h = tam;
    for (int i = 0; i < vn; i= i+5) {
      v[i][0] = random(w);
      v[i][1] = random(-h/2, h/2);
    }
  }


void trace() {
    noFill(); // relleno de la figura
    stroke(0); // color de la linea
    strokeWeight(0.25); // grosor de la linea
    
    ellipse(2, 4, 62, 62);
    
    triangle(v[0][0], v[0][1],v[vn-1][0], v[vn-1][1],v[vn-1][0]+9, v[vn-1][1]+30);
    
    triangle (v[0][1], v[0][0],v[vn-1][1], v[vn-1][0],v[vn-1][1]+30, v[vn-1][0]+9);
    
   
  }
  

  void render() {
    pushMatrix(); // cambiar la matriz
    {
      translate(x, y);
      trace();
      scale(-1, 1);
      trace();
    }
    popMatrix(); // volver a la matriz original
  }
}