Skip to content

Instantly share code, notes, and snippets.

@bmoren
Last active April 6, 2016 02:30
Show Gist options
  • Save bmoren/6db57d9bb2e6fa6525305383dddfc00a to your computer and use it in GitHub Desktop.
Save bmoren/6db57d9bb2e6fa6525305383dddfc00a to your computer and use it in GitHub Desktop.
p5js sketch to layer 1pixel per sheet of paper for depth printing
var sideA;
var depth = 500; //choose how deep to make the guillotine slit scan
function preload(){
sideA = loadImage("usd.jpg");
}
function setup() {
createCanvas(3300,2550) //300 pixels per inch 8.5x11
pixelDensity(1); //turn off pixel density so calcualtions for page size are independent of screen pixel density
textFont("Helvetica");
textSize(20);
background(255);
for(i=0;i<sideA.height;i++){
// copy(srcImage,sx,sy,sw,sh,dx,dy,dw,dh)
for(j=0;j<depth;j++){ //do a slit scan effect to add pixel depth for later guillotine cutting
copy(sideA, 0, i, sideA.width, 1, (width/2)-(sideA.width/2), j, sideA.width, 1);
}
text(i, 50, height/2) //comment out to disable text index printout
saveCanvas(i + "_layer",'jpg')
background(255);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment