Tarea 7: runas

De Casiopea
Revisión del 10:46 27 sep 2018 de Hspencer (discusión | contribs.) (Texto reemplazado: «Helbert Spencer» por «Herbert Spencer»)
(difs.) ← Revisión anterior | Revisión actual (difs.) | Revisión siguiente → (difs.)
simbolos y runas


Títulosimbolos y runas
Tipo de ProyectoProyecto de Curso
Palabras Clavetarea 7
Período2012-2012
AsignaturaImagen Escrita 2012,
Del CursoImagen Escrita 2012,
CarrerasArquitectura
Alumno(s)Eduardo Andrés Segovia Jeria
ProfesorHerbert 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();
  }
}

}