Color map
isa_manim.isa_scene.isa_color_map.IsaColorMap provides the functionality to manage
object colors. The default color and the color scheme can all be changed by the
constructor function.
The hash value controls the color of objects. The objects with the same hash value share the same color.
IsaColorMap
This class is used to map colors for ISA objects by allocating colors in the color scheme.
Attributes:
| Name | Type | Description |
|---|---|---|
colormap_default_color |
Color
|
Default color, used by registers, function units and memory units. Default is WHITE. |
_colormap_color_list |
List[Color]
|
List of color scheme. Default is [RED, BLUE, GREEN, YELLOW, TEAL, PURPLE, MAROON]. |
_colormap_color_index |
int
|
Index points to the last picked color. |
_colormap_hash_dict |
Dict[Union[int, str], Color]
|
Dictionary of objects and their color. Key of the dictionary is the hash value and the value is assigned color. |
__init__(default_color=WHITE, color_scheme=None)
Construct color map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
default_color
|
Color
|
Default color. |
WHITE
|
color_scheme
|
List[Color]
|
Color scheme. |
None
|
colormap_get_color(color_hash, num=1)
Get one color or one list of colors for one given hash value.
- If the hash value exists in the color map, return the assigned color from dictionary.
- Otherwise, return the next color or next colors in the color scheme.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
color_hash
|
Union[int, str]
|
Hash for item. |
required |
num
|
int
|
Number of color. |
1
|
Returns:
| Type | Description |
|---|---|
Union[Color, List[Color]]
|
If |
colormap_reset()
Reset color map.
Reset color index and clear hash dictionary.