Re: [RESOLVED] My Potions are too strong for you Traveller. Cairo Hue Shift?
Argen, you can do "anything" with RGB. It's just not necessarily as easy as it is with HSL. That was my point in saying "often superior for artistic and design purposes".
To increase luminosity with RGB, just proportionally raise each of your R, G, B values.
To add saturation, you'd spread the R, G, B values farther away from each other (taking the overall color further from gray).
Re: [RESOLVED] My Potions are too strong for you Traveller. Cairo Hue Shift?
One problem i have seen is choosing a text color to print onto a colored background. You usually need to choose a text color that contrasts with the back color as much as possible for best legibility.
It isn't as simple as that, but using a sort of "complement mod 241" of the HSV components gets you a close approximation pretty quickly.
Code:
Option Explicit
Private Const CC_ANYCOLOR = &H100
Private Const CC_RGBINIT = &H1
Private Const CC_FULLOPEN = &H2
Private Const CC_PREVENTFULLOPEN = &H4
Private Type CHOOSECOLOR
lStructSize As Long
hwndOwner As Long
hInstance As Long
rgbResult As Long
lpCustColors As Long
Flags As Long
lCustData As Long
lpfnHook As Long
lpTemplateName As Long
End Type
Private Declare Function ChooseColorW Lib "comdlg32" ( _
ByRef CHOOSECOLOR As CHOOSECOLOR) As Long
Private Declare Function ColorHLSToRGB Lib "shlwapi" ( _
ByVal wHue As Integer, _
ByVal wLuminance As Integer, _
ByVal wSaturation As Integer) As Long
Private Declare Sub ColorRGBToHLS Lib "shlwapi" ( _
ByVal clrRGBNew As Long, _
ByRef wHue As Integer, _
ByRef wLuminance As Integer, _
ByRef wSaturation As Integer)
Private Declare Function GetSysColor Lib "user32" (ByVal nIndex As Long) As Long
Private CHOOSECOLOR As CHOOSECOLOR
Private CustomColors(0 To 15) As Long 'Buffer to retain user's settings.
Private Sub Command1_Click()
Const MESSAGE As String = "Testing, testing... Hello World!"
Dim wHue As Integer
Dim wLuminance As Integer
Dim wSaturation As Integer
Dim Msg As String
With CHOOSECOLOR
.hwndOwner = hWnd
.lpCustColors = VarPtr(CustomColors(0))
If BackColor < 0 Then
.rgbResult = GetSysColor(BackColor And &HFFFF&)
Else
.rgbResult = BackColor
End If
If ChooseColorW(CHOOSECOLOR) <> 0 Then
BackColor = .rgbResult
ColorRGBToHLS BackColor, wHue, wLuminance, wSaturation
wHue = (wHue + 119) Mod 240
wLuminance = (wLuminance + 120) Mod 241
wSaturation = (wSaturation + 120) Mod 241
ForeColor = ColorHLSToRGB(wHue, wLuminance, wSaturation)
CurrentX = (ScaleWidth - TextWidth(MESSAGE)) / 2
CurrentY = 0
Print MESSAGE
Msg = "Back: &H" & Right$("0000000" & Hex$(BackColor), 8)
CurrentX = (ScaleWidth - TextWidth(Msg)) / 2
Print Msg
Msg = "Fore: &H" & Right$("0000000" & Hex$(ForeColor), 8)
CurrentX = (ScaleWidth - TextWidth(Msg)) / 2
Print Msg
End If
End With
End Sub
Private Sub Form_Load()
With CHOOSECOLOR
.lStructSize = LenB(CHOOSECOLOR)
.Flags = CC_ANYCOLOR Or CC_RGBINIT Or CC_FULLOPEN
End With
AutoRedraw = True
End Sub
Re: [RESOLVED] My Potions are too strong for you Traveller. Cairo Hue Shift?
Quote:
Originally Posted by
Elroy
Argen, you can do "anything" with RGB. It's just not necessarily as easy as it is with HSL. That was my point in saying "often superior for artistic and design purposes".
To increase luminosity with RGB, just proportionally raise each of your R, G, B values.
To add saturation, you'd spread the R, G, B values farther away from each other (taking the overall color further from gray).
I agree with Argen, or at least his underlying point. PixelPainter isn't the first sprite colouring tool I ever wrote, I actually wrote one more than a decade ago. Hell in the screenshot it's running on Windows XP. Anyways, in those days I was very ignorant to a lot of things which included a broader understanding of colour spaces. I naively wrote the damn thing to recolour sprites using the RGB colour space and let me tell you, I still remember how frustrating it was to get the exact colours you wanted because you be could be comfortably shifting throught a red hue and end up right into a purple all of a sudden.
RGB is really only good when you don't care what the colours look like. If you're just interested is raw number crunching for various filters like converting to grayscale, then RGB is perfectly fine. But when you start caring about how certain colours would look, you really don't want to use RGB. I learned this first hand. RGB is cubic and unintuitive for "guessing" colours. HSB and HSL have conic a geometry with hues distributed about the circumference which is highly intuitive when one needs to speculate.
Re: [RESOLVED] My Potions are too strong for you Traveller. Cairo Hue Shift?
Quote:
Originally Posted by
Elroy
Argen, you can do "anything" with RGB. It's just not necessarily as easy as it is with HSL.
I agree, you can do anything with RGB, but if you convert the bits to HSL.
With RGB you can do little.
Quote:
That was my point in saying "often superior for artistic and design purposes".
I can't agree. Artistic might be one route of applications only, there can be many non-artistic app that could need to change colors.
Quote:
Originally Posted by
Elroy
To increase luminosity with RGB, just proportionally raise each of your R, G, B values.
Probably not that easy. How much (percent, 1 or 256 based) is the luminosity from which you start?
Then you want to increase the luminosity to 99%,
and after that decrease it to 50%
How would you do that with RGB?
Quote:
To add saturation, you'd spread the R, G, B values farther away from each other (taking the overall color further from gray).
If you do a lot of match you could do anything. The problem is that you basically will be converting to HSL or something similar every time.