Skip to content

Commit 14df62c

Browse files
authored
Bugfix: Allow using #hex colors with 3 characters (#998)
* Fix error using #hex colors with 3 characters * Add test
1 parent 0072334 commit 14df62c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

manim/utils/color.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ def rgb_to_hex(rgb):
289289
def hex_to_rgb(hex_code):
290290
hex_part = hex_code[1:]
291291
if len(hex_part) == 3:
292-
"".join([2 * c for c in hex_part])
292+
hex_part = "".join([2 * c for c in hex_part])
293293
return np.array([int(hex_part[i : i + 2], 16) / 255 for i in range(0, 6, 2)])
294294

295295

tests/test_color.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ def test_background_color():
2020
S.renderer.update_frame(S)
2121
assert np.all(S.renderer.get_frame()[0, 0] == np.array([67, 111, 128, 255]))
2222

23+
S.camera.background_color = "#fff"
24+
S.renderer.update_frame(S)
25+
assert np.all(S.renderer.get_frame()[0, 0] == np.array([255, 255, 255, 255]))
26+
2327
S.camera.background_color = "#bbffbb"
2428
S.camera.background_opacity = 0.5
2529
S.renderer.update_frame(S)

0 commit comments

Comments
 (0)