From e4c824e672444b139d30148e070ff3692dcbc9ba Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Thu, 8 Feb 2024 14:37:46 -0600 Subject: [PATCH] Update random_bright_color to operate based on hsl ranges --- manimlib/utils/color.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/manimlib/utils/color.py b/manimlib/utils/color.py index c712c3e6..4389a5b9 100644 --- a/manimlib/utils/color.py +++ b/manimlib/utils/color.py @@ -121,9 +121,16 @@ def random_color() -> Color: return Color(rgb=tuple(np.random.random(3))) -def random_bright_color() -> Color: - color = random_color() - return average_color(color, Color(WHITE)) +def random_bright_color( + hue_range: tuple[float, float] = (0.0, 1.0), + saturation_range: tuple[float, float] = (0.5, 0.8), + luminance_range: tuple[float, float] = (0.5, 1.0), +) -> Color: + return Color(hsl=( + interpolate(*hue_range, random.random()), + interpolate(*saturation_range, random.random()), + interpolate(*luminance_range, random.random()), + )) def get_colormap_list(