by Anonymous (267 Submissions)
Category: Graphics
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Mon 23rd June 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Converts from Hue Saturation Value (HSV) to a VB Color suitable for use in forms, controls, etc.
' 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
No comments have been posted about Converts from Hue Saturation Value (HSV) to a VB Color suitable for use in forms, controls, etc.. Why not be the first to post a comment about Converts from Hue Saturation Value (HSV) to a VB Color suitable for use in forms, controls, etc..