Skip to content

Instantly share code, notes, and snippets.

@behreajj
Created June 25, 2017 16:02
Show Gist options
  • Save behreajj/1b7ee46b489704dfd7d110d4561a656f to your computer and use it in GitHub Desktop.
Save behreajj/1b7ee46b489704dfd7d110d4561a656f to your computer and use it in GitHub Desktop.
Color Gradients 1-9
size(512, 256, P2D);
color start = 0xff00ffff;
color stop = 0xffff00ff;
color clear = 0x00ffff00;
float count = 64;
float centerX = width * 0.5;
float centerY = height * 0.5;
float stopRad = max(centerX, centerY) - 2.5;
float startRad = stopRad * 0.25;
float radius = startRad;
float angle;
float step;
background(0xffffffff);
noStroke();
beginShape(TRIANGLE_FAN);
for (int i = 0; i < count; ++i) {
step = i / count;
radius = lerp(startRad, stopRad, step);
angle = step * TWO_PI;
fill(i % 2 == 0 ? clear
: lerpColor(start, stop, step));
vertex(centerX + cos(angle) * radius,
centerY + sin(angle) * radius);
}
endShape(CLOSE);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment