VBspeed / Util / ValidateHSL
VBspeed © 2000-10, updated: 24-Nov-2001
ValidateHSL


ValidateHSL
Validate Hue, Saturation, Luminance parameters.
Doping: none
Public Sub ValidateHSL(Hue As Long, Saturation As Long, Luminance As Long)
' by Donald, donald@xbeat.net, 20011119
  
  ' Hue: 0-360, wrapped around (Hue is a circle)
  '   eg. -2 -> 358, 362 -> 2
  If Hue < 0 Then
    If Hue < -2147483520 Then   '5965232 * 360
      Hue = (Hue + 2147483520) + 360
    Else
      Hue = (Hue + 2147483520)
    End If
  End If
  Hue = Hue Mod 360
    
  ' Saturation: 0-100, cut-off
  '   eg. -2 -> 0, 120 -> 100
  If Saturation < 0 Then
    Saturation = 0
  ElseIf Saturation > 100 Then
    Saturation = 100
  End If
  
  ' Luminance: same as Saturation
  If Luminance < 0 Then
    Luminance = 0
  ElseIf Luminance > 100 Then
    Luminance = 100
  End If
  
  ''Debug.Print Hue, Saturation, Luminance
End Sub
Author's comments:
Donald's comments:


VBspeed © 2000-10 by Donald Lessau