Francisco Cataldo Bichitoz

De Casiopea
Proyecto Imagen Escrita - Árboles


TítuloProyecto Imagen Escrita - Árboles
Tipo de ProyectoProyecto de Taller
Palabras Clavetarea 7, imagen escrita 2012
Período2012-
AsignaturaTaller Inicial 1ª y 2ª Etapa,
Del CursoImagen Escrita 2012,
CarrerasArquitectura
Alumno(s)Francisco Cataldo
ProfesorHerbert Spencer

//Basado en el ejemplo otorgado por el profesor Herbert Spencer// Se forman distintos patrones de árboles, al presionar S se voltean, con A se agrandan, con Z se achican y con Q se guarda el dibujo.

//Árboles, por Francisco Cataldo,basado en el ejemplo del profesor Herbert Spencer//

import processing.pdf.*;

Trees[] tre;
float margin = 80;
PFont tipografia;

void setup() {
  size(793, 1224, PDF, "ÁrbolesFranciscoCataldo.pdf");
  tipografia = createFont("Britannic Bold", 10);
  textFont(tipografia, 10);
  int ynum = 8; //8 árboles en columna
  int xnum = 10; //10 árboles en fila

  tre = new Trees[ynum * xnum];

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

  int c = 0; 

  for (float y = margin; y <= height - margin; y+= ysp) {
    for (float x = margin; x <= width - margin; x += xsp) {
      tre[c] = new Trees(x, y);
      c++;
    }
  } 
  smooth();
}
void draw() {
  background(255);
  texto();
  for (int i = 0; i < tre.length; i++) {
    tre[i].render();
    println("listo apretar Ctrl + k para revisar el pdf");
    exit();
  }
}
void texto() {
  fill(0);
  text("Francisco Cataldo", width-margin*1.25, 25);
  text("I°ARQ, PUCV", width-margin*1.25, 35);
  smooth();
}
class Trees {
  float x, y;
  float[][] v; 
  int vn; 
  float tam; 
  float w, h;

  Trees(float x, float y) {
    this.x = x;
    this.y = y;
    vn = round(random(40, 100)); //determina la forma de las hojas
    v = new float[vn][5];
    tam =35; //tamaño del árbol formado
    init();
  }

  void init() {
    w = tam/3; //ancho
    h = tam; //alto
    for (int i = 0; i < vn; i++) {
      v[i][0] = random(w);
      v[i][1] = random(-h/2, h/3);
    }
  }

  void trace() {
    noFill();
    stroke(40);
    strokeWeight(1.20);
    beginShape();


    arc(10, 20, 30, 40, 50, 10);
    triangle(0, 1, 0, 20, 0, 15);
    for (int i = 0; i < vn; i++) {
      curveVertex(v[i][0], v[i][1]);
      arc( v[i][0], 4, 6, 6, 4, 2);
      arc (100, 110, 120, 100, 90, 80);
    }
    vertex(v[vn-9][1], v[vn-11][0]);
    endShape();
  }

  void render() {
    pushMatrix();
    {
      translate(x, y);
      trace();
      scale(-1, 1);
      trace();
    }
    popMatrix();
  }
}

void keyPressed() {
  if (key == 's') {//los voltea//
    for (int i = 0; i < tre.length; i++) {
      tre[i].init();
    }
  }

  if (key=='q') {//guarda el trabajo//
    saveFrame("img/######.jpg");
  }
}