mirror of
https://github.com/3b1b/manim.git
synced 2025-09-01 00:48:45 +00:00
Add interpolate_color_by_hsl
This commit is contained in:
parent
100b108ad1
commit
31b2bcd9e6
1 changed files with 10 additions and 0 deletions
|
@ -102,6 +102,16 @@ def interpolate_color(
|
||||||
return rgb_to_color(rgb)
|
return rgb_to_color(rgb)
|
||||||
|
|
||||||
|
|
||||||
|
def interpolate_color_by_hsl(
|
||||||
|
color1: ManimColor,
|
||||||
|
color2: ManimColor,
|
||||||
|
alpha: float
|
||||||
|
) -> Color:
|
||||||
|
hsl1 = np.array(Color(color1).get_hsl())
|
||||||
|
hsl2 = np.array(Color(color2).get_hsl())
|
||||||
|
return Color(hsl=interpolate(hsl1, hsl2, alpha))
|
||||||
|
|
||||||
|
|
||||||
def average_color(*colors: ManimColor) -> Color:
|
def average_color(*colors: ManimColor) -> Color:
|
||||||
rgbs = np.array(list(map(color_to_rgb, colors)))
|
rgbs = np.array(list(map(color_to_rgb, colors)))
|
||||||
return rgb_to_color(np.sqrt((rgbs**2).mean(0)))
|
return rgb_to_color(np.sqrt((rgbs**2).mean(0)))
|
||||||
|
|
Loading…
Add table
Reference in a new issue