Created
April 30, 2012 17:40
-
-
Save pigeonflight/2560367 to your computer and use it in GitHub Desktop.
my processing thing
This file contains 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
/** | |
* Subtractive Color Wheel | |
* by Ira Greenberg. | |
* | |
* The primaries are red, yellow, and blue. The secondaries are green, | |
* purple, and orange. The tertiaries are yellow-orange, red-orange, | |
* red-purple, blue-purple, blue-green, and yellow-green. | |
* | |
* Create a shade or tint of the subtractive color wheel using | |
* SHADE or TINT parameters. | |
* | |
* Updated 26 February 2010. | |
*/ | |
int segs = 12; | |
int steps = 6; | |
float rotAdjust = TWO_PI / segs / 2; | |
float radius; | |
float segWidth; | |
float interval = TWO_PI / segs; | |
int counter = 20; | |
int count = 0; | |
int yval = 0; | |
int xval = 0; | |
void setup() { | |
size(200, 200); | |
background(127); | |
smooth(); | |
ellipseMode(RADIUS); | |
noStroke(); | |
frameRate(30); | |
// make the diameter 90% of the sketch area | |
radius = min(width, height) * 0.45; | |
segWidth = radius / steps; | |
// swap which line is commented out to draw the other version | |
//drawTintWheel(); | |
drawShadeWheel(yval,200); | |
} | |
void draw(){ | |
radius = min(50,50) * 0.45; | |
count = (count+1); // Use % to cycle through frames | |
if (count%200 == 0) { | |
count = 0; | |
yval = yval + 50; | |
} | |
xval = count; | |
drawShadeWheel(yval,xval); | |
} | |
void drawShadeWheel(float argx, float argy) { | |
for (int j = 0; j < steps; j++) { | |
color[] cols = { | |
color(255-(255/steps)*j, 255-(255/steps)*j, 0), | |
color(255-(255/steps)*j, (255/1.5)-((255/1.5)/steps)*j, 0), | |
color(255-(255/steps)*j, (255/2)-((255/2)/steps)*j, 0), | |
color(255-(255/steps)*j, (255/2.5)-((255/2.5)/steps)*j, 0), | |
color(255-(255/steps)*j, 0, 0), | |
color(255-(255/steps)*j, 0, (255/2)-((255/2)/steps)*j), | |
color(255-(255/steps)*j, 0, 255-(255/steps)*j), | |
color((255/2)-((255/2)/steps)*j, 0, 255-(255/steps)*j), | |
color(0, 0, 255-(255/steps)*j), | |
color(0, 255-(255/steps)*j, (255/2.5)-((255/2.5)/steps)*j), | |
color(0, 255-(255/steps)*j, 0), | |
color((255/2)-((255/2)/steps)*j, 255-(255/steps)*j, 0) | |
}; | |
for (int i = 0; i < segs; i++) { | |
fill(cols[i]); | |
arc(argx, argy, radius, radius, | |
interval*i+rotAdjust, interval*(i+1)+rotAdjust); | |
} | |
radius -= segWidth; | |
} | |
} | |
void drawTintWheel() { | |
for (int j = 0; j < steps; j++) { | |
color[] cols = { | |
color((255/steps)*j, (255/steps)*j, 0), | |
color((255/steps)*j, ((255/1.5)/steps)*j, 0), | |
color((255/steps)*j, ((255/2)/steps)*j, 0), | |
color((255/steps)*j, ((255/2.5)/steps)*j, 0), | |
color((255/steps)*j, 0, 0), | |
color((255/steps)*j, 0, ((255/2)/steps)*j), | |
color((255/steps)*j, 0, (255/steps)*j), | |
color(((255/2)/steps)*j, 0, (255/steps)*j), | |
color(0, 0, (255/steps)*j), | |
color(0, (255/steps)*j, ((255/2.5)/steps)*j), | |
color(0, (255/steps)*j, 0), | |
color(((255/2)/steps)*j, (255/steps)*j, 0) | |
}; | |
for (int i = 0; i < segs; i++) { | |
fill(cols[i]); | |
arc(width/2, height/2, radius, radius, | |
interval*i+rotAdjust, interval*(i+1)+rotAdjust); | |
} | |
radius -= segWidth; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment