forked from mcneel/MOVED-rhinoscript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ColorHelpers.rvb
49 lines (46 loc) · 1.77 KB
/
ColorHelpers.rvb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' 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