|
ok, ok - you made it look too easy - let me give you entire spec ...
This is going to be used in a FadeToBlack() UDF ... FadeToBlack() takes a number (a hex number) in the BBGGRR format above, and a second parameter called "level" that is a number from 0 to 255 (0 to FF) ... you call it like this:
$color = FadeToBlack($color, 200)
Here's what FadeToBlack should do. Compare each color component (0-FF) with "level" ... if the color component is less than level, leave it alone. If the color component is equal to or greater than level - set the color component to equal level. Then "reassemble" the color components back into a BBGGRR color, for example:
$color = &00DDFF $color = FadeToBlack($color, &EE)
color should now be: &00DDEE. Then when you call it again, using the new value of color and a new value for level,
$color = &00DDEE $color = FadeToBlack($color, &DD)
color should now be &00DDDD
and again:
$color = &00DDDD $color = FadeToBlack($color, &CC)
color will be &00CCCC and so on and so on. The level parm will always be a value from 0 to FF (255) ... under no circumstances should a negative BBGGRR color be returned ...
|