'Code module
'Subs in this code module will be accessible from all modules.
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim cR,cG,cB As Int
End Sub
Sub HSV2RGB(h As Float,s As Float,v As Float)
Dim i As Int
Dim r,g,b As Float
Dim f,p,q,t As Float
If s=0 Then
'achromatic (grey)
r=v
g=v
b=v
Else
h=h/60
i=Floor(h)
f=h-i
p=v*(1-s)
q=v*(1-s*f)
t=v*(1-s*(1-f))
Select 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 5:
r=v
g=p
b=q
End Select
End If
cR=Floor(255*r)
cG=Floor(255*g)
cB=Floor(255*b)
End Sub