Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Moving through a sepia color set, from dark to light ?
Message
From
29/05/2010 23:59:02
 
 
To
28/05/2010 15:47:48
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01466438
Message ID:
01466548
Views:
84
This message has been marked as the solution to the initial question of the thread.
>Hi,
>
>I am looking for a way to programmatically deliver a set of sepia-based colors.
>
>Assuming I have a base sepia color, say RGB(112,66,20), I can try something like GETCOLOR(RGB(112,66,20)) and move through various tones from DARK sepia to LIGHT with the Windows color box. How can I replicate that in code ?
>
>Sure, that must be something someone among the UT has bumped into whilst coding an graphical application:)
>
>It may be simple but I am stuck at this stage!

When you do GETCOLOR(RGB(112,66,20)), and you expand the dialog, I assume when you say "move through various tones from DARK sepia to LIGHT" you mean using the slider in the right side.

In the bottom right, you have 6 textboxes. The 3 on the right give you the values of RGB in the RGB color space, the ones in the left give you the values of HSL in the HSL color space.

Now move the slider up and down, and notice that in the HSL color space, only the L value changes. Congratulations, you have just discovered the wonders of the HSL color space.

You only need to functions, to go from RGB to HSL and back.

*!* _apiColorHLSToRGB
Lparameters wHue, wLuminance, wSaturation

Declare Integer ColorHLSToRGB In shlwapi.Dll As _apiColorHLSToRGB ;
short wHue, ;
short wLuminance, ;
Short wSaturation

Return _apiColorHLSToRGB(m.wHue, m.wLuminance, m.wSaturation)

*!* _apiColorRGBToHLS
Lparameters clrRGB, pwHue, pwLuminance, pwSaturation

Declare ColorRGBToHLS In shlwapi.Dll As _apiColorRGBToHLS ;
Integer clrRGB,;
Short @pwHue,;
Short @pwLuminance,;
Short @pwSaturation

Return _apiColorRGBToHLS(clrRGB, @pwHue, @pwLuminance, @pwSaturation)

NOTE: HSL in Windows API has the following ranges: H: 0-360, S: 0-240, L: 0-240

These may help too:

*!* ctlRgbGetR
Lparameters pnRgbColor
Return Bitrshift(Bitand(m.pnRgbColor, 0x0000FF), 0)

*!* ctlRgbGetG
Lparameters pnRgbColor
Return Bitrshift(Bitand(m.pnRgbColor, 0x00FF00), 8)

*!* ctlRgbGetB
Lparameters pnRgbColor
Return Bitrshift(Bitand(m.pnRgbColor, 0xFF0000), 16)

Also you can check this out:
http://www.ctl32.com.ar/ctl32_colorpicker.asp
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform