María Jesús Arestizábal Tarea 7
De Casiopea
Título | Tarea 7 |
---|---|
Tipo de Proyecto | Proyecto de Curso |
Palabras Clave | tarea 7 |
Asignatura | Imagen Escrita 2012 |
Del Curso | imagen escrita 2012 |
Carreras | Diseño Gráfico, Diseño Industrial |
Alumno(s) | María Jesús Arestizábal |
// Esta tarea consiste en diseñar un objeto y construir una colección de ellos. Se realizará en base de una manera aleatoria, para así presentar los diferentes especímenes en un insectario.
Insect[] ins; float margin = 60;
void setup() {
size(600, 600); int ynum = 10; int xnum = 8; ins = new Insect[ynum * xnum]; float ysp = (height - (6 * margin)) / ((float)ynum - 4); float xsp = (width - (6 * margin)) / ((float)xnum - 4); int c =0; 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(150,360,360); 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(10, 18)); v = new float[vn][2]; tam = 44; init(); } void init() { w = tam/3; h = tam/2; for (int i = 0; i < vn; i++) { v[i][0] = random(h); v[i][1] = random(-h/4, h/2); } } void trace() { noFill(); stroke(#299BF0); strokeWeight(.4); beginShape(); vertex(v[0][0], v[0][1]); for (int i = 0; i < vn; i++) { curveVertex(v[i][2], v[i][1]); } vertex(v[vn-2][0], v[vn-1][1]); endShape(); } void render() { pushMatrix(); { translate(x, y); trace(); scale(-2, 2); trace(); } popMatrix(); }
}
void keyPressed() {
if (key == 'm') { for (int i = 0; i < ins.length; i++) { ins[i].init(); } } if (key == 'j') { for (int i = 0; i < ins.length; i++) { ins[i].tam--; ins[i].init(); } }
}