Last active
February 4, 2019 00:33
-
-
Save nasustim/41e2206531ad77a8db8a46fab5655e08 to your computer and use it in GitHub Desktop.
Loading Animation, Generated in Processing. Depend GifMaker
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
import gifAnimation.*; | |
GifMaker gifExport; | |
void gifSetup(){ | |
gifExport = new GifMaker(this, "/Users/mitsu/Desktop/loading_animation.gif"); | |
gifExport.setRepeat(0); | |
gifExport.setQuality(10); | |
gifExport.setDelay(20); | |
} | |
void saveGifAnimation(){ | |
if(frameCount <= 50*3) | |
gifExport.addFrame(); | |
else | |
gifExport.finish(); | |
} | |
float x; | |
float y; | |
float tanh(float x){ | |
return (exp(x) - exp(-x))/(exp(x) + exp(-x)); | |
} | |
float morphingFunction(int timing){ | |
float x; | |
if(timing > 75) | |
x = timing; | |
else | |
x = 75 - (timing - 75); | |
x = radians(x * PI); | |
return (((tanh((x - 6) / 2) + 1) / 2 ) - 6 / 12); | |
} | |
float sum = 0; | |
void setup(){ | |
frameRate(50); | |
size(300, 300); | |
background(#ffffff); | |
gifSetup(); | |
} | |
void draw(){ | |
fill(#ffffff, 130); | |
stroke(#ffffff); | |
rect(0, 0, 300, 300); | |
sum += morphingFunction(frameCount); | |
x = cos(sum) * (150 - 30) + 150; | |
y = sin(sum) * (150 - 30) + 150; | |
fill(#141414); | |
circle(x, y, 40); | |
saveGifAnimation(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment