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 › How to get the color()  values
Page Index Toggle Pages: 1
How to get the color()  values (Read 253 times)
How to get the color()  values
Jul 28th, 2008, 4:38am
 
How to get the color() method  values ,and print the three values.
Re: How to get the color()  values
Reply #1 - Jul 28th, 2008, 6:47am
 
color c = color(random(255),random(255),random(255),random(255));

float r = red(c);
float g = green(c);
float b = blue(c);
float a = alpha(c);

// OR

int alpha = ( c >> 24 ) & 0xFF;
int red   = ( c >> 16 ) & 0xFF;
int green = ( c >> 8 )  & 0xFF;
int blue  =   c         & 0xFF;
Re: How to get the color()  values
Reply #2 - Jul 28th, 2008, 8:10am
 
Thank you very much!
Page Index Toggle Pages: 1