Making a color wheel with Processing
in
Programming Questions
•
3 months ago
Hello again,
I am trying to create a colour wheel which displays the selected (mouse clicked) colour in a box to the right using
Processing. I was told that I should build a clock, and then solve for the mouse point using theta.
I am looking for some advice, constructive criticism and discussion on how to go about building this program.
How would I go about allowing users to select mono or complement colours?
Ideally it should look something like this.
I have the code for a clock interface but I'm not sure how to implement the colours into it.
//clock code
void setup() {
size(500, 500);
}
void draw() {
background(255);
// get the current time
int s = second(); // values from 0 - 59
int m = minute(); // values from 0 - 59
int h = hour(); // values from 0 - 23
// move origin to center of the screen
translate(250, 250);
// draw the seconds hand
pushMatrix();
rotate(radians(map(s, 0, 59, 0, 360)));
stroke(255, 0, 0);
strokeWeight(1);
line(0, 0, 0, -225);
popMatrix();
// draw the minutes hand
pushMatrix();
rotate(radians(map(m + s / 60.0, 0.0, 60.0, 0.0, 360.0)));
stroke(0, 0, 255);
strokeWeight(5);
line(0, 0, 0, -200);
popMatrix();
// draw the hours hand
pushMatrix();
if (h > 12) h -= 12;
rotate(radians(map(h + m / 60.0, 0.0, 24, 0.0, 360.0)));
strokeWeight(5);
stroke(0, 255, 0);
line(0, 0, 0, -100);
popMatrix();
// "button" at the center
fill(0);
noStroke();
ellipse(0, 0, 15, 15);
}
//Thanks for your wonderful help,
//turnedbarley
1