We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › a color palette in my program
Poll Poll
Question: can I put a color pallete in my program?



« Created by: Bossa on: Apr 21st, 2010, 4:01pm »

Page Index Toggle Pages: 1
a color palette in my program? (Read 674 times)
a color palette in my program?
Apr 21st, 2010, 4:01pm
 
i am currently working on a text viewer and want the user to be able to choose the text color from a box like the one found in paint, can anybody give me a way to it?? plz
Re: a color palette in my program?
Reply #1 - Apr 21st, 2010, 7:02pm
 
like this?:
Code:

int h=0, s=255,v=255;

void setup() {
 size(350,256);
 colorMode(HSB);
 for(int y=0; y < 256; y++)
   for(int x=0; x < 256; x++)
   {
     stroke(x,y,127);
     point(x,y);
   }
 fill(h,s,v);
 noStroke();
 rect(310,0,40,height);
}




void draw() {
 for(int y=0; y < 256; y++) {
   stroke(h,s,y);
   line(270,y,300,y);
 }
 if(mousePressed){
   if(mouseX<256 && mouseY<256) {
     h = mouseX;
     s = mouseY;
   }
   else if(mouseX > 270 && mouseX < 300)
     v = mouseY;
   println("h: "+h+", s: "+s+" v: "+v);
   fill(h,s,v);
   noStroke();
   rect(310,0,40,height);
 }
}
Page Index Toggle Pages: 1