Donny Ahumada, tarea 8

De Casiopea
Tarea 8, pincel según gama


TítuloTarea 8, pincel según gama
Tipo de ProyectoProyecto de Curso
Palabras Clavetarea 8
AsignaturaImagen Escrita 2012,
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)Donny Ahumada
ProfesorHerbert Spencer

import processing.pdf.*;

PImage bleh; // se llama a la Foto PFont typo; // se crea la fuente String[] brush; // se crea un string para guardar el texto

// se dan margenes de 1,5 cm en izquierda y derecha, y de 2 cm arriba y abajo. float martop = 56.7; float marleft = 42.5; float marright = 42.5; float marbottom = 56.7; float escalar;

void setup() {

 bleh = loadImage("bleh.jpg");  // se carga (llama) a la imagen 
 size (609, 765, PDF, "Final.pdf"); // se contruye el tamaño carta
 float ancho = width - (marleft + marright); //se calcula el ancho total que tendra la imágen
 escalar = ancho/(float)bleh.width; // se crea el calculo del factor para escalar 
 
 noStroke();
 noLoop();
 background(255);  // fondo blanco
 
 typo = createFont ("Helvetica-Normal-48", 9);  // se crea el tipo de fuente y el tamaño
 textFont(typo, 9);
 
 brush = loadStrings("pincel.pde"); // se crea y guarda el texto del codigo en pincel.pde

}

void draw () {

 colorMode(RGB);
 float spacer = 16;   // se delimita el espacio entre pincelada
 for (int x=0; x < bleh.width; x += spacer)  // se crea el for que recorrera la imágen
 {
   for (int y=0; y < bleh.height; y += spacer)
   {
     float resizX = map (x, 0, bleh.width, marleft, width-marright);
     float resizY = map (y, 0, bleh.height, martop, martop + (bleh.height * escalar));
     color c = bleh.get (x, y);
  
  if (x < (bleh.width)/2)    // se condiciona para separar el que será invertido en color
   {   
     pincel(resizX, resizY, c, spacer);
   }
   if (x >= (bleh.width)/2)  // se condiciona para el que no será invertido
   {
     pincel2(resizX, resizY, c, spacer);
   }
   }
   
 }
 
 
 
 hacerPDF();  // se llama a la función que imprime el texto del void pincel
 println("PDF hecho!"); // aviso de que el pdf se realizó
 exit(); // salida

}

// se crea la función que recorrera el string que guarda el texto de pincel.pde y luego se escribe en text void hacerPDF() {

 fill(0);
 float entrelinea = 0;
 for (int w = 0; w < brush.length; w++)
 {
   text (brush[w], marleft*2, 2 * martop + bleh.height * escalar + entrelinea);
   entrelinea += 11;
 }

}

// Función que invetirá los colores de la imágen. void pincel (float x, float y, color c, float amp) {

 // cálculo de inversión de colore RGB.
 float r = red(c);
 float g = green(c);
 float b = blue(c);
 r = 255 - r;
 g = 255 - g;
 b = 255 - b;
 fill (r,g,b);
 // el cuadrado será más pequeño dependiendo del lugar que ocupe en la gama de colores.
 rect (x, y, map(hue(c), 0, 255, 0, 5), map(hue(c), 0, 255, 0, 5)); 

}

// Función que no invierte los colores de la imágen. void pincel2 (float x, float y, color c, float amp) {

 fill (c);
 rect (x, y, map(hue(c), 0, 255, 0, 5), map(hue(c), 0, 255, 0, 5));

}