The short function below converts any color to its darker or brighter version, just as the original colorpicker slidebar.
Parameters:
RGB - original RGB value to convert
tnLevel - ranges from -100 to + 100. Zero means no changes; +100 = White; -100 = Black; Positive values will return brighter images, while negative will bring darker.
LPARAMETERS tnRGB, tnLevel
IF tnLevel = 0
RETURN tnRGB
ENDIF
tnLevel = tnLevel / 100
LOCAL lnRed, lnGreen, lnBlue
lnRed = BITAND(tnRGB, 0x000000FF)
lnGreen = BITRSHIFT(BITAND(tnRGB, 0x0000FF00), 8)
lnBlue = BITRSHIFT(BITAND(tnRGB, 0x00FF0000), 16)
IF tnLevel > 0
RETURN RGB( ;
lnRed + ((255 - lnRed) * tnLevel) , ;
lnGreen + ((255 - lnGreen) * tnLevel) , ;
lnBlue + ((255 - lnBlue) * tnLevel) )
ELSE
RETURN RGB( ;
lnRed + (lnRed * tnLevel) , ;
lnGreen + (lnGreen * tnLevel) , ;
lnBlue + (lnBlue * tnLevel) )
ENDIF
To better understand how it works, you can download the attached file, that contains a simple example. Click on "Select Color" to pick a color then play with the spinner to see the darker and brighter resulting colors.
