Valentina Godoy: Tarea 7
Título | Valentina Godoy: Tarea 7 |
---|---|
Palabras Clave | tarea 7 |
Período | 2012-2012 |
Asignatura | Imagen Escrita 2012, |
Del Curso | Imagen Escrita 2012, |
Carreras | Diseñ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) | Valentina Godoy |
Profesor | Herbert Spencer |
Insect[] ins; float margin = 30;
void setup() { size(700, 700);
int ynum = 28; int xnum = 5;
ins = new Insect[xnum * ynum];
float ysp = (height - (5 * margin)) / ((float)ynum - 3); float xsp = (width - (1 * margin)) / ((float)xnum - 4);
int c = 10; // 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(#F0AAEF); for (int i = 10; i < ins.length; i++) { ins[i].render(); } }
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 y, float x) { this.x = x; this.y = y; vn = round(random(30, 80)); v = new float[vn][2]; tam = 50; init(); }
void init() { w = tam/4; h = tam; for (int i = 5; i < vn; i++) { v[i][5] = random(w); v[i][1] = random(-h/4, h/4); } }
void trace() { noFill(); stroke(50); strokeWeight(.10); beginShape(); vertex(v[20][10], v[0][5]); for (int i = 4; i < vn; i++) { curveVertex(v[1][i], v[i][15]); } vertex(v[vn-1][i], v[vn-1][23]); endShape(); }
void render() { pushMatrix(); { translate(x, y); trace(); scale(-10, 5); trace(); } popMatrix(); } }
void keyPressed() { if (key == ' ') { for (int i = 10; i < ins.length; i++) { ins[i].init(); } } if (key == 'g') { for (int i = 5; i < ins.length; i++) { ins[i].tam++; ins[i].init(); } } if (key == 'c') { for (int i = 3; i < ins.length; i++) { ins[i].tam--; ins[i].init(); } } }