mbdlyb.colormap
Color mapping for visualization of MBD model elements.
Provides color schemes for rendering nodes, networks, and relations in diagrams and graph exports.
Attributes
Default color mapping for MBD model elements. |
Classes
Maps model element types to hex color codes for visualization. |
Module Contents
- class mbdlyb.colormap.ColorMap(colormap: dict[type | str, str] | list[tuple[type | str, str]] | None = None)
Maps model element types to hex color codes for visualization.
ColorMap provides a flexible way to assign colors to different types of MBD model elements. Colors can be specified by class type or by string class name. The ColorMap falls back to base class colors if a specific class is not found, and provides a default color for unmapped types.
- Variables:
_map (dict[str, str]) – Internal mapping from class names to hex color codes.
- get_color(c: Any, default: str = '#AAAAAA') str
Get the color for an element or class.
Performs intelligent lookup: 1. If c is a string in the colormap, returns that color 2. If c is an instance, checks its class and base classes 3. If c is a class, checks it and its base classes 4. Returns default if no match found
- Parameters:
c (Any) – An element instance, class, or string class name to get color for.
default (str) – The hex color to return if no mapping is found. Default is ‘#AAAAAA’.
- Returns:
Hex color code (e.g., ‘#FFFFFF’) for the element.
- Return type:
str
- mbdlyb.colormap.DEFAULT_COLORMAP
Default color mapping for MBD model elements.