/*
* circulate
* by Matt Katz
* after I saw this http://butdoesitfloat.com/2280711/Turn-Turn-Turn
* I wanted to do it.
* The source image kindle provided by Gordon Griffiths [CC-BY-SA-2.0], via Wikimedia Commons
*
*/
PImage source;
PImage table;
PImage img;
PImage maskImg;
boolean render;
boolean showOriginal;
int bands;
int bandWidth;
int bandSpace;
float bandTwist;
ScrollPanel panel;
int cX, cY;
void setup(){
//size(403,603);
String file = "Oatenfields_Pasture_-_geograph.org.uk_-_443325.jpg";
source = loadImage(file);
img = loadImage(file);
//comment out the previous size and uncomment this
//if you are playing with various photos in
//processing ide
size(source.width, source.height);
//print(source.width);
//print (source.height);
background(source);
smooth();
render = true;
showOriginal = true;
bands = 12;
bandWidth = 60;
bandSpace = 8;
panel = new ScrollPanel(4);
//panel.addBar("bands", 0,20,width,10,16,width);
panel.addIBar("Bands", 12);
panel.addIBar("Width",100);
panel.addIBar("Space", 50);
panel.addBBar("Twist",30);
cX = width/2;
cY = height/2;
}
void keyPressed(){
println("pressed " + key);
if(key == 'g'){
render = !render;
if(render){background(255);}else{background(source);}
println("render is " + render);
}
}
void draw(){
//panel.displayScrolls();
//info("1");
panel.updateScrolls();
if(panel.overScrolls()){
panel.displayScrolls();
}
else if(mousePressed){
showOriginal = !showOriginal;
render = true;
}
if(render){
if(showOriginal){
revertBack();
}
else{
background(source);
makePic(mouseX, mouseY);
if(! online){
saveFrame("seriousbusiness-####.jpg");
}
}
render = false;
}
}
void updateValuesFromPanel(){
bands = (int)panel.getVal("Bands");
bandWidth = (int)panel.getVal("Width");
bandSpace = (int)panel.getVal("Space");
bandTwist = panel.getVal("Twist");
}
void revertBack(){
background(source);
}
void makePic(int mX, int mY ){
updateValuesFromPanel();
int startWidth = width * bandWidth/100;
for(int band = 0; band