Last active
December 28, 2018 22:29
-
-
Save timcowlishaw/ee6e5adfb9be24e64f12861fb7af2456 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 t = 0; | |
float r = 50.0; | |
float r2 = 400.0; | |
float k1 = 10 * exp(1); | |
float k2 = 0.1 * PI; | |
float x; | |
float y; | |
float offsetX = 500; | |
float offsetY = 500; | |
color from; | |
color to; | |
float fromOpacity = 60.0; | |
float toOpacity = 0; | |
float opacityCycleOffset = 0.05; | |
float colourCycleOffset = 0.0; | |
void setup() { | |
size(1000, 1000); | |
colorMode(HSB); | |
from = color(120, 255, 255); | |
to = color(180, 255, 255); | |
background(0, 0, 255); | |
stroke( | |
lerpColor(from, to, ((k1*t)/(2*PI+colourCycleOffset))%1), | |
lerp(fromOpacity, toOpacity, ((k1*t)/(2*PI+opacityCycleOffset))%1) | |
); | |
x = offsetX + r * cos(t * k1) + r2 * cos(t * k2); | |
y = offsetY + r * sin(t * k1) + r2 * sin(t * k2); | |
} | |
void draw() { | |
stroke( | |
lerpColor(from, to, ((k1*t)/(2*PI+colourCycleOffset))%1), | |
lerp(fromOpacity, toOpacity, ((k1*t)/(2*PI+opacityCycleOffset))%1) | |
); | |
float x_ = offsetX + r * cos(t * k1) + r2 * cos(t * k2); | |
float y_ = offsetY + r * sin(t * k1) + r2 * sin(t * k2); | |
line(x, y, x_, y_); | |
x = x_; | |
y = y_; | |
t++; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment