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 › color: defining alpha-value with #AABBCC syntax
Page Index Toggle Pages: 1
color: defining alpha-value with #AABBCC syntax (Read 1766 times)
color: defining alpha-value with #AABBCC syntax
Apr 23rd, 2005, 10:45pm
 
Is this possible? Can i define an alphavalue to a color-variable using hexadecimal-syntax instead of RGB?

this work:
Code:
color crcol = color(140, 95, 0, 55); 



but here?
Code:
color lcol = #FF0066; //alpha?????????? 

Re: color: defining alpha-value with #AABBCC synta
Reply #1 - Apr 23rd, 2005, 11:07pm
 
you almost can, but you need to use the function "unhex", e.g.:
Code:

color hexcolor(String val)
{
return unhex(val.substring(1,7));
}

void setup()
{
size(200,200);
color c=hexcolor("#FF00FF");
background(c);
}
Re: color: defining alpha-value with #AABBCC synta
Reply #2 - Apr 23rd, 2005, 11:27pm
 
color c = unhex("FFAAFF80");
should do it, where the first two chars are the alpha value.

we debated including #colors with alpha, but decided it was too confusing in the end (does alpha go first or last? it should actually go first, but all our color functions have alpha last...) and since we'd never seen #xxxxxx syntax with alpha, we didn't want to make something up.
Re: color: defining alpha-value with #AABBCC synta
Reply #3 - Apr 23rd, 2005, 11:38pm
 
but i just recently figured out that this also works.

Code:
color crcol = 0x44775522; 



where the first two chars are the alpha and the next six are the usual #...... code.

this works for me, because i'm very into webcolors and i always have some good colors in mind using #-syntax Wink
Page Index Toggle Pages: 1