Valeria Contreras, tarea 8

De Casiopea
Trazo impresionista


TítuloTrazo impresionista
Tipo de ProyectoProyecto de Curso
Palabras Clavetarea 8
Período2012-
AsignaturaTaller Inicial Común 1ª y 2ª Etapa,
Del CursoImagen Escrita 2012,
CarrerasDiseño Gráfico"Diseño Gráfico" is not in the list (Arquitectura, Diseño, Magíster, Otra) of allowed values for the "Carreras Relacionadas" property., Diseño Industrial"Diseño Industrial" is not in the list (Arquitectura, Diseño, Magíster, Otra) of allowed values for the "Carreras Relacionadas" property.
Alumno(s)Valeria Contreras
ProfesorHerbert Spencer

import processing.pdf.*;

PImage cafe; PFont font; String[] code;

float margenIzquierda = 30; float margenArriba = 20; float margenDerecha = 20; float margenAbajo = 20; float escala;

void setup() {

 cafe = loadImage("cafe.jpg"); // al cargar la imagen se construye el objeto PImage c
 size(609, 765, PDF, "cafe.pdf"); // hoja tamaño carta
 // desde la imagen al pincel
 float ancho = width - (margenIzquierda + margenDerecha);
 escala = ancho/(float)cafe.width;
 noStroke();
 noLoop();
 background(255);
 font = createFont("Courier", 6); // construcción de la tipografía desde una fuente de sistema
 textFont(font, 6);
 code = loadStrings("trazo.pde"); // se carga el código trazo, que construye el pincel

}


void draw() {

 float spacer = 12;
 // muestreo regular desde la foto (modificable)
 for (int y = 0; y < cafe.height; y += spacer) {
   for (int x = 0; x < cafe.width; x += spacer) {
     // obtención del color
       float plotX = map(x, 0, cafe.width, margenIzquierda, width-margenDerecha);
     float plotY = map(y, 0, cafe.height, margenArriba, margenArriba + (cafe.height * escala));
     color c = cafe.get(x, y);
     trazo(plotX, plotY, c, spacer);
   }
 }
 printCode();
 println("---->PDF done!");
 exit();

}


void printCode() {

 float interlinea = 0;
 for (int i = 0; i < code.length; i++) {
   // cada linea de código escrita en la pantalla
   text(code[i], width/4, 2 * margenArriba + cafe.height * escala + interlinea);
   interlinea += 15;
 }

}


/***************************** trazo ******************************/


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

 fill(c);
 ellipse(x, y, map(brightness(c), 0, 255, ramdom, 0), 
 map(brightness(c), 0, 255, ramdom, 0));

}