Re: Scrolling through Hue
Well, in order to solve the problem I first decided to make a little converter from RGB to HSB. There are three textboxes and a command button. There are no errors, however the code does not return the correct values for Hue and Saturation based on the RGB values. What am I doing wrong?? (I found a mathematical operation on the web and adapted it... maybe something is wrong).
Note: All variables dimmed as Single
VB Code:
Private Sub Command1_Click()
R = Val(txtR.Text) / 255
G = Val(txtG.Text) / 255
B = Val(txtB.Text) / 255
vMax = Max(R, G, B) 'Function that returns maximum of the three values
vMin = Min(R, G, B) 'Function that returns minimum of the three values
Delta = vMax - vMin
If Delta = 0 Then
Hue = 0
Sat = 0
Else
Sat = Delta / vMax
dR = (((vMax - R) / 6) + (Delta / 2)) / Delta
dG = (((vMax - G) / 6) + (Delta / 2)) / Delta
dB = (((vMax - B) / 6) + (Delta / 2)) / Delta
If R = vMax Then
Hue = dB - dG
ElseIf G = vMax Then
Hue = 1 / 3 + dR - dB
ElseIf B = vMax Then
Hue = 2 / 3 + dG - dR
End If
If Hue < 0 Then
Hue = Hue + 1
ElseIf Hue > 0 Then
Hue = Hue - 1
End If
End If
Hue = Hue * 180
'Ranges: -180<Hue<180
' 0<Sat<1
Debug.Print Hue
Debug.Print Sat
End Sub
Re: Scrolling through Hue
Here's a program that does conversions. You can try it for free for 10 days.
It will let you know if you are doing things correctly.
http://www.google.com/url?sa=U&start...icker/&e=10431
Re: Scrolling through Hue
Quote:
Originally Posted by dglienna
Here's a program that does conversions. You can try it for free for 10 days.
It will let you know if you are doing things correctly.
Well, I know that I'm doing them incorrectly :cry:
The program can't help me..... :cry:
Re: Scrolling through Hue
Re: Scrolling through Hue
Quote:
Originally Posted by dglienna
I'll check it out... thanks
Re: Scrolling through Hue
Hum, it seems to be exactly what I need... Thanks, dglienna
1 Attachment(s)
Re: Scrolling through Hue
Alright! Coded...
If anybody's interested, the code for "scrolling through hue" is attached.
Re: Scrolling through Hue
I thought I had that before, but couldn't find it. Glad things worked out. :wave: