Colors in Python
This guide provides an overview of a RhinoScriptSyntax Color type in Python.
Colors in Rhino are represented as zero-based, one-dimensional arrays that contain four values. The first 3 values are the Red, Green and Blue channels. Each channel may contain a value from 0 to 255. The fourth value is the Alpha Channel. This control transparency of the color. 0 is completely transparent and the default value of 255 is completely opaque.
color contains [Red, Green, Blue, Alpha]
CreateColor() function to create a new color structure:
import rhinoscriptsytnax as rs color1 = rs.CreateColor(128, 128, 128) # Creates a medium grey color.
CreateColor() function assumes the alpha value is 255 by default.
import rhinoscriptsyntax as rs col = rs.CreateColor(43,45,56) print col print col print col
Unlike many other Rhino types, colors are immutable. This means you cannot set one channel by itself, but must always create a new color when trying to make a color. Setting one channel will not work, for instance
color1 = 56 will throw an error.
Here is a table of commonly used colors:
For more colors see an Online RGB Color table.