int start = 24;
int end = 80;
int index = start;
int beginTijd = 120;
int eindTijd = 400;
int mapY = 89;
int mapY2 = 720;
int mapH = mapY2-mapY;
float sc = 1;
PVector prev;
PImage bg;
void setup() {
background(255);
size(1259,809);
textFont(loadFont("Serif-18.vlw"));
bg = loadImage("history0001.png");
}
void draw() {
String filename = "NetherlandsThroughTime"+nf(index,4)+".jpg";
println(filename);
PImage img = loadImage(filename);
PVector nl = getNL(img);
image(bg,0,mapY,img.width*sc,mapH*sc);
tint(255,100);
image(img,0,0,img.width*sc,img.height*sc);
//set(0,20,img.get(0,height-50,width,50));
//nl = new PVector(img.width/2,mapY2);
noStroke();
fill(255,0,0);
ellipse(nl.x*sc,nl.y*sc,4,4);
stroke(0);
fill(0);
int jaar = (int)map(index,start,end,beginTijd,eindTijd);
nl.x = map(nl.x, 0.0, img.width, 0, 1);
nl.y = map(nl.y, mapY, mapY2, 0, 1);
nl.x = int(nl.x*10000)/10000.0;
nl.y = int(nl.y*10000)/10000.0;
text("jaar = " + jaar + "\nx = " + nl.x + "\ny = " + nl.y,10,20);
}
void keyPressed() {
if (keyCode==LEFT) index--;
if (keyCode==RIGHT) index++;
if (index<start) index=start;
if (index>end) index=end;
}
PVector getNL(PImage img) {
for (int y=0; y<height; y++) {
for (int x=0; x<width; x++) {
color c = img.get(x,y);
if (brightness(c)<1) return new PVector(x-3,y+8);
}
}
return new PVector();
}