Tarea 7: runas
De Casiopea
Título | simbolos y runas |
---|---|
Tipo de Proyecto | Proyecto de Curso |
Palabras Clave | tarea 7 |
Período | 2012-2012 |
Asignatura | Imagen Escrita 2012, |
Del Curso | Imagen Escrita 2012, |
Carreras | Arquitectura |
Alumno(s) | Eduardo Andrés Segovia Jeria |
Profesor | Herbert Spencer |
//esta tarea muestra varios objetos que cambian de forma con una tecla, fue tomada del ejemplo del profesor y modificado
Insect[] ins; float margin = 80;
void setup() {
size(700, 700); int column = 10; int row = 10; 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(#F50505); 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 = 50; init(); } void init() { w = tam/2; h = tam; for (int i = 0; i < vn; i++) { v[i][1] = random(w); v[1][0] = random(h); } } void trace() { noFill(); stroke(#FFF308); 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() { //cambian de forma
if (key == 'r') { for (int i = 0; i < ins.length; i++) { ins[i].init(); } } //se acercan if (key == 'z') { for (int i = 0; i < ins.length; i++) { ins[i].tam++; ins[i].init(); } } //se alejan if (key == 'x') { for (int i = 0; i < ins.length; i++) { ins[i].tam--; ins[i].init(); } }
}