const WHITEÂÃ, = 0xFFFFFF;
const BLACKÂÃ, = 0x000000;
const REDÂÃ, Ã‚Ã, Ã‚Ã, = 0x0000FF;
const GREEN = 0x00FF00;
const BLUEÂÃ, Ã‚Ã, = 0xFF0000;
const YELLOW = RED|GREEN; // this works
const GRAY = RGB(127,127,127); //this doesn't
Are calculated constants something for the future?
RGB is a function whose return is a variable.
RGB = r | g << 8| b<<16
So you could do
const gray = 127 | 127 << 8 | 127 << 16;
Paul.
That works. Paranthesis make it easier to read:ÂÃ, Ã‚Ã, ;>)
const gray = 127 | (127 <<ÂÃ, 8) | (127 << 16);
(One needs to turn smilies "off" to get this right.)
I think I should know better. Aren't constants defined during compilation and RGB() returns a value at runtime?
Yes, all functions' values are determined at runtime, while constants are resolved at compile time. If RGB was a macro, you'd be able to do what you were saying.