Created
June 25, 2017 17:31
-
-
Save behreajj/1195485679e8c709546e508079380ed0 to your computer and use it in GitHub Desktop.
Color Gradients 2-9
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
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