NEW: Welcome to the Rhino 6 version of this page! Looking for the older Rhino 5 version?

Get RGB Color Intensities

Demonstrates retrieve red, green, and blue color intensities using VBScript.

VBScript

''' ---------------------------------------------------------------------------
''' 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
''' ---------------------------------------------------------------------------
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
''' ---------------------------------------------------------------------------
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
''' ---------------------------------------------------------------------------
Function GetBValue(val)
  If val > -1 And val < 16777216 Then
    GetBValue = val \ 256 ^ 2 And 255
  Else
    GetBValue = -1
  End If
End Function