- Home
·
- Graphics
·
- Converts from Hue Saturation Value (HSV) to a VB Color suitable for use in forms, controls, etc.
Converts from Hue Saturation Value (HSV) to a VB Color suitable for use in forms, controls, etc.
Converts from Hue Saturation Value (HSV) to a VB Color suitable for use in forms, controls, etc.
Rate Converts from Hue Saturation Value (HSV) to a VB Color suitable for use in forms, controls, etc.
(2(2 Vote))
' Get a VB Color from HSV.
'
'H (hue) between 0 and 360
'S (saturation) between 0 and 1
'V (value) between 0 and 1
'
'by [email protected]
Public Function HSV(ByVal h As Single, _
ByVal s As Single, _
ByVal v As Single) As Long
Dim i As Long
Dim r As Single, g As Single, b As Single
Dim f As Single, p As Single, q As Single, t As Single
If (s = 0) Then
b = v
g = v
r = v
Exit Function
End If
h = h / 60
i = Int(h)
f = h - i
p = v * (1 - s)
q = v * (1 - s * f)
t = v * (1 - s * (1 - f))
Select Case i
Case 0
r = v
g = t
b = p
Case 1
r = q
g = v
b = p
Case 2
r = p
g = v
b = t
Case 3
r = p
g = q
b = v
Case 4
r = t
g = p
b = v
Case Else
r = v
g = p
b = q
End Select
r = r * 255
g = g * 255
b = b * 255
HSV = RGB(r, g, b)
End Function
Converts from Hue Saturation Value (HSV) to a VB Color suitable for use in forms, controls, etc. Comments
No comments yet — be the first to post one!
Post a Comment