Trabajo Final

De Casiopea



TítuloEspejo Roto
AsignaturaImagen Escrita 2017
Del CursoImagen Escrita 2017
CarrerasArquitectura
Alumno(s)Nicolas Farias


Codigo Proyecto

void setup() {

 fullScreen();
 t = new ArrayList<TrazoTrizado>(); 

}

void draw() {

 background(100); 
 float d = dist(mouseX, mouseY, pmouseX, pmouseY);
 
 if (dibujando) {
   trazoTrizadoTemporal.draw(); 
   trazoTrizadoTemporal.temblor();
 }
 if (mousePressed && d > 1) {
   Punto nuevoPunto = new Punto(mouseX, mouseY); 
   trazoTrizadoTemporal.p.add(nuevoPunto);
   
   if(random(1) < 0.10 ){
     trazoTrizadoTemporal.triza(mouseX, mouseY);
   }
 }
 for (int i = 0; i < t.size(); i++) {
   t.get(i).draw();
 }

}

void mousePressed() {

 trazoTrizadoTemporal = new TrazoTrizado(); 
 Punto punto = new Punto(mouseX, mouseY);
 trazoTrizadoTemporal.p.add(punto);
 dibujando = true;

}

void mouseReleased() {

 t.add(trazoTrizadoTemporal); 
 dibujando = false;

}

void keyPressed() {

 setup();

}

Punto

class Punto {

 float x, y, t;
 Punto(){
  x = random(width);
  y = random(height);
  t = random(TWO_PI);
 }
 
 Punto(int x, int y) {
   this.x = float(x);
   this.y = float(y);
   t = random(TWO_PI);
 }
 Punto(float x, float y) {
   this.x = x;
   this.y = y;
   t = random(TWO_PI);
 }
 Punto(float x, float y, float t) {
   this.x = x;
   this.y = y;
   this.t = t;
 }

}

Trazo

class Trazo {

 ArrayList<Punto> p; 
 Trazo() {
   p = new ArrayList<Punto>();
 }
 void draw() {
   noFill();
   strokeWeight(1.8);
   stroke(200);
   beginShape();
   for (int i = 0; i < p.size(); i++) {
     curveVertex(p.get(i).x, p.get(i).y);
   }
   endShape();
 }
 
 void temblor(){
   for (int i = 0; i < p.size(); i++) {
     Punto pt = p.get(i); 
     pt.x += random(-2, 2);
     pt.y += random(-2, 2);
   }
 }

}

Trazo de Trizadura

class TrazoTrizado {

 ArrayList<Punto> p; 
 ArrayList<Trizadura> triz;
 TrazoTrizado() {
   p = new ArrayList<Punto>();
   triz = new ArrayList<Trizadura>();
 }
 void draw() {
   noFill();
   strokeWeight(1.8);
   stroke(200);
   beginShape();
   for (int i = 0; i < p.size(); i++) {
     vertex(p.get(i).x, p.get(i).y);
   }
   endShape();
   // dibuja trizaduras
   for (int i = 0; i < triz.size(); i++) {
     triz.get(i).draw();
   }
 }
 void temblor() {
   for (int i = 0; i < p.size(); i++) {
     Punto pt = p.get(i); // punto temporal
     pt.x += random(-2, 2);
     pt.y += random(-2, 2);
   }
 }
 void triza(float x, float y) {
   Trizadura nueva = new Trizadura(x, y);
   triz.add(nueva);
   float largo = round(random(5, 20));
   for (int i = 0; i < largo; i++) {
     nueva.avanza();
   }
 }

}

Trizadura

class Trizadura {

 float s, t; // step o paso y t = ángulo
 ArrayList<Punto> p;
 Trizadura(float x, float y) {
   p = new ArrayList<Punto>();
   t = random(TWO_PI);
   s = random(5, 20);
   Punto puntoInicial = new Punto(x, y);
   p.add(puntoInicial);
 }
 void avanza() {
   Punto ultimo = p.get(p.size()-1);
   float nx = ultimo.x + cos(t)*s;
   float ny = ultimo.y + sin(t)*s;
   t += random(-10, (mouseX-pmouseX)+10);
   s += random (-10, (mouseY-pmouseY)+10);
   Punto nuevo = new Punto(nx, ny);
   p.add(nuevo);
 }
 void draw() {
   noFill();
   strokeWeight(1.8);
   stroke(200);
   beginShape();
   for (int i = 0; i < p.size(); i++) {
     vertex(p.get(i).x, p.get(i).y);
   }
   endShape();
 }

} <processingjs>