Skip to content

Instantly share code, notes, and snippets.

@behreajj
Created June 25, 2017 17:31
Show Gist options
  • Save behreajj/1195485679e8c709546e508079380ed0 to your computer and use it in GitHub Desktop.
Save behreajj/1195485679e8c709546e508079380ed0 to your computer and use it in GitHub Desktop.
Color Gradients 2-9
size(512, 512);
background(0xffffffff);
noStroke();
colorMode(HSB, 359, 99, 99);
ellipseMode(RADIUS);
textAlign(CENTER, CENTER);
int count = 16;
float centerX = width * 0.5;
float centerY = height * 0.5;
float radius = 42;
float dist = min(height, width) * 0.5 - radius;
float angle;
float hue;
float x;
float y;
float radToDeg = 360 / TWO_PI;
float countToRad = TWO_PI / float(count);
String label = "";
for (int i = 0; i < count; ++i) {
angle = i * countToRad;
hue = angle * radToDeg;
x = centerX + cos(angle) * dist;
y = centerY + sin(angle) * dist;
label = ceil(hue) + "\u00b0";
fill(color(hue, 99, 99));
ellipse(x, y, radius, radius);
fill(0xff000000);
text(label, x, y);
fill(0xffffffff);
text(label, x + 1, y - 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment