Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
50 lines (46 sloc) 1.77 KB
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' ColorHelpers.rvb -- January 2011
' If this code works, it was written by Dale Fugier.
' If not, I don't know who wrote it.
' Works with Rhino 4.0.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function: GetRValue
' Purpose: Returns the Red value from an RGB color value
' Arguments: vbLong - An RGB color value
' Returns: vbLong - A Red color value, -1 on error
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Function GetRValue (val)
If val > -1 And val < 16777216 Then
GetRValue = val \ 256 ^ 0 And 255
Else
GetRValue = -1
End If
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function: GetGValue
' Purpose: Returns the Green value from an RGB color value
' Arguments: vbLong - an RGB color value
' Returns: vbLong - a Green color value, -1 on error
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Function GetGValue (val)
If val > -1 And val < 16777216 Then
GetGValue = val \ 256 ^ 1 And 255
Else
GetGValue = -1
End If
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function: GetBValue
' Purpose: Returns the Blue value from an RGB color value
' Arguments: vbLong - an RGB color value
' Returns: vbLong - a Blue color value, -1 on error
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Function GetBValue (val)
If val > -1 And val < 16777216 Then
GetBValue = val \ 256 ^ 2 And 255
Else
GetBValue = -1
End If
End Function