Skip to content

Commit 9dd9ba2

Browse files
committed
added fallback: check whether passed object has get_hex method
1 parent bd32291 commit 9dd9ba2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

manim/utils/color/core.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,14 @@ def __init__(
232232
raise ValueError(
233233
f"ManimColor only accepts lists/tuples/arrays of length 3 or 4, not {length}"
234234
)
235+
elif hasattr(value, 'get_hex') and callable(value.get_hex):
236+
result = re_hex.search(value.get_hex())
237+
if result is None:
238+
raise ValueError(f"Failed to parse a color from {value}")
239+
240+
self._internal_value = ManimColor._internal_from_hex_string(
241+
result.group(), alpha
242+
)
235243
else:
236244
# logger.error(f"Invalid color value: {value}")
237245
raise TypeError(

0 commit comments

Comments
 (0)