fluxkompensator - 25. Feb, 15:11
import processing.opengl.*;
import processing.pdf.*;
//SimplePostscript ps;
int gap; //space in between lines
int num_lines;
float z_value;
PImage img;
float value;
color[] myarr;
boolean dosave=true;
void setup(){
size(2300, 2300, OPENGL); //if you change this arange new canvas rotation
background(0);
strokeWeight(2);
noLoop();
//frameRate(30); //if you use mouse input for viewport
gap = 10; // line spacing
z_value = 25; // height of elevation
num_lines = floor(height/gap);
//place this flie in the data directory in the script folder
PImage img = loadImage("ovi_lines2.jpg"); //best if you have same size, use nice gausian blur
image(img, 0, 0);
loadPixels();
//filter(GRAY);
//filter(BLUR,100); //leftovers from attempts using processing also for the blur. Type relevant code was removed.
myarr= new color[pixels.length]; //this may not be necessary
arraycopy(pixels, myarr); // copy buffer to new array
for (int i=0; i <(width*height) -1; i++){ // store brightness values in new array
float brg = brightness(pixels[i]); // part of the magic, reading values
//float brg = 0.30 * r + 0.59 * g + 0.11 * b ;
myarr[i] = abs ((int) brg);
}
}
void draw(){
if(dosave) {
PGraphicsPDF pdf=(PGraphicsPDF)beginRaw(PDF, "pdf_out.pdf");
// set stroke styles and paint background rect.
pdf.strokeJoin(MITER);
pdf.strokeCap(SQUARE);
pdf.fill(0);
pdf.noStroke();
pdf.rect(0,0, width,height);
}
background(0);
stroke(255);
strokeWeight(1);
fill(0);//interesting effect if you do not fill shapes ;)
smooth();
pushMatrix();
translate(width/2, height/2);
//rotateX(map(mouseX,0, width, 0, PI/2)); // test realtime what effect you like
rotateX(PI/6); //final settings for viewpoint
rotateZ(-PI/120);
//rotateZ(map(mouseY, 0, height, 0, PI/2));
scale(2);
translate(-width/4,-height/2);
for (int i=0; i < num_lines; i++){ // y resolution
beginShape();
for ( int j=0; j < width; j++){ // x resolution
//color c = pixels[i*width+j]; //experiment with color variations based on location
value = map (myarr[i*gap*width+j], 0, 255, 0, z_value);
vertex(j, i*gap, value); //other primitives also work bezier vertex.
// if (j == 0) ps.moveto(j, i*gap);
// else ps.lineto(j, i*gap);
}
endShape();
}
popMatrix();
save("ovi_lines.tif"); //bitmap
if(dosave) {
endRaw();
dosave=false;
}
}
void keyPressed() {
if(key=='s') dosave=true;
}
fluxkompensator - 23. Feb, 18:01
fluxkompensator - 22. Feb, 13:49
fluxkompensator - 22. Feb, 02:30
fluxkompensator - 21. Feb, 16:13
fluxkompensator - 21. Feb, 10:47
Strahlen, Konstruktivismus, Futurismus,...
fluxkompensator - 17. Feb, 11:26
alles rein da! :)
fluxkompensator - 17. Feb, 03:41
fluxkompensator - 13. Feb, 11:31