Skip to content

Instantly share code, notes, and snippets.

@behreajj
Last active June 25, 2017 23:22
Show Gist options
  • Save behreajj/cc1d9c9de3f63d437be35523625994bb to your computer and use it in GitHub Desktop.
Save behreajj/cc1d9c9de3f63d437be35523625994bb to your computer and use it in GitHub Desktop.
Color Gradients 1-4
color blue = 0xff0000ff;
color magenta = 0xffff00ff;
color red = 0xffff0000;
color yellow = 0xffffff00;
color startc;
color stopc;
float margin = 32;
float left = margin;
float right;
float top = margin;
float bottom;
float horizchange;
float step = 1;
float clrstep;
float horizfreq = 0.033;
float clrfreq = 0.05;
void setup() {
size(512, 256);
right = width - margin;
bottom = height - margin;
}
void draw() {
step = map(mouseY, 0, height, 1, 7);
clrstep = cos(frameCount * clrfreq) * 0.5 + 0.5;
startc = lerpColor(red, yellow, clrstep);
stopc = lerpColor(blue, magenta, clrstep);
background(0xffffffff);
for (float i = top, fcnti; i <= bottom; i += step) {
fcnti = frameCount + i;
horizchange = cos(fcnti * horizfreq) * margin;
stroke(lerpColor(startc, stopc, (i - top) / (bottom - top)));
line(left + horizchange, i,
right + horizchange, i);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment