Created
August 18, 2020 00:23
-
-
Save Nekodigi/087e6edc3e04c6ddafbe5f15b59f84fc to your computer and use it in GitHub Desktop.
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
float n = 8; | |
float r; | |
void setup(){ | |
size(500, 500); | |
r = height/3; | |
strokeWeight(5); | |
} | |
void draw(){ | |
background(0); | |
stroke(255); | |
float t = constrain(float(frameCount)/50-0.3, 0, 1); | |
float t2 = constrain(float(frameCount)/50, 0, 1); | |
PVector origin = new PVector(width/2, height/2); | |
for(int i=0; i<n; i++){ | |
PVector pmax = PVector.fromAngle(map(i, 0, n, 0, TWO_PI)).mult(r).add(origin); | |
PVector p1 = PVector.lerp(origin, pmax, EaseInOutCubic(0, 1, t));println(t, t2); | |
PVector p2 = PVector.lerp(origin, pmax, EaseInOutCubic(0, 1, t2)); | |
if(t2-t>0.1)line(p1.x, p1.y, p2.x, p2.y); | |
} | |
} | |
float EaseInOutCubic(float start, float end, float t){ | |
end -= start;//calculate difference | |
return t<0.5 ? end*4*t*t*t+start : end*(4*(t-1)*(t-1)*(t-1)+1)+start; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment