Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A sketch to get a timeline that moves forward and backward when you move the mouse.
int year = 0;
int y = 0;
int spacing = 50;
void setup(){
size(500,800);
background(0);
textSize(25);
fill(255,255,255);
for (int i = year; i<2018; i=i+25){
text(i, 10, y+25);
y = y + spacing;
}
}
void draw(){
}
void mouseMoved(){
int x = 0;
y = 10;
if (mouseY>750 && year<1950){
year = year + 25;
y=0;
background(0);
fill(255,255,255);
for (int i = year; i<2018; i=i+25){
print(year + " ");
if(i<0) {
text(abs(i) + " BC", 10, y+25);
} else {
text(abs(i), 10, y+25);
}
x = x+25;
y = y +spacing;
}
}
if (mouseY<50 && year>-5000){
y=0;
year = year - 25;
background(0);
for (int i = year; i<2018; i=i+25){
print(year + " ");
if(i<0) {
text(abs(i) + " BC", 10, y+25);
} else {
text(abs(i), 10, y+25);
}
x = x+25;
y = y+spacing;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.