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 › Trouble getting color(hex, alpha) working in 1.01
Page Index Toggle Pages: 1
Trouble getting color(hex, alpha) working in 1.01 (Read 205 times)
Trouble getting color(hex, alpha) working in 1.01
Dec 12th, 2008, 1:36am
 
I don't know if it's a bug or not, but I cannot get color(hex, alpha) to work.  

color(#068e00) renders the correct color.
color(#068e00, 255) renders black.
color(#068e00, 0) renders black.
color(#068e00, 125) renders gray.

This also works:
color a = #068e00;
color(red(a), green(a), blue(a), 125);

Is this a bug or am I doing something wrong?

Thanks
Re: Trouble getting color(hex, alpha) working in 1
Reply #1 - Dec 12th, 2008, 10:56am
 
Looks like it never worked... I still have 0135 and it doesn't work there either.
Test:
Code:
/*
void setup()
{
size(400, 400);
noStroke();
noLoop();
fill(color(0xBB2288FF));
ellipse(300, 200, 150, 200);
fill(color(0x802288FF));
ellipse(200, 200, 150, 200);
fill(color(0x402288FF));
ellipse(100, 200, 150, 200);
}
*/
//*
void setup()
{
size(400, 400);
noStroke();
noLoop();
color c = #2288FF;
// or int c = 0x2288FF;
// also tested with 0xFF2288FF and even 0x002288FF
fill(color(c, 0xEE));
ellipse(300, 200, 150, 200);
fill(color(c, 0x80));
ellipse(200, 200, 150, 200);
fill(color(c, 0x40));
ellipse(100, 200, 150, 200);
}
//*/

Commented out setup routine works, not the bottom one.
You should fill in a bug in the Contribute section of the site.
Page Index Toggle Pages: 1