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 representation
Page Index Toggle Pages: 1
Color representation (Read 300 times)
Color representation
Aug 12th, 2006, 5:23pm
 
Am I right in assuming the colors in processing (pixels array) are stored as a value from -1 to -16777216?

In either case, how would I convert an RGB value to the internal representation?
Re: Color representation
Reply #1 - Aug 12th, 2006, 8:49pm
 
Nope.
Code:

int a = color(0);
int b = color(255, 255, 255);
println(a);
println(b);
background(a);

Also see fjen's color snippet for a more concise view of how color is calculated.

http://snippet.seltar.org/index.php?pid=3&sid=10
Page Index Toggle Pages: 1