Created
May 5, 2018 13:30
-
-
Save gifguide2code/8aee15b6154cfd1fc7a2754c7e8c0a51 to your computer and use it in GitHub Desktop.
A sketch to get a timeline that moves forward and backward when you move the mouse.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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