Tomás Valladares juego de formas tarea 9
De Casiopea
Título | juego de formas trazo |
---|---|
Tipo de Proyecto | Proyecto de Curso |
Palabras Clave | tarea 8 |
Asignatura | Imagen Escrita 2012, |
Del Curso | Imagen Escrita 2012, |
Carreras | Arquitectura |
Alumno(s) | Tomás Valladares Vergara |
Profesor | Herbert Spencer |
/* Imagen Escrita 2012: Construcción de un trazo (algoritmo pictórico de la luz y el color) */ import processing.pdf.*; PImage mono; // la foto: el encuadre, la escena, el paisaje PFont font; // la fuente tipográfica String[] code; // el texto del código /* Al exportar un PDF, Processing translada las unidades de pixeles a puntos tipográficos. 1 pt = 0.0352778 cm 1 cm = 28.346438837 pt */ float margenIzquierda = 100; float margenArriba = 80; float margenDerecha = 100; float margenAbajo = 400; float escala; void setup() { colorMode(HSB,100);// declaro nuevo modo de color hsb mono = loadImage("monito.jpg"); // se carga la imagen, se "construye" el objeto PImage mono size(609, 765,PDF,"mandril.pdf"); // tamaño carta smooth(); // cálculos para escalar desde la imagen hacia el pincel float ancho = width - (margenIzquierda + margenDerecha); escala = ancho/(float)mono.width; noStroke(); noLoop(); background(0,1,99); font = createFont("Courier", 8); // construyo la tipografía a partir de una fuente de sistema textFont(font, 4); code = loadStrings("trazo.pde"); // cargo el código "trazo" (el pincel) } void draw() { float spacer = 14; // este valor debe variar en relacion al tamaño y la cantidad de pixeles de la foto // muestreo regular desde la foto, esto se puede modificar.... for (int y = 0; y < mono.height; y += spacer) { for (int x = 0; x < mono.width; x += spacer) { // obtengo el color float plotX = map(x, 0, mono.width, margenIzquierda, width-margenDerecha); float plotY = map(y, 0, mono.height, margenArriba, margenArriba + (mono.height * escala)); color c = mono.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++) { // escribo cada línea de código en la pantalla text(code[i], width/4, 2 * margenArriba + mono.height * escala + interlinea); interlinea += 15; } } //--------------------------------- TRAZO----------------------------- /* Trazo Pictórico tomás valladares*/ void trazo(float x, float y, color c, float amp) { float r=red(c); // obtengo valores en los 3 colores rgb float v=green(c); float a=blue(c); float h = hue(c); // obtento los valores HSB para poder crear variaciones de relleno float s= saturation(c); float b = brightness(c); //fill(h+30, s, b); // construyo triangulos con cierta variacion de color // triangle(x, y, x+2, y+4, x-2, y+4); if(h>0 && h<33.3) { pushMatrix(); //empujo la matriz para translate(x, y); rotate(radians(random(0,45))); scale(map(b, 0, 255, 3.00, 3.60)); // mapeo un promedio de color rgb, y luego eso lo escalo // entre el 50% (0.50)y el 100% (1.00) de la forma forma(h, s+9, b+10); popMatrix(); } else if (hue(c)>=33.3 && hue(c)<66.6){ pushMatrix(); translate(x, y); rotate(radians(random(0,78))); scale(map(b, 0, 255, 2.00, 3.00)); forma2(h,s+6,b+23); popMatrix(); } else{ pushMatrix(); translate(x, y); rotate(radians(random(0,80))); scale(map(b, 0, 255, 2.00, 1.00)); forma3(h,s+5,b+15); popMatrix(); }} void forma(float h, float s, float b) { fill(h, s, b); noStroke(); beginShape(); vertex(9, 12.45); vertex(4, 12); vertex(5.61, 9.92); vertex(1.53, 9.51); vertex(4.52, 5.94); vertex(3.16, 2.68); vertex(5.52, 0.46); vertex(5.92, 0.46); endShape(CLOSE); } void forma2(float h, float s, float b) { fill(h, s, b); noStroke(); beginShape(); vertex(11.35, 7); vertex(8.7, 9.7); vertex(6.3, 11); vertex(3, 9); vertex(9, 7); vertex(2, 5); vertex(8.3, 2); vertex(11, 4); endShape(CLOSE); } void forma3(float h, float s, float b) { fill(h, s, b); noStroke(); beginShape(); vertex(4.6,10); vertex(2,7.7); vertex(1.6,5.62); vertex(2.5,3); vertex(5.3,1.62); vertex(7.6,2); vertex(9,6.5); vertex(9.7,9.7); vertex(10.3,12.6); vertex(7.3,9.4); vertex(8.2,12.2); vertex(4,12.4); endShape(CLOSE); }