colors.py¶
Color manipulation and conversion utilities for Houdini.
This module provides functions for converting between different color formats and managing node color palettes within Houdini. It handles hex colors, RGB floats, and Houdini's native color representations.
Functions:
Name | Description |
---|---|
hex_to_float_rgb |
Convert hex color strings to RGB float values |
float_rgb_to_hex |
Convert RGB float values to hex color strings |
color_selected_nodes |
Apply colors to selected nodes |
validate_palette_file |
Validate Houdini color palette files |
load_default_palette |
Get Houdini's default color palette |
color_selected_nodes(node)
¶
Changes the color of the selected nodes with a color palette window.
Opens a color picker dialog and applies the chosen color to selected nodes and an optional target node.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node
|
Optional[Node]
|
Additional node to apply color to besides selection. If None, only selected nodes will be colored. |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Raises:
Type | Description |
---|---|
RuntimeError
|
If color application fails |
ValueError
|
If node is invalid |
Example
change_node_color(hou.node('/obj/geo1')) # Colors geo1 and selection
Source code in utils/colors.py
float_rgb_to_hex(red, green, blue)
¶
Convert RGB float values to hex color string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
red
|
float
|
Red value (0-1) |
required |
green
|
float
|
Green value (0-1) |
required |
blue
|
float
|
Blue value (0-1) |
required |
Returns:
Type | Description |
---|---|
str
|
6-character hex color string without # prefix |
Examples:
Source code in utils/colors.py
hex_to_float_rgb(hex_value)
¶
Convert a hex color string to RGB float values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hex_value
|
str
|
Hex color string (e.g. "FF0000" or "#FF0000") |
required |
Returns:
Type | Description |
---|---|
Tuple[float, float, float]
|
Tuple of RGB float values from 0-1 |
Examples:
Source code in utils/colors.py
load_default_palette()
¶
Get Houdini's default 36 color palette.
Returns:
Type | Description |
---|---|
List[Tuple[float, float, float]]
|
List of RGB float tuples representing default colors |
Note
The default palette includes white, black, grays, and various hues. Colors are returned as RGB float tuples with values from 0-1.
Source code in utils/colors.py
validate_palette_file(file_path, importing=True)
¶
Validate if a file is a valid Houdini color palette file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
Union[str, Path]
|
Path to the palette file |
required |
importing
|
bool
|
Whether file is being imported (requires content) |
True
|
Returns:
Type | Description |
---|---|
bool
|
True if file is valid, False if invalid |
Notes
Valid palette files must: - Be named "opColorPalette.def" - Exist at the specified path - Contain content if importing=True
Example
validate_palette_file("path/to/opColorPalette.def") True