2006-11-27

FUNCTION TO CONVERT COLORS

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.



2006-11-23

Updated version of the My namespace

Doug Hennig very kindly published a new version of the my namespace on the White papers and source code page of the stonefield web site.

It's a 240 k download. This version contains some fixes, a small project and a simple form showing how to use some functions.

In my tests, I installed "MY" with no errors. It works fine even without having a previous version installed, and does not need the sedna ctp to run, just vfp9. Intellisense worked perfectly, showing only the properties and methods of interest, and inside a form. The help file is nice, and contains good documentation about the more than 60 functions included.

As always, another great job from Doug.