You can get and set the internal values using different color representations such as RGB and L*a*b*.
Note that the constructor takes a single tuple of RGB values, not three arguments. So, for example, to create red you would say:
red = hou.Color((1.0, 0, 0))
You can set the color in one color space and get the color in a different color space to convert between spaces.
See HSL and HSV , Lab color space , CIE 1931 color space , and Color temperature for an introduction to the concepts the methods are based on.
Methods ¶
__init__(rgb_tuple=(0.0, 0.0, 0.0))
→ Color
Creates a color object, optionally from RGB values.
To construct a color using a different representation, first create the object and then use a set
method:
c = hou.Color() c.setHSV(180, 0.5, 1.0)
rgb()
→ (float, float, float)
Returns the color as a tuple of (red, green, blue)
floating point values, where each value is in the range 0.0 to 1.0.
setRGB(tuple)
Sets the color using a tuple of (red, green, blue)
floating point values. See the rgb() method.
hsv()
→ (float, float, float)
Returns the color as a tuple of (hue, saturation, value)
, where hue is 0 - 360, and saturation and value are 0.0 - 1.0.
setHSV(tuple)
Sets the color as a tuple of (hue, saturation, value)
. See the hsv() method.
hsl()
→ (float, float, float)
Returns the color as a tuple of (hue, saturation, lightness)
, where hue is 0 - 360, and saturation and lightness are 0.0 - 1.0.
setHSL(tuple)
Sets the color as a tuple of (hue, saturation, lightness)
. See the hsl() method.
lab()
→ (float, float, float)
Returns the color as a tuple of (L, a, b)
as defined in the L*a*b* model, where L
is 0 - 100, and a
and b
are unbound. (Note that a
and b
are restricted to -128 - 127 in TIFF files).
setLAB(tuple)
Sets the color as a tuple of (L, a, b)
as defined in the L*a*b* model. See the lab() method.
tmi()
→ (float, float, float)
Returns the color as a tuple of (temperature, magenta, intensity)
, where each component is -1.0 to 1.0.
setTMI(tuple)
Sets the color as a tuple of (temperature, magenta, intensity)
. See the tmi() method.
xyz()
→ (float, float, float)
Returns the color as a tuple of (x, y, z)
“tristimulus” values, where each component is 0.0 to 1.0 (but may go out of bounds from conversion).
setXYZ(tuple)
Sets the color as a tuple of (x, y, z)
“tristimulus” values. See the xyz() method.
ocio_transform(src_colorspace, dest_colorspace, looks) ->
hou.Color`
Transforms from this color (in src_colorspace
) to a different colorspace (dest_colorspace
) with optional transforms specified in looks
and returns the transformed color. The color space names and the look name must be defined in the current OCIO config file.
ocio_viewTransform(src_colorspace, display_name, view_name) ->
hou.Color`
Transforms from this color (in src_colorspace
) to the view specified by 'display_name' and 'view_name', and returns the transformed color. The color space names, display name, and view name must be defined in the current OCIO config file.