In my code i usually use Math.min and Math.max. It does take more lines, but 
the intent is obvious and the code is readable.

You can play with OR'ing three AND'ed expressions. Each AND expression handles 
a specific color channel, using the shifted value as the base and shifted mask. 
Something like

r << 16 && 255 << 16 (for red)
g << 8 && 255 << 8 (for green)
b && 255 (for blue)

Then, the result would be

255 << 24 | (r << 16 && 255 << 16) | (g << 8 && 255 << 8) | (b && 255)

It is shorter but not necessarily easier to understand without comments.
[Message sent by forum member 'kirillcool' (kirillcool)]

http://forums.java.net/jive/thread.jspa?messageID=230872

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to