Génesis Morales: Tarea 8

De Casiopea
La versión para imprimir ya no se admite y puede contener errores de representación. Actualiza los marcadores del navegador y utiliza en su lugar la función de impresión predeterminada del navegador.
Génesis Morales: Tarea 8


TítuloGénesis Morales: Tarea 8
Tipo de ProyectoProyecto de Curso
Palabras Clavetarea 8
Período2012-
AsignaturaTaller Inicial 1ª y 2ª Etapa,
Del CursoImagen Escrita 2012,
CarrerasArquitectura
Alumno(s)Génesis Morales
ProfesorHerbert Spencer
import processing.pdf.*;

PImage imagen;
PFont font;
String[] code;

float mI = 30; // Margen Izquierda
float mAr  = 30; // Margen Arriba
float mD = 40; // Margen Derecha
float mAb   = 30; // Margen Abajo
float escala;

void setup() {

  imagen = loadImage("1.jpg");
  size(609, 765, PDF, "tarea_8.pdf");  // tamaño carta

  float ancho = width - (mI + mD);
  escala = ancho/imagen.width;

  noLoop();
  background(255);
  smooth();

  font = createFont("Courier", 15, true);
  textFont(font, 15);
  code = loadStrings("trazo.pde"); // cargo el código "trazo" (el pincel)
}

void draw() {

  float spacer = 10;

  for (int y = 0; y < imagen.height; y += spacer) {
    for (int x = 0; x < imagen.width; x += spacer) {

      // obtengo el color
      float plotX = map(x, 0, imagen.width, mI, width-mD);
      float plotY = map(y, 0, imagen.height, mAr, mAr + (imagen.height * escala));
      color c = imagen.get(x, y);


      trazo(plotX, plotY, c, spacer);
    }
  }
  printCode();
  texto();
  println("Listo. Presione Ctrl + K para ver el archivo pdf");
  exit();
}

void printCode() {
  fill(#707171); // color de la letra
  float interlinea = 0;
  for (int i = 0; i < code.length; i++) {
    // escribo cada línea de código en la pantalla
    text(code[i], width/16, height/2 + 110 + interlinea);
    interlinea += 15;
  }
}

void texto() {

  fill(#000000);
  text("Génesis Morales", width - mD*5, height - mAb - 20);
  text("1 Año Arquitectura", width - mD*5, height - mAb);
}

/*TRAZO*/

void trazo(float x, float y, color c, float amp) {

  fill(c);
  int puntos = round(random(10));
  for (int i = 0; i <= puntos; i++) {
    float a = hue(c) + random(10);
    float e = saturation(c) + random(50);
    float b = brightness(c) + random(200);
    pushMatrix();
    ellipse(x, y, 10, 5);
    stroke(a, e, b);
    popMatrix();
  }
}