Adding :class: ManimColor to manim and converting all types (#3020)

* first draft of color class + starting library conversion

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* changed everything to Manim color todo: figure out circular dependency in utils

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* first working draft of new color version

* resolving conflicts

* resolving conflicts

* resolving conflicts

* resolving conflicts

* resolving conflicts

* changed default internal value of ManimColor to np.ndarray[float]

* starting to fix tests

* fixed more tests and changed precision of manim color

* removed premature color conversion

* fixed some more tests

* final test changes

* fix doctests

* fix for 3.8

* fixing ManimColor string representation

* removing some unneccesary conversions

* moved community constants to manim_colors.py and added more color standards

* broke some too long lines

* added fallback: check whether passed object has get_hex method

* actually fix _internal_from_string

* added hsv support

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* remove dependency on colour

* fixed DARK_EARTH being assigned twice

* fixed double assignment

* remove more duplicated colour names

* raise NotImplementedError for ManimColor.gradient

* removed unused import

* remove superfluous ManimColor import

* fix circular import, remove dependency of space_ops on config

* one more Color -> ParseableManimColor

* removed one *-import

* somewhat unrelated fixed type hint

* -1 *-import

* fixed change of logic in CoordinateSystem.get_graph_label

* removed debug print; fixed type hint in mobject.py

* some fixes and improvements to text_mobject.py

* update three_dimensions

* fixes for rendered documentation of utils.color.*

* substantial improvements to documentation, including new Sphinx directive

Co-authored-by: MrDiver <mrdiverlp@gmail.com>

* Rewrite of the sphinx directive to use docutils nodes and 2 column design

* I just had to do it

* Improve the color table

* minor cleanup

* fixed ColorOverview example

* documentation improvements

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update manim/mobject/mobject.py

Co-authored-by: Benjamin Hackl <devel@benjamin-hackl.at>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix flake8 errors

* Removed test in test_text_mobject

* Improved Documentation of core.py and added private members in sphinx so that internal methods can be documented

* Change color types of labeled.py

* removed some unused imports

* turned docstring into comment

* _colors  -> _all_manim_colors; move to manim_color module

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fixed typing

* rewrite import

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Benjamin Hackl <devel@benjamin-hackl.at>
Co-authored-by: Naveen M K <naveen521kk@gmail.com>
This commit is contained in:
Tristan Schulz 2023-08-08 14:47:00 +02:00 committed by GitHub
commit 82e55b5da2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
52 changed files with 4730 additions and 1710 deletions

View file

@ -23,6 +23,9 @@ ignore_errors = True
[mypy-manim.utils.*]
ignore_errors = True
[mypy-manim.utils.color]
ignore_errors = False
[mypy-manim.animation.*]
ignore_errors = True

View file

@ -7,6 +7,8 @@ Qualified name: ``{{ fullname | escape }}``
.. autoclass:: {{ objname }}
:show-inheritance:
:members:
:private-members:
{% block methods %}
{%- if methods %}

View file

@ -43,6 +43,7 @@ extensions = [
"sphinx.ext.viewcode",
"sphinxext.opengraph",
"manim.utils.docbuild.manim_directive",
"manim.utils.docbuild.autocolor_directive",
"sphinx.ext.graphviz",
"sphinx.ext.inheritance_diagram",
"sphinxcontrib.programoutput",

View file

@ -23,11 +23,11 @@ from collections.abc import Mapping, MutableMapping
from pathlib import Path
from typing import Any, Iterable, Iterator
import colour
import numpy as np
from .. import constants
from ..constants import RendererType
from ..utils.color import ManimColor
from ..utils.tex import TexTemplate, TexTemplateFromFile
from ..utils.tex_templates import TexTemplateLibrary
@ -1096,7 +1096,7 @@ class ManimConfig(MutableMapping):
background_color = property(
lambda self: self._d["background_color"],
lambda self, val: self._d.__setitem__("background_color", colour.Color(val)),
lambda self, val: self._d.__setitem__("background_color", ManimColor(val)),
doc="Background color of the scene (-c).",
)

View file

@ -6,12 +6,17 @@ __all__ = ["AnimatedBoundary", "TracedPath"]
from typing import Callable
from colour import Color
from manim._config import config
from manim.mobject.opengl.opengl_compatibility import ConvertToOpenGL
from manim.mobject.types.vectorized_mobject import VGroup, VMobject
from manim.utils.color import BLUE_B, BLUE_D, BLUE_E, GREY_BROWN, WHITE
from manim.utils.color import (
BLUE_B,
BLUE_D,
BLUE_E,
GREY_BROWN,
WHITE,
ParsableManimColor,
)
from manim.utils.rate_functions import smooth
@ -140,7 +145,7 @@ class TracedPath(VMobject, metaclass=ConvertToOpenGL):
self,
traced_point_func: Callable,
stroke_width: float = 2,
stroke_color: Color = WHITE,
stroke_color: ParsableManimColor | None = WHITE,
dissipating_time: float | None = None,
**kwargs,
):

View file

@ -77,13 +77,13 @@ import itertools as it
from typing import TYPE_CHECKING, Callable, Iterable, Sequence
import numpy as np
from colour import Color
if TYPE_CHECKING:
from manim.mobject.text.text_mobject import Text
from manim.mobject.opengl.opengl_surface import OpenGLSurface
from manim.mobject.opengl.opengl_vectorized_mobject import OpenGLVMobject
from manim.utils.color import ManimColor
from .. import config
from ..animation.animation import Animation
@ -259,7 +259,7 @@ class DrawBorderThenFill(Animation):
sm.set_stroke(color=self.get_stroke_color(sm), width=self.stroke_width)
return outline
def get_stroke_color(self, vmobject: VMobject | OpenGLVMobject) -> Color:
def get_stroke_color(self, vmobject: VMobject | OpenGLVMobject) -> ManimColor:
if self.stroke_color:
return self.stroke_color
elif vmobject.get_stroke_width() > 0:

View file

@ -40,7 +40,6 @@ __all__ = [
from typing import Callable, Iterable, Optional, Tuple, Type, Union
import numpy as np
from colour import Color
from manim.mobject.geometry.arc import Circle, Dot
from manim.mobject.geometry.line import Line
@ -58,7 +57,7 @@ from ..constants import *
from ..mobject.mobject import Mobject
from ..mobject.types.vectorized_mobject import VGroup, VMobject
from ..utils.bezier import interpolate, inverse_interpolate
from ..utils.color import GREY, YELLOW
from ..utils.color import GREY, YELLOW, ParsableManimColor
from ..utils.deprecation import deprecated
from ..utils.rate_functions import smooth, there_and_back, wiggle
from ..utils.space_ops import normalize
@ -609,7 +608,7 @@ class Circumscribe(Succession):
fade_out=False,
time_width=0.3,
buff: float = SMALL_BUFF,
color: Color = YELLOW,
color: ParsableManimColor = YELLOW,
run_time=1,
stroke_width=DEFAULT_STROKE_WIDTH,
**kwargs

View file

@ -24,7 +24,7 @@ from ..mobject.mobject import Mobject
from ..mobject.types.image_mobject import AbstractImageMobject
from ..mobject.types.point_cloud_mobject import PMobject
from ..mobject.types.vectorized_mobject import VMobject
from ..utils.color import color_to_int_rgba
from ..utils.color import ManimColor, ParsableManimColor, color_to_int_rgba
from ..utils.family import extract_mobject_family_members
from ..utils.images import get_full_raster_image_path
from ..utils.iterables import list_difference_update
@ -75,6 +75,8 @@ class Camera:
frame_height: float | None = None,
frame_width: float | None = None,
frame_rate: float | None = None,
background_color: ParsableManimColor | None = None,
background_opacity: float | None = None,
**kwargs,
):
self.background_image = background_image
@ -106,9 +108,14 @@ class Camera:
frame_rate = config["frame_rate"]
self.frame_rate = frame_rate
# TODO: change this to not use kwargs.get
for attr in ["background_color", "background_opacity"]:
setattr(self, f"_{attr}", kwargs.get(attr, config[attr]))
if background_color is None:
self._background_color = ManimColor.parse(config["background_color"])
else:
self._background_color = ManimColor.parse(background_color)
if background_opacity is None:
self._background_opacity = config["background_opacity"]
else:
self._background_opacity = background_opacity
# This one is in the same boat as the above, but it doesn't have the
# same name as the corresponding key so it has to be handled on its own

View file

@ -1,9 +0,0 @@
"""The colormap of manim community"""
from __future__ import annotations
LOGO_WHITE = "#ece6e2"
LOGO_GREEN = "#87c2a5"
LOGO_BLUE = "#525893"
LOGO_RED = "#e07a5f"
LOGO_BLACK = "#343434"

View file

@ -48,7 +48,6 @@ import warnings
from typing import TYPE_CHECKING, Sequence
import numpy as np
from colour import Color
from manim.constants import *
from manim.mobject.opengl.opengl_compatibility import ConvertToOpenGL
@ -492,7 +491,7 @@ class Circle(Arc):
def __init__(
self,
radius: float | None = None,
color: Color | str = RED,
color: ParsableManimColor = RED,
**kwargs,
):
super().__init__(
@ -658,7 +657,7 @@ class Dot(Circle):
radius: float = DEFAULT_DOT_RADIUS,
stroke_width: float = 0,
fill_opacity: float = 1.0,
color: Color | str = WHITE,
color: ParsableManimColor = WHITE,
**kwargs,
):
super().__init__(

View file

@ -12,7 +12,7 @@ from manim.mobject.geometry.shape_matchers import (
)
from manim.mobject.text.tex_mobject import MathTex, Tex
from manim.mobject.text.text_mobject import Text
from manim.utils.color import WHITE, Color
from manim.utils.color import WHITE, ManimColor, ParsableManimColor
class LabeledLine(Line):
@ -26,11 +26,11 @@ class LabeledLine(Line):
A ratio in the range [0-1] to indicate the position of the label with respect to the length of the line. Default value is 0.5.
font_size : float | optional
Control font size for the label. This parameter is only used when `label` is of type `str`.
label_color: numpy.ndarray | optional
label_color: ParsableManimColor | optional
The color of the label's text. This parameter is only used when `label` is of type `str`.
label_frame : Bool | optional
Add a `SurroundingRectangle` frame to the label box.
frame_fill_color : numpy.ndarray | optional
frame_fill_color : ParsableManimColor | optional
Background color to fill the label box. If no value is provided, the background color of the canvas will be used.
frame_fill_opacity : float | optional
Determine the opacity of the label box by passing a value in the range [0-1], where 0 indicates complete transparency and 1 means full opacity.
@ -65,13 +65,15 @@ class LabeledLine(Line):
label: str | Tex | MathTex | Text,
label_position: float = 0.5,
font_size: float = DEFAULT_FONT_SIZE,
label_color: Color | str | None = WHITE,
label_color: ParsableManimColor = WHITE,
label_frame: bool = True,
frame_fill_color: Color | str | None = None,
frame_fill_color: ParsableManimColor = None,
frame_fill_opacity: float = 1,
*args,
**kwargs,
) -> None:
label_color = ManimColor(label_color)
frame_fill_color = ManimColor(frame_fill_color)
if isinstance(label, str):
from manim import MathTex
@ -120,11 +122,11 @@ class LabeledArrow(LabeledLine, Arrow):
A ratio in the range [0-1] to indicate the position of the label with respect to the length of the line. Default value is 0.5.
font_size : float | optional
Control font size for the label. This parameter is only used when `label` is of type `str`.
label_color: numpy.ndarray | optional
label_color: ParsableManimColor | optional
The color of the label's text. This parameter is only used when `label` is of type `str`.
label_frame : Bool | optional
Add a `SurroundingRectangle` frame to the label box.
frame_fill_color : numpy.ndarray | optional
frame_fill_color : ParsableManimColor | optional
Background color to fill the label box. If no value is provided, the background color of the canvas will be used.
frame_fill_opacity : float | optional
Determine the opacity of the label box by passing a value in the range [0-1], where 0 indicates complete transparency and 1 means full opacity.

View file

@ -17,7 +17,6 @@ __all__ = [
from typing import Any, Sequence
import numpy as np
from colour import Color
from manim import config
from manim.constants import *
@ -28,7 +27,6 @@ from manim.mobject.opengl.opengl_compatibility import ConvertToOpenGL
from manim.mobject.opengl.opengl_mobject import OpenGLMobject
from manim.mobject.types.vectorized_mobject import DashedVMobject, VGroup, VMobject
from manim.utils.color import *
from manim.utils.color import Colors
from manim.utils.space_ops import angle_of_vector, line_intersection, normalize
@ -647,7 +645,7 @@ class Vector(Arrow):
self,
integer_labels: bool = True,
n_dim: int = 2,
color: Color | None = None,
color: ParsableManimColor | None = None,
**kwargs,
):
"""Creates a label based on the coordinates of the vector.
@ -879,7 +877,7 @@ class Angle(VMobject, metaclass=ConvertToOpenGL):
dot: bool = False,
dot_radius: float | None = None,
dot_distance: float = 0.55,
dot_color: Colors = WHITE,
dot_color: ParsableManimColor = WHITE,
elbow: bool = False,
**kwargs,
):

View file

@ -19,7 +19,6 @@ from math import ceil
from typing import Iterable, Sequence
import numpy as np
from colour import Color
from manim.constants import *
from manim.mobject.geometry.arc import ArcBetweenPoints
@ -597,7 +596,7 @@ class Rectangle(Polygon):
def __init__(
self,
color: Color = WHITE,
color: ParsableManimColor = WHITE,
height: float = 2.0,
width: float = 4.0,
grid_xstep: float | None = None,

View file

@ -10,7 +10,7 @@ from manim.mobject.geometry.line import Line
from manim.mobject.geometry.polygram import RoundedRectangle
from manim.mobject.mobject import Mobject
from manim.mobject.types.vectorized_mobject import VGroup
from manim.utils.color import BLACK, RED, YELLOW, Color, Colors
from manim.utils.color import BLACK, RED, YELLOW, ParsableManimColor
class SurroundingRectangle(RoundedRectangle):
@ -79,7 +79,7 @@ class BackgroundRectangle(SurroundingRectangle):
def __init__(
self,
mobject,
color: Colors | None = None,
color: ParsableManimColor | None = None,
stroke_width: float = 0,
stroke_opacity: float = 0,
fill_opacity: float = 0.75,
@ -121,7 +121,7 @@ class BackgroundRectangle(SurroundingRectangle):
return self
def get_fill_color(self):
return Color(self.color)
return self.color
class Cross(VGroup):
@ -152,7 +152,7 @@ class Cross(VGroup):
def __init__(
self,
mobject: Mobject | None = None,
stroke_color: Color = RED,
stroke_color: ParsableManimColor = RED,
stroke_width: float = 6,
scale_factor: float = 1,
**kwargs,

View file

@ -17,7 +17,6 @@ import numbers
from typing import TYPE_CHECKING, Any, Callable, Iterable, Sequence
import numpy as np
from colour import Color
from manim import config
from manim.constants import *
@ -44,6 +43,8 @@ from manim.utils.color import (
GREEN,
WHITE,
YELLOW,
ManimColor,
ParsableManimColor,
color_gradient,
invert_color,
)
@ -431,7 +432,7 @@ class CoordinateSystem:
point: Sequence[float],
line_func: Line = DashedLine,
line_config: dict | None = None,
color: Color | None = None,
color: ParsableManimColor | None = None,
stroke_width: float = 2,
) -> Line:
"""Returns a straight line from a given axis to a point in the scene.
@ -467,7 +468,7 @@ class CoordinateSystem:
if color is None:
color = VMobject().color
line_config["color"] = color
line_config["color"] = ManimColor.parse(color)
line_config["stroke_width"] = stroke_width
axis = self.get_axis(index)
@ -823,7 +824,9 @@ class CoordinateSystem:
function: Callable[[float], float],
u_range: Sequence[float] | None = None,
v_range: Sequence[float] | None = None,
colorscale: Sequence[[color], float] | None = None,
colorscale: Sequence[ParsableManimColor]
| Sequence[tuple[ParsableManimColor, float]]
| None = None,
colorscale_axis: int = 2,
**kwargs,
):
@ -992,7 +995,7 @@ class CoordinateSystem:
x_val: float | None = None,
direction: Sequence[float] = RIGHT,
buff: float = MED_SMALL_BUFF,
color: Color | None = None,
color: ParsableManimColor | None = None,
dot: bool = False,
dot_config: dict | None = None,
) -> Mobject:
@ -1044,7 +1047,8 @@ class CoordinateSystem:
if dot_config is None:
dot_config = {}
color = color or graph.get_color()
if color is None:
color = graph.get_color()
label = self.x_axis._create_label_tex(label).set_color(color)
if x_val is None:
@ -1074,9 +1078,9 @@ class CoordinateSystem:
dx: float | None = 0.1,
input_sample_type: str = "left",
stroke_width: float = 1,
stroke_color: Color = BLACK,
stroke_color: ParsableManimColor = BLACK,
fill_opacity: float = 1,
color: Iterable[Color] | Color = np.array((BLUE, GREEN)),
color: Iterable[ParsableManimColor] | ParsableManimColor = (BLUE, GREEN),
show_signed_area: bool = True,
bounded_graph: ParametricFunction = None,
blend: bool = False,
@ -1175,11 +1179,12 @@ class CoordinateSystem:
rectangles = VGroup()
x_range = np.arange(*x_range)
# allows passing a string to color the graph
if type(color) is str:
colors = [color] * len(x_range)
if isinstance(color, (list, tuple)):
color = [ManimColor(c) for c in color]
else:
colors = color_gradient(color, len(x_range))
color = [ManimColor(color)]
colors = color_gradient(color, len(x_range))
for x, color in zip(x_range, colors):
if input_sample_type == "left":
@ -1234,7 +1239,7 @@ class CoordinateSystem:
self,
graph: ParametricFunction,
x_range: tuple[float, float] | None = None,
color: Color | Iterable[Color] = [BLUE, GREEN],
color: ParsableManimColor | Iterable[ParsableManimColor] = (BLUE, GREEN),
opacity: float = 0.3,
bounded_graph: ParametricFunction = None,
**kwargs,
@ -1383,7 +1388,7 @@ class CoordinateSystem:
return np.tan(self.angle_of_tangent(x, graph, **kwargs))
def plot_derivative_graph(
self, graph: ParametricFunction, color: Color = GREEN, **kwargs
self, graph: ParametricFunction, color: ParsableManimColor = GREEN, **kwargs
) -> ParametricFunction:
"""Returns the curve of the derivative of the passed graph.
@ -1491,12 +1496,12 @@ class CoordinateSystem:
x: float,
graph: ParametricFunction,
dx: float | None = None,
dx_line_color: Color = YELLOW,
dy_line_color: Color | None = None,
dx_line_color: ParsableManimColor = YELLOW,
dy_line_color: ParsableManimColor | None = None,
dx_label: float | str | None = None,
dy_label: float | str | None = None,
include_secant_line: bool = True,
secant_line_color: Color = GREEN,
secant_line_color: ParsableManimColor = GREEN,
secant_line_length: float = 10,
) -> VGroup:
"""Creates two lines representing `dx` and `df`, the labels for `dx` and `df`, and
@ -1670,11 +1675,11 @@ class CoordinateSystem:
x_val: float,
graph: ParametricFunction,
label: float | str | Mobject | None = None,
label_color: Color | None = None,
label_color: ParsableManimColor | None = None,
triangle_size: float = MED_SMALL_BUFF,
triangle_color: Color | None = WHITE,
triangle_color: ParsableManimColor | None = WHITE,
line_func: Line = Line,
line_color: Color = YELLOW,
line_color: ParsableManimColor = YELLOW,
) -> VGroup:
"""Creates a labelled triangle marker with a vertical line from the x-axis
to a curve at a given x-value.
@ -2153,7 +2158,7 @@ class Axes(VGroup, CoordinateSystem, metaclass=ConvertToOpenGL):
x_values: Iterable[float],
y_values: Iterable[float],
z_values: Iterable[float] | None = None,
line_color: Color = YELLOW,
line_color: ParsableManimColor = YELLOW,
add_vertex_dots: bool = True,
vertex_dot_radius: float = DEFAULT_DOT_RADIUS,
vertex_dot_style: dict | None = None,

View file

@ -8,7 +8,6 @@ __all__ = ["SampleSpace", "BarChart"]
from typing import Iterable, MutableSequence, Sequence
import numpy as np
from colour import Color
from manim import config, logger
from manim.constants import *
@ -26,6 +25,7 @@ from manim.utils.color import (
LIGHT_GREY,
MAROON_B,
YELLOW,
ParsableManimColor,
color_gradient,
)
from manim.utils.iterables import tuplify
@ -401,7 +401,7 @@ class BarChart(Axes):
def get_bar_labels(
self,
color: Color | None = None,
color: ParsableManimColor | None = None,
font_size: float = 24,
buff: float = MED_SMALL_BUFF,
label_constructor: type[VMobject] = Tex,

View file

@ -1,4 +1,5 @@
"""Base classes for objects that can be displayed."""
from __future__ import annotations
__all__ = ["Mobject", "Group", "override_animate"]
@ -29,7 +30,6 @@ from typing import (
)
import numpy as np
from colour import Color
from manim.mobject.opengl.opengl_compatibility import ConvertToOpenGL
@ -39,7 +39,8 @@ from ..utils.color import (
BLACK,
WHITE,
YELLOW_C,
Colors,
ManimColor,
ParsableManimColor,
color_gradient,
interpolate_color,
)
@ -91,7 +92,14 @@ class Mobject:
cls._add_intrinsic_animation_overrides()
cls._original__init__ = cls.__init__
def __init__(self, color=WHITE, name=None, dim=3, target=None, z_index=0):
def __init__(
self,
color: ParsableManimColor | list[ParsableManimColor] = WHITE,
name=None,
dim=3,
target=None,
z_index=0,
):
self.name = self.__class__.__name__ if name is None else name
self.dim = dim
self.target = target
@ -100,7 +108,7 @@ class Mobject:
self.submobjects = []
self.updaters = []
self.updating_suspended = False
self.color = Color(color) if color else None
self.color: ManimColor = ManimColor.parse(color)
self.reset_points()
self.generate_points()
@ -201,10 +209,10 @@ class Mobject:
>>> from manim import Square, GREEN
>>> Square.set_default(color=GREEN, fill_opacity=0.25)
>>> s = Square(); s.color, s.fill_opacity
(<Color #83c167>, 0.25)
(ManimColor('#83C167'), 0.25)
>>> Square.set_default()
>>> s = Square(); s.color, s.fill_opacity
(<Color white>, 0.0)
(ManimColor('#FFFFFF'), 0.0)
.. manim:: ChangedDefaultTextcolor
:save_last_frame:
@ -1687,7 +1695,7 @@ class Mobject:
# Background rectangle
def add_background_rectangle(
self, color: Colors | None = None, opacity: float = 0.75, **kwargs
self, color: ParsableManimColor | None = None, opacity: float = 0.75, **kwargs
):
"""Add a BackgroundRectangle as submobject.
@ -1739,7 +1747,9 @@ class Mobject:
# Color functions
def set_color(self, color: Color = YELLOW_C, family: bool = True):
def set_color(
self, color: ParsableManimColor = YELLOW_C, family: bool = True
) -> Mobject:
"""Condition is function which takes in one arguments, (x, y, z).
Here it just recurses to submobjects, but in subclasses this
should be further implemented based on the the inner workings
@ -1748,19 +1758,30 @@ class Mobject:
if family:
for submob in self.submobjects:
submob.set_color(color, family=family)
self.color = Color(color)
self.color = ManimColor.parse(color)
return self
def set_color_by_gradient(self, *colors):
def set_color_by_gradient(self, *colors: Iterable[ParsableManimColor]):
"""Set the color of this mobject's submobjects along the specified
gradient.
Parameters
----------
colors
The colors to use for the gradient. Use like
``set_color_by_gradient(RED, BLUE, GREEN)``.
"""
self.set_submobject_colors_by_gradient(*colors)
return self
def set_colors_by_radial_gradient(
self,
center=None,
radius=1,
inner_color=WHITE,
outer_color=BLACK,
radius: float = 1,
inner_color: ParsableManimColor = WHITE,
outer_color: ParsableManimColor = BLACK,
):
self.set_submobject_colors_by_radial_gradient(
center,
@ -1770,7 +1791,7 @@ class Mobject:
)
return self
def set_submobject_colors_by_gradient(self, *colors):
def set_submobject_colors_by_gradient(self, *colors: Iterable[ParsableManimColor]):
if len(colors) == 0:
raise ValueError("Need at least one color")
elif len(colors) == 1:
@ -1786,9 +1807,9 @@ class Mobject:
def set_submobject_colors_by_radial_gradient(
self,
center=None,
radius=1,
inner_color=WHITE,
outer_color=BLACK,
radius: float = 1,
inner_color: ParsableManimColor = WHITE,
outer_color: ParsableManimColor = BLACK,
):
if center is None:
center = self.get_center()
@ -1805,7 +1826,7 @@ class Mobject:
self.set_color(self.color)
return self
def fade_to(self, color, alpha, family=True):
def fade_to(self, color: ParsableManimColor, alpha: float, family: bool = True):
if self.get_num_points() > 0:
new_color = interpolate_color(self.get_color(), color, alpha)
self.set_color(new_color, family=False)
@ -1814,13 +1835,13 @@ class Mobject:
submob.fade_to(color, alpha)
return self
def fade(self, darkness=0.5, family=True):
def fade(self, darkness: float = 0.5, family: bool = True):
if family:
for submob in self.submobjects:
submob.fade(darkness, family)
return self
def get_color(self):
def get_color(self) -> ManimColor:
"""Returns the color of the :class:`~.Mobject`"""
return self.color
@ -2169,7 +2190,7 @@ class Mobject:
all_mobjects = [self] + list(it.chain(*sub_families))
return remove_list_redundancies(all_mobjects)
def family_members_with_points(self):
def family_members_with_points(self) -> list[Mobject]:
return [m for m in self.get_family() if m.get_num_points() > 0]
def arrange(
@ -2760,7 +2781,7 @@ class Mobject:
self,
z_index_value: float,
family: bool = True,
) -> VMobject:
) -> T:
"""Sets the :class:`~.Mobject`'s :attr:`z_index` to the value specified in `z_index_value`.
Parameters

View file

@ -10,13 +10,11 @@ from typing import Iterable, Sequence
import moderngl
import numpy as np
from colour import Color
from manim import config, logger
from manim.constants import *
from manim.utils.bezier import integer_interpolate, interpolate
from manim.utils.color import *
from manim.utils.color import Colors
from manim.utils.config_ops import _Data, _Uniforms
# from ..utils.iterables import batch_by_property
@ -146,7 +144,7 @@ class OpenGLMobject:
self.init_updaters()
# self.init_event_listners()
self.init_points()
self.color = Color(color) if color else None
self.color = ManimColor.parse(color)
self.init_colors()
self.shader_indices = None
@ -203,10 +201,10 @@ class OpenGLMobject:
>>> from manim import Square, GREEN
>>> Square.set_default(color=GREEN, fill_opacity=0.25)
>>> s = Square(); s.color, s.fill_opacity
(<Color #83c167>, 0.25)
(ManimColor('#83C167'), 0.25)
>>> Square.set_default()
>>> s = Square(); s.color, s.fill_opacity
(<Color white>, 0.0)
(ManimColor('#FFFFFF'), 0.0)
.. manim:: ChangedDefaultTextcolor
:save_last_frame:
@ -1971,12 +1969,12 @@ class OpenGLMobject:
for mob in self.get_family(recurse):
mob.data[name] = rgbas.copy()
def set_color(self, color, opacity=None, recurse=True):
def set_color(self, color: ParsableManimColor | None, opacity=None, recurse=True):
self.set_rgba_array(color, opacity, recurse=False)
# Recurse to submobjects differently from how set_rgba_array
# in case they implement set_color differently
if color is not None:
self.color = Color(color)
self.color: ManimColor = ManimColor.parse(color)
if opacity is not None:
self.opacity = opacity
if recurse:
@ -2037,7 +2035,7 @@ class OpenGLMobject:
# Background rectangle
def add_background_rectangle(
self, color: Colors | None = None, opacity: float = 0.75, **kwargs
self, color: ParsableManimColor | None = None, opacity: float = 0.75, **kwargs
):
# TODO, this does not behave well when the mobject has points,
# since it gets displayed on top

View file

@ -7,7 +7,6 @@ from typing import Callable, Iterable, Optional, Sequence
import moderngl
import numpy as np
from colour import Color
from manim import config
from manim.constants import *
@ -81,9 +80,9 @@ class OpenGLVMobject(OpenGLMobject):
def __init__(
self,
fill_color: Color | None = None,
fill_color: ParsableManimColor | None = None,
fill_opacity: float = 0.0,
stroke_color: Color | None = None,
stroke_color: ParsableManimColor | None = None,
stroke_opacity: float = 1.0,
stroke_width: float = DEFAULT_STROKE_WIDTH,
draw_stroke_behind_fill: bool = False,
@ -146,10 +145,10 @@ class OpenGLVMobject(OpenGLMobject):
super().__init__(**kwargs)
self.refresh_unit_normal()
if fill_color:
self.fill_color = Color(fill_color)
if stroke_color:
self.stroke_color = Color(stroke_color)
if fill_color is not None:
self.fill_color = ManimColor.parse(fill_color)
if stroke_color is not None:
self.stroke_color = ManimColor.parse(stroke_color)
def get_group_class(self):
return OpenGLVGroup
@ -184,7 +183,7 @@ class OpenGLVMobject(OpenGLMobject):
def set_fill(
self,
color: Color | None = None,
color: ParsableManimColor | None = None,
opacity: float | None = None,
recurse: bool = True,
) -> OpenGLVMobject:
@ -350,14 +349,15 @@ class OpenGLVMobject(OpenGLMobject):
super().fade(darkness, recurse)
return self
# Todo im not quite sure why we are doing this
def get_fill_colors(self):
return [Color(rgb_to_hex(rgba[:3])) for rgba in self.fill_rgba]
return [ManimColor.from_rgb(rgba[:3]) for rgba in self.fill_rgba]
def get_fill_opacities(self):
return self.fill_rgba[:, 3]
def get_stroke_colors(self):
return [Color(rgb_to_hex(rgba[:3])) for rgba in self.stroke_rgba]
return [ManimColor.from_rgb(rgba[:3]) for rgba in self.stroke_rgba]
def get_stroke_opacities(self):
return self.stroke_rgba[:, 3]
@ -1881,7 +1881,7 @@ class OpenGLDashedVMobject(OpenGLVMobject):
vmobject: OpenGLVMobject,
num_dashes: int = 15,
dashed_ratio: float = 0.5,
color: Color = WHITE,
color: ParsableManimColor = WHITE,
**kwargs,
):
self.dashed_ratio = dashed_ratio

View file

@ -67,8 +67,6 @@ __all__ = [
import itertools as it
from typing import Callable, Iterable, Sequence
from colour import Color
from manim.mobject.geometry.line import Line
from manim.mobject.geometry.polygram import Polygon
from manim.mobject.geometry.shape_matchers import BackgroundRectangle
@ -82,7 +80,7 @@ from ..animation.composition import AnimationGroup
from ..animation.creation import Create, Write
from ..animation.fading import FadeIn
from ..mobject.types.vectorized_mobject import VGroup, VMobject
from ..utils.color import BLACK, YELLOW
from ..utils.color import BLACK, YELLOW, ManimColor, ParsableManimColor
from .utils import get_vectorized_mobject_class
@ -197,9 +195,9 @@ class Table(VGroup):
h_buff: float = 1.3,
include_outer_lines: bool = False,
add_background_rectangles_to_entries: bool = False,
entries_background_color: Color = BLACK,
entries_background_color: ParsableManimColor = BLACK,
include_background_rectangle: bool = False,
background_rectangle_color: Color = BLACK,
background_rectangle_color: ParsableManimColor = BLACK,
element_to_mobject: Callable[
[float | str | VMobject],
VMobject,
@ -218,9 +216,9 @@ class Table(VGroup):
self.h_buff = h_buff
self.include_outer_lines = include_outer_lines
self.add_background_rectangles_to_entries = add_background_rectangles_to_entries
self.entries_background_color = entries_background_color
self.entries_background_color = ManimColor(entries_background_color)
self.include_background_rectangle = include_background_rectangle
self.background_rectangle_color = background_rectangle_color
self.background_rectangle_color = ManimColor(background_rectangle_color)
self.element_to_mobject = element_to_mobject
self.element_to_mobject_config = element_to_mobject_config
self.arrange_in_grid_config = arrange_in_grid_config
@ -504,7 +502,7 @@ class Table(VGroup):
"""
return VGroup(*(VGroup(*row) for row in self.mob_table))
def set_column_colors(self, *colors: Iterable[Color]) -> Table:
def set_column_colors(self, *colors: Iterable[ParsableManimColor]) -> Table:
"""Set individual colors for each column of the table.
Parameters
@ -533,7 +531,7 @@ class Table(VGroup):
column.set_color(color)
return self
def set_row_colors(self, *colors: Iterable[Color]) -> Table:
def set_row_colors(self, *colors: Iterable[ParsableManimColor]) -> Table:
"""Set individual colors for each row of the table.
Parameters
@ -752,10 +750,10 @@ class Table(VGroup):
label_group.add(*label)
return label_group
def add_background_to_entries(self, color: Color = BLACK) -> Table:
def add_background_to_entries(self, color: ParsableManimColor = BLACK) -> Table:
"""Adds a black :class:`~.BackgroundRectangle` to each entry of the table."""
for mob in self.get_entries():
mob.add_background_rectangle(color=color)
mob.add_background_rectangle(color=ManimColor(color))
return self
def get_cell(self, pos: Sequence[int] = (1, 1), **kwargs) -> Polygon:
@ -816,7 +814,7 @@ class Table(VGroup):
return rec
def get_highlighted_cell(
self, pos: Sequence[int] = (1, 1), color: Color = YELLOW, **kwargs
self, pos: Sequence[int] = (1, 1), color: ParsableManimColor = YELLOW, **kwargs
) -> BackgroundRectangle:
"""Returns a :class:`~.BackgroundRectangle` of the cell at the given position.
@ -848,11 +846,11 @@ class Table(VGroup):
self.add(table)
"""
cell = self.get_cell(pos)
bg_cell = BackgroundRectangle(cell, color=color, **kwargs)
bg_cell = BackgroundRectangle(cell, color=ManimColor(color), **kwargs)
return bg_cell
def add_highlighted_cell(
self, pos: Sequence[int] = (1, 1), color: Color = YELLOW, **kwargs
self, pos: Sequence[int] = (1, 1), color: ParsableManimColor = YELLOW, **kwargs
) -> Table:
"""Highlights one cell at a specific position on the table by adding a :class:`~.BackgroundRectangle`.
@ -882,7 +880,7 @@ class Table(VGroup):
table.add_highlighted_cell((2,2), color=GREEN)
self.add(table)
"""
bg_cell = self.get_highlighted_cell(pos, color=color, **kwargs)
bg_cell = self.get_highlighted_cell(pos, color=ManimColor(color), **kwargs)
self.add_to_back(bg_cell)
entry = self.get_entries(pos)
entry.background_rectangle = bg_cell

View file

@ -12,6 +12,8 @@ r"""Mobjects representing text rendered using LaTeX.
from __future__ import annotations
from manim.utils.color import ManimColor
__all__ = [
"SingleStringMathTex",
"MathTex",
@ -28,8 +30,6 @@ from functools import reduce
from textwrap import dedent
from typing import Dict, Iterable, Optional
from colour import Color
from manim import config, logger
from manim.constants import *
from manim.mobject.geometry.line import Line
@ -253,7 +253,7 @@ class MathTex(SingleStringMathTex):
*tex_strings,
arg_separator: str = " ",
substrings_to_isolate: Iterable[str] | None = None,
tex_to_color_map: dict[str, Color] = None,
tex_to_color_map: dict[str, ManimColor] = None,
tex_environment: str = "align*",
**kwargs,
):

View file

@ -63,7 +63,6 @@ from typing import Iterable, Sequence
import manimpango
import numpy as np
from colour import Color
from manimpango import MarkupUtils, PangoUtils, TextSetting
from manim import config, logger
@ -71,7 +70,7 @@ from manim.constants import *
from manim.mobject.geometry.arc import Dot
from manim.mobject.svg.svg_mobject import SVGMobject
from manim.mobject.types.vectorized_mobject import VGroup, VMobject
from manim.utils.color import Colors, color_gradient
from manim.utils.color import ManimColor, ParsableManimColor, color_gradient
from manim.utils.deprecation import deprecated
TEXT_MOB_SCALE_FACTOR = 0.05
@ -148,7 +147,7 @@ class Paragraph(VGroup):
self,
*text: Sequence[str],
line_spacing: float = -1,
alignment: Optional[str] = None,
alignment: str | None = None,
**kwargs,
) -> None:
self.line_spacing = line_spacing
@ -413,7 +412,7 @@ class Text(SVGMobject):
text: str,
fill_opacity: float = 1.0,
stroke_width: float = 0,
color: Color | str | None = None,
color: ParsableManimColor | None = None,
font_size: float = DEFAULT_FONT_SIZE,
line_spacing: float = -1,
font: str = "",
@ -482,7 +481,7 @@ class Text(SVGMobject):
else:
self.line_spacing = self._font_size + self._font_size * self.line_spacing
color = Color(color) if color else VMobject().color
color: ManimColor = ManimColor(color) if color else VMobject().color
file_name = self._text2svg(color)
PangoUtils.remove_last_M(file_name)
super().__init__(
@ -643,10 +642,10 @@ class Text(SVGMobject):
for start, end in self._find_indexes(word, self.text):
self.chars[start:end].set_color_by_gradient(*gradient)
def _text2hash(self, color: Color):
def _text2hash(self, color: ManimColor):
"""Generates ``sha256`` hash for file name."""
settings = (
"PANGO" + self.font + self.slant + self.weight + color.hex_l
"PANGO" + self.font + self.slant + self.weight + str(color)
) # to differentiate Text and CairoText
settings += str(self.t2f) + str(self.t2s) + str(self.t2w) + str(self.t2c)
settings += str(self.line_spacing) + str(self._font_size)
@ -691,7 +690,9 @@ class Text(SVGMobject):
t2xwords = set(chain(*([*t2x.keys()] for t2x, _ in t2xs)))
for word in t2xwords:
setting_args = {
arg: t2x[word] if word in t2x else default_args[arg]
arg: str(t2x[word]) if word in t2x else default_args[arg]
# NOTE: when t2x[word] is a ManimColor, str will yield the
# hex representation
for t2x, arg in t2xs
}
@ -707,13 +708,13 @@ class Text(SVGMobject):
if self.gradient:
colors = color_gradient(self.gradient, len(self.text))
for i in range(len(self.text)):
args["color"] = colors[i].hex
args["color"] = colors[i].to_hex()
settings.append(TextSetting(i, i + 1, **args))
for word, gradient in self.t2g.items():
if isinstance(gradient, str) or len(gradient) == 1:
color = gradient if isinstance(gradient, str) else gradient[0]
gradient = [Color(color)]
gradient = [ManimColor(color)]
colors = (
color_gradient(gradient, len(word))
if len(gradient) != 1
@ -721,11 +722,11 @@ class Text(SVGMobject):
)
for start, end in self._find_indexes(word, self.text):
for i in range(start, end):
args["color"] = colors[i - start].hex
args["color"] = colors[i - start].to_hex()
settings.append(TextSetting(i, i + 1, **args))
return settings
def _text2settings(self, color: Color):
def _text2settings(self, color: str):
"""Converts the texts and styles to a setting for parsing."""
t2xs = [
(self.t2f, "font"),
@ -734,6 +735,7 @@ class Text(SVGMobject):
(self.t2c, "color"),
]
# setting_args requires values to be strings
default_args = {
arg: getattr(self, arg) if arg != "color" else str(color) for _, arg in t2xs
}
@ -791,7 +793,7 @@ class Text(SVGMobject):
return settings
def _text2svg(self, color: Color):
def _text2svg(self, color: ManimColor):
"""Convert the text to SVG using Pango."""
size = self._font_size
line_spacing = self.line_spacing
@ -1136,7 +1138,7 @@ class MarkupText(SVGMobject):
text: str,
fill_opacity: float = 1,
stroke_width: float = 0,
color: Color | None = None,
color: ParsableManimColor | None = None,
font_size: float = DEFAULT_FONT_SIZE,
line_spacing: int = -1,
font: str = "",
@ -1189,7 +1191,7 @@ class MarkupText(SVGMobject):
else:
self.line_spacing = self._font_size + self._font_size * self.line_spacing
color = Color(color) if color else VMobject().color
color: ManimColor = ManimColor(color) if color else VMobject().color
file_name = self._text2svg(color)
PangoUtils.remove_last_M(file_name)
@ -1305,10 +1307,14 @@ class MarkupText(SVGMobject):
else:
self.scale(font_val / self.font_size)
def _text2hash(self, color: Color):
def _text2hash(self, color: ManimColor):
"""Generates ``sha256`` hash for file name."""
settings = (
"MARKUPPANGO" + self.font + self.slant + self.weight + color.hex_l
"MARKUPPANGO"
+ self.font
+ self.slant
+ self.weight
+ ManimColor(color).to_hex().lower()
) # to differentiate from classical Pango Text
settings += str(self.line_spacing) + str(self._font_size)
settings += str(self.disable_ligatures)
@ -1318,7 +1324,7 @@ class MarkupText(SVGMobject):
hasher.update(id_str.encode())
return hasher.hexdigest()[:16]
def _text2svg(self, color: Color | None):
def _text2svg(self, color: ManimColor):
"""Convert the text to SVG using Pango."""
size = self._font_size
line_spacing = self.line_spacing
@ -1326,15 +1332,16 @@ class MarkupText(SVGMobject):
line_spacing /= TEXT2SVG_ADJUSTMENT_FACTOR
dir_name = config.get_dir("text_dir")
if not dir_name.exists():
if not dir_name.is_dir():
dir_name.mkdir(parents=True)
hash_name = self._text2hash(color)
file_name = dir_name / (hash_name + ".svg")
if file_name.exists():
svg_file = str(file_name.resolve())
else:
final_text = (
f'<span foreground="{color}">{self.text}</span>'
f'<span foreground="{color.to_hex()}">{self.text}</span>'
if color is not None
else self.text
)
@ -1412,7 +1419,7 @@ class MarkupText(SVGMobject):
if re.match("#[0-9a-f]{6}", col):
return col
else:
return Colors[col.lower()].value
return ManimColor(col).to_hex()
def _extract_color_tags(self):
"""Used to determine which parts (if any) of the string should be formatted

View file

@ -16,7 +16,7 @@ __all__ = [
"Torus",
]
from typing import TYPE_CHECKING
from typing import Callable, Sequence
import numpy as np
@ -28,15 +28,19 @@ from manim.mobject.mobject import *
from manim.mobject.opengl.opengl_compatibility import ConvertToOpenGL
from manim.mobject.opengl.opengl_mobject import OpenGLMobject
from manim.mobject.types.vectorized_mobject import VGroup, VMobject
from manim.utils.color import *
from manim.utils.color import (
BLUE,
BLUE_D,
BLUE_E,
LIGHT_GREY,
WHITE,
ManimColor,
ParsableManimColor,
interpolate_color,
)
from manim.utils.iterables import tuplify
from manim.utils.space_ops import normalize, perpendicular_bisector, z_to_vector
if TYPE_CHECKING:
from typing import *
from colour import Color
class ThreeDVMobject(VMobject, metaclass=ConvertToOpenGL):
def __init__(self, shade_in_3d: bool = True, **kwargs):
@ -102,10 +106,10 @@ class Surface(VGroup, metaclass=ConvertToOpenGL):
v_range: Sequence[float] = [0, 1],
resolution: Sequence[int] = 32,
surface_piece_config: dict = {},
fill_color: Color = BLUE_D,
fill_color: ParsableManimColor = BLUE_D,
fill_opacity: float = 1.0,
checkerboard_colors: Sequence[Color] = [BLUE_D, BLUE_E],
stroke_color: Color = LIGHT_GREY,
checkerboard_colors: Sequence[ParsableManimColor] | bool = [BLUE_D, BLUE_E],
stroke_color: ParsableManimColor = LIGHT_GREY,
stroke_width: float = 0.5,
should_make_jagged: bool = False,
pre_function_handle_to_anchor_scale_factor: float = 0.00001,
@ -116,10 +120,15 @@ class Surface(VGroup, metaclass=ConvertToOpenGL):
super().__init__(**kwargs)
self.resolution = resolution
self.surface_piece_config = surface_piece_config
self.fill_color = fill_color
self.fill_color: ManimColor = ManimColor(fill_color)
self.fill_opacity = fill_opacity
self.checkerboard_colors = checkerboard_colors
self.stroke_color = stroke_color
if checkerboard_colors:
self.checkerboard_colors: list[ManimColor] = [
ManimColor(x) for x in checkerboard_colors
]
else:
self.checkerboard_colors = checkerboard_colors
self.stroke_color: ManimColor = ManimColor(stroke_color)
self.stroke_width = stroke_width
self.should_make_jagged = should_make_jagged
self.pre_function_handle_to_anchor_scale_factor = (
@ -188,7 +197,7 @@ class Surface(VGroup, metaclass=ConvertToOpenGL):
self.set_fill_by_checkerboard(*self.checkerboard_colors)
def set_fill_by_checkerboard(
self, *colors: Sequence[Color], opacity: float = None
self, *colors: Sequence[ParsableManimColor], opacity: float = None
) -> Mobject:
"""Sets the fill_color of each face of :class:`Surface` in
an alternating pattern.
@ -215,7 +224,7 @@ class Surface(VGroup, metaclass=ConvertToOpenGL):
def set_fill_by_value(
self,
axes: Mobject,
colorscale: Union[Iterable[Color], Color] | None = None,
colorscale: list[ParsableManimColor] | ParsableManimColor | None = None,
axis: int = 2,
**kwargs,
) -> Mobject:
@ -449,8 +458,8 @@ class Dot3D(Sphere):
self,
point: list | np.ndarray = ORIGIN,
radius: float = DEFAULT_DOT_RADIUS,
color: Color = WHITE,
resolution: Sequence[int] = (8, 8),
color: ParsableManimColor = WHITE,
resolution=(8, 8),
**kwargs,
) -> None:
super().__init__(center=point, radius=radius, resolution=resolution, **kwargs)
@ -491,7 +500,7 @@ class Cube(VGroup):
self,
side_length: float = 2,
fill_opacity: float = 0.75,
fill_color: Color = BLUE,
fill_color: ParsableManimColor = BLUE,
stroke_width: float = 0,
**kwargs,
) -> None:
@ -901,7 +910,7 @@ class Line3D(Cylinder):
start: np.ndarray = LEFT,
end: np.ndarray = RIGHT,
thickness: float = 0.02,
color: Color = None,
color: ParsableManimColor = None,
**kwargs,
):
self.thickness = thickness
@ -1124,7 +1133,7 @@ class Arrow3D(Line3D):
thickness: float = 0.02,
height: float = 0.3,
base_radius: float = 0.08,
color: Color = WHITE,
color: ParsableManimColor = WHITE,
**kwargs,
) -> None:
super().__init__(

View file

@ -6,7 +6,6 @@ __all__ = ["AbstractImageMobject", "ImageMobject", "ImageMobjectFromCamera"]
import pathlib
import colour
import numpy as np
from PIL import Image
from PIL.Image import Resampling
@ -17,7 +16,7 @@ from ... import config
from ...constants import *
from ...mobject.mobject import Mobject
from ...utils.bezier import interpolate
from ...utils.color import WHITE, color_to_int_rgb
from ...utils.color import WHITE, ManimColor, color_to_int_rgb
from ...utils.images import change_to_rgba_array, get_full_raster_image_path
@ -277,7 +276,7 @@ class ImageMobject(AbstractImageMobject):
def get_style(self):
return {
"fill_color": colour.rgb2hex(self.color.get_rgb()),
"fill_color": ManimColor(self.color.get_rgb()).to_hex(),
"fill_opacity": self.fill_opacity,
}

View file

@ -5,7 +5,6 @@ from __future__ import annotations
__all__ = ["PMobject", "Mobject1D", "Mobject2D", "PGroup", "PointCloudDot", "Point"]
import numpy as np
from colour import Color
from manim.mobject.opengl.opengl_compatibility import ConvertToOpenGL
from manim.mobject.opengl.opengl_point_cloud_mobject import OpenGLPMobject
@ -17,6 +16,7 @@ from ...utils.color import (
BLACK,
WHITE,
YELLOW,
ManimColor,
color_gradient,
color_to_rgba,
rgba_to_color,
@ -76,7 +76,7 @@ class PMobject(Mobject, metaclass=ConvertToOpenGL):
num_new_points = len(points)
self.points = np.append(self.points, points, axis=0)
if rgbas is None:
color = Color(color) if color else self.color
color = ManimColor(color) if color else self.color
rgbas = np.repeat([color_to_rgba(color, alpha)], num_new_points, axis=0)
elif len(rgbas) != len(points):
raise ValueError("points and rgbas must have same length")

View file

@ -15,9 +15,8 @@ __all__ = [
import itertools as it
import sys
import typing
from typing import Callable, Optional, Sequence, Union
from typing import Callable, Sequence
import colour
import numpy as np
from PIL.Image import Image
@ -38,8 +37,7 @@ from ...utils.bezier import (
partial_bezier_points,
proportions_along_bezier_curve_for_point,
)
from ...utils.color import BLACK, WHITE, color_to_rgba
from ...utils.deprecation import deprecated
from ...utils.color import BLACK, WHITE, ManimColor, ParsableManimColor
from ...utils.iterables import make_even, resize_array, stretch_array_to_length, tuplify
from ...utils.space_ops import rotate_vector, shoelace_direction
@ -81,12 +79,12 @@ class VMobject(Mobject):
def __init__(
self,
fill_color=None,
fill_color: ParsableManimColor | None = None,
fill_opacity=0.0,
stroke_color=None,
stroke_color: ParsableManimColor | None = None,
stroke_opacity=1.0,
stroke_width=DEFAULT_STROKE_WIDTH,
background_stroke_color=BLACK,
background_stroke_color: ParsableManimColor | None = BLACK,
background_stroke_opacity=1.0,
background_stroke_width=0,
sheen_factor=0.0,
@ -105,7 +103,10 @@ class VMobject(Mobject):
self.fill_opacity = fill_opacity
self.stroke_opacity = stroke_opacity
self.stroke_width = stroke_width
self.background_stroke_color = background_stroke_color
if background_stroke_color is not None:
self.background_stroke_color: ManimColor = ManimColor(
background_stroke_color
)
self.background_stroke_opacity = background_stroke_opacity
self.background_stroke_width = background_stroke_width
self.sheen_factor = sheen_factor
@ -123,11 +124,16 @@ class VMobject(Mobject):
self.tolerance_for_point_equality = tolerance_for_point_equality
self.n_points_per_cubic_curve = n_points_per_cubic_curve
super().__init__(**kwargs)
self.submobjects: list[VMobject]
if fill_color:
self.fill_color = fill_color
if stroke_color:
self.stroke_color = stroke_color
# TODO: Find where color overwrites are happening and remove the color doubling
# if "color" in kwargs:
# fill_color = kwargs["color"]
# stroke_color = kwargs["color"]
if fill_color is not None:
self.fill_color = ManimColor.parse(fill_color)
if stroke_color is not None:
self.stroke_color = ManimColor.parse(stroke_color)
# OpenGL compatibility
@property
@ -172,7 +178,7 @@ class VMobject(Mobject):
return self
def generate_rgbas_array(self, color, opacity):
def generate_rgbas_array(self, color: ManimColor | list[ManimColor], opacity):
"""
First arg can be either a color, or a tuple/list of colors.
Likewise, opacity can either be a float, or a tuple of floats.
@ -180,10 +186,12 @@ class VMobject(Mobject):
one color was passed in, a second slightly light color
will automatically be added for the gradient
"""
colors = [c if (c is not None) else BLACK for c in tuplify(color)]
opacities = [o if (o is not None) else 0 for o in tuplify(opacity)]
colors: list[ManimColor] = [
ManimColor(c) if (c is not None) else BLACK for c in tuplify(color)
]
opacities: list[float] = [o if (o is not None) else 0 for o in tuplify(opacity)]
rgbas = np.array(
[color_to_rgba(c, o) for c, o in zip(*make_even(colors, opacities))],
[c.to_rgba_with_alpha(o) for c, o in zip(*make_even(colors, opacities))],
)
sheen_factor = self.get_sheen_factor()
@ -194,7 +202,9 @@ class VMobject(Mobject):
rgbas = np.append(rgbas, light_rgbas, axis=0)
return rgbas
def update_rgbas_array(self, array_name, color=None, opacity=None):
def update_rgbas_array(
self, array_name, color: ManimColor | None = None, opacity=None
):
rgbas = self.generate_rgbas_array(color, opacity)
if not hasattr(self, array_name):
setattr(self, array_name, rgbas)
@ -217,7 +227,7 @@ class VMobject(Mobject):
def set_fill(
self,
color: str | None = None,
color: ParsableManimColor | None = None,
opacity: float | None = None,
family: bool = True,
):
@ -266,7 +276,7 @@ class VMobject(Mobject):
def set_stroke(
self,
color=None,
color: ParsableManimColor = None,
width=None,
opacity=None,
background=False,
@ -289,7 +299,10 @@ class VMobject(Mobject):
if opacity is not None:
setattr(self, opacity_name, opacity)
if color is not None and background:
self.background_stroke_color = color
if isinstance(color, (list, tuple)):
self.background_stroke_color = color
else:
self.background_stroke_color = ManimColor(color)
return self
def set_background_stroke(self, **kwargs):
@ -299,12 +312,12 @@ class VMobject(Mobject):
def set_style(
self,
fill_color=None,
fill_opacity=None,
stroke_color=None,
fill_color: ParsableManimColor | None = None,
fill_opacity: float | None = None,
stroke_color: ParsableManimColor | None = None,
stroke_width=None,
stroke_opacity=None,
background_stroke_color=None,
background_stroke_color: ParsableManimColor = None,
background_stroke_width=None,
background_stroke_opacity=None,
sheen_factor=None,
@ -341,10 +354,11 @@ class VMobject(Mobject):
"stroke_width": self.get_stroke_width(),
}
# TODO: FIX COLORS HERE
if simple:
ret["fill_color"] = colour.rgb2hex(self.get_fill_color().get_rgb())
ret["fill_color"] = self.get_fill_color()
ret["fill_opacity"] = self.get_fill_opacity()
ret["stroke_color"] = colour.rgb2hex(self.get_stroke_color().get_rgb())
ret["stroke_color"] = self.get_stroke_color()
else:
ret["fill_color"] = self.get_fill_colors()
ret["fill_opacity"] = self.get_fill_opacities()
@ -373,7 +387,7 @@ class VMobject(Mobject):
sm1.match_style(sm2)
return self
def set_color(self, color, family=True):
def set_color(self, color: ParsableManimColor, family=True):
self.set_fill(color, family=family)
self.set_stroke(color, family=family)
return self
@ -417,9 +431,10 @@ class VMobject(Mobject):
"""
return self.get_fill_opacities()[0]
# TODO: Does this just do a copy?
def get_fill_colors(self):
return [
colour.Color(rgb=rgba[:3]) if rgba.any() else None
ManimColor(rgba[:3]) if rgba.any() else None
for rgba in self.get_fill_rgbas()
]
@ -455,7 +470,7 @@ class VMobject(Mobject):
def get_stroke_colors(self, background=False):
return [
colour.Color(rgb=rgba[:3]) if rgba.any() else None
ManimColor(rgba[:3]) if rgba.any() else None
for rgba in self.get_stroke_rgbas(background)
]

View file

@ -14,7 +14,6 @@ from math import ceil, floor
from typing import Callable, Iterable, Sequence
import numpy as np
from colour import Color
from PIL import Image
from manim.animation.updaters.update import UpdateFromAlphaFunc
@ -30,7 +29,16 @@ from ..mobject.mobject import Mobject
from ..mobject.types.vectorized_mobject import VGroup
from ..mobject.utils import get_vectorized_mobject_class
from ..utils.bezier import interpolate, inverse_interpolate
from ..utils.color import BLUE_E, GREEN, RED, YELLOW, color_to_rgb, rgb_to_color
from ..utils.color import (
BLUE_E,
GREEN,
RED,
YELLOW,
ManimColor,
ParsableManimColor,
color_to_rgb,
rgb_to_color,
)
from ..utils.rate_functions import ease_out_sine, linear
from ..utils.simple_functions import sigmoid
@ -66,11 +74,11 @@ class VectorField(VGroup):
def __init__(
self,
func: Callable[[np.ndarray], np.ndarray],
color: Color | None = None,
color: ParsableManimColor | None = None,
color_scheme: Callable[[np.ndarray], float] | None = None,
min_color_scheme_value: float = 0,
max_color_scheme_value: float = 2,
colors: Sequence[Color] = DEFAULT_SCALAR_FIELD_COLORS,
colors: Sequence[ParsableManimColor] = DEFAULT_SCALAR_FIELD_COLORS,
**kwargs,
):
super().__init__(**kwargs)
@ -107,7 +115,7 @@ class VectorField(VGroup):
self.pos_to_color = lambda pos: rgb_to_color(self.pos_to_rgb(pos))
else:
self.single_color = True
self.color = color
self.color = ManimColor.parse(color)
self.submob_movement_updater = None
@staticmethod
@ -409,7 +417,7 @@ class VectorField(VGroup):
self,
start: float,
end: float,
colors: Iterable,
colors: Iterable[ParsableManimColor],
):
"""
Generates a gradient of rgbas as a numpy array
@ -533,11 +541,11 @@ class ArrowVectorField(VectorField):
def __init__(
self,
func: Callable[[np.ndarray], np.ndarray],
color: Color | None = None,
color: ParsableManimColor | None = None,
color_scheme: Callable[[np.ndarray], float] | None = None,
min_color_scheme_value: float = 0,
max_color_scheme_value: float = 2,
colors: Sequence[Color] = DEFAULT_SCALAR_FIELD_COLORS,
colors: Sequence[ParsableManimColor] = DEFAULT_SCALAR_FIELD_COLORS,
# Determining Vector positions:
x_range: Sequence[float] = None,
y_range: Sequence[float] = None,
@ -707,11 +715,11 @@ class StreamLines(VectorField):
def __init__(
self,
func: Callable[[np.ndarray], np.ndarray],
color: Color | None = None,
color: ParsableManimColor | None = None,
color_scheme: Callable[[np.ndarray], float] | None = None,
min_color_scheme_value: float = 0,
max_color_scheme_value: float = 2,
colors: Sequence[Color] = DEFAULT_SCALAR_FIELD_COLORS,
colors: Sequence[ParsableManimColor] = DEFAULT_SCALAR_FIELD_COLORS,
# Determining stream line starting positions:
x_range: Sequence[float] = None,
y_range: Sequence[float] = None,

View file

@ -9,7 +9,7 @@ from .. import config, logger
__all__ = []
plugins_requested: list = config["plugins"]
plugins_requested: list[str] = config["plugins"]
if "" in plugins_requested:
plugins_requested.remove("")
for plugin in pkg_resources.iter_entry_points("manim.plugins"):

View file

@ -7,7 +7,6 @@ __all__ = ["VectorScene", "LinearTransformationScene"]
from typing import Callable
import numpy as np
from colour import Color
from manim.mobject.geometry.arc import Dot
from manim.mobject.geometry.line import Arrow, Line, Vector
@ -28,7 +27,17 @@ from ..mobject.matrix import Matrix
from ..mobject.mobject import Mobject
from ..mobject.types.vectorized_mobject import VGroup, VMobject
from ..scene.scene import Scene
from ..utils.color import BLUE_D, GREEN_C, GREY, RED_C, WHITE, YELLOW
from ..utils.color import (
BLACK,
BLUE_D,
GREEN_C,
GREY,
RED_C,
WHITE,
YELLOW,
ManimColor,
ParsableManimColor,
)
from ..utils.rate_functions import rush_from, rush_into
from ..utils.space_ops import angle_of_vector
@ -581,8 +590,8 @@ class LinearTransformationScene(VectorScene):
show_coordinates: bool = False,
show_basis_vectors: bool = True,
basis_vector_stroke_width: float = 6,
i_hat_color: Color = X_COLOR,
j_hat_color: Color = Y_COLOR,
i_hat_color: ParsableManimColor = X_COLOR,
j_hat_color: ParsableManimColor = Y_COLOR,
leave_ghost_vectors: bool = False,
**kwargs,
):
@ -593,8 +602,8 @@ class LinearTransformationScene(VectorScene):
self.show_coordinates = show_coordinates
self.show_basis_vectors = show_basis_vectors
self.basis_vector_stroke_width = basis_vector_stroke_width
self.i_hat_color = i_hat_color
self.j_hat_color = j_hat_color
self.i_hat_color = ManimColor(i_hat_color)
self.j_hat_color = ManimColor(j_hat_color)
self.leave_ghost_vectors = leave_ghost_vectors
self.background_plane_kwargs = {
"color": GREY,

View file

@ -1,552 +0,0 @@
"""Colors and utility functions for conversion between different color models."""
from __future__ import annotations
__all__ = [
"color_to_rgb",
"color_to_rgba",
"rgb_to_color",
"rgba_to_color",
"rgb_to_hex",
"hex_to_rgb",
"invert_color",
"color_to_int_rgb",
"color_to_int_rgba",
"color_gradient",
"interpolate_color",
"average_color",
"random_bright_color",
"random_color",
"get_shaded_rgb",
]
import random
from enum import Enum
from typing import Iterable
import numpy as np
from colour import Color
from ..utils.bezier import interpolate
from ..utils.space_ops import normalize
class Colors(Enum):
"""A list of pre-defined colors.
Examples
--------
.. manim:: ColorsOverview
:save_last_frame:
:hide_source:
from manim.utils.color import Colors
class ColorsOverview(Scene):
def construct(self):
def color_group(color):
group = VGroup(
*[
Line(ORIGIN, RIGHT * 1.5, stroke_width=35, color=Colors[name].value)
for name in subnames(color)
]
).arrange_submobjects(buff=0.4, direction=DOWN)
name = Text(color).scale(0.6).next_to(group, UP, buff=0.3)
if any(decender in color for decender in "gjpqy"):
name.shift(DOWN * 0.08)
group.add(name)
return group
def subnames(name):
return [name + "_" + char for char in "abcde"]
color_groups = VGroup(
*[
color_group(color)
for color in [
"blue",
"teal",
"green",
"yellow",
"gold",
"red",
"maroon",
"purple",
]
]
).arrange_submobjects(buff=0.2, aligned_edge=DOWN)
for line, char in zip(color_groups[0], "abcde"):
color_groups.add(Text(char).scale(0.6).next_to(line, LEFT, buff=0.2))
def named_lines_group(length, colors, names, text_colors, align_to_block):
lines = VGroup(
*[
Line(
ORIGIN,
RIGHT * length,
stroke_width=55,
color=Colors[color].value,
)
for color in colors
]
).arrange_submobjects(buff=0.6, direction=DOWN)
for line, name, color in zip(lines, names, text_colors):
line.add(Text(name, color=color).scale(0.6).move_to(line))
lines.next_to(color_groups, DOWN, buff=0.5).align_to(
color_groups[align_to_block], LEFT
)
return lines
other_colors = (
"pink",
"light_pink",
"orange",
"light_brown",
"dark_brown",
"gray_brown",
)
other_lines = named_lines_group(
3.2,
other_colors,
other_colors,
[BLACK] * 4 + [WHITE] * 2,
0,
)
gray_lines = named_lines_group(
6.6,
["white"] + subnames("gray") + ["black"],
[
"white",
"lighter_gray / gray_a",
"light_gray / gray_b",
"gray / gray_c",
"dark_gray / gray_d",
"darker_gray / gray_e",
"black",
],
[BLACK] * 3 + [WHITE] * 4,
2,
)
pure_colors = (
"pure_red",
"pure_green",
"pure_blue",
)
pure_lines = named_lines_group(
3.2,
pure_colors,
pure_colors,
[BLACK, BLACK, WHITE],
6,
)
self.add(color_groups, other_lines, gray_lines, pure_lines)
VGroup(*self.mobjects).move_to(ORIGIN)
The preferred way of using these colors is by importing their constants from manim:
.. code-block:: pycon
>>> from manim import RED, GREEN, BLUE
>>> RED
'#FC6255'
Note this way uses the name of the colors in UPPERCASE.
Alternatively, you can also import this Enum directly and use its members
directly, through the use of :code:`color.value`. Note this way uses the
name of the colors in lowercase.
.. code-block:: pycon
>>> from manim.utils.color import Colors
>>> Colors.red.value
'#FC6255'
.. note::
The colors of type "C" have an alias equal to the colorname without a letter,
e.g. GREEN = GREEN_C
"""
white: str = "#FFFFFF"
gray_a: str = "#DDDDDD"
gray_b: str = "#BBBBBB"
gray_c: str = "#888888"
gray_d: str = "#444444"
gray_e: str = "#222222"
black: str = "#000000"
lighter_gray: str = gray_a
light_gray: str = gray_b
gray: str = gray_c
dark_gray: str = gray_d
darker_gray: str = gray_e
blue_a: str = "#C7E9F1"
blue_b: str = "#9CDCEB"
blue_c: str = "#58C4DD"
blue_d: str = "#29ABCA"
blue_e: str = "#236B8E"
pure_blue: str = "#0000FF"
blue: str = blue_c
dark_blue: str = blue_e
teal_a: str = "#ACEAD7"
teal_b: str = "#76DDC0"
teal_c: str = "#5CD0B3"
teal_d: str = "#55C1A7"
teal_e: str = "#49A88F"
teal: str = teal_c
green_a: str = "#C9E2AE"
green_b: str = "#A6CF8C"
green_c: str = "#83C167"
green_d: str = "#77B05D"
green_e: str = "#699C52"
pure_green: str = "#00FF00"
green: str = green_c
yellow_a: str = "#FFF1B6"
yellow_b: str = "#FFEA94"
yellow_c: str = "#FFFF00"
yellow_d: str = "#F4D345"
yellow_e: str = "#E8C11C"
yellow: str = yellow_c
gold_a: str = "#F7C797"
gold_b: str = "#F9B775"
gold_c: str = "#F0AC5F"
gold_d: str = "#E1A158"
gold_e: str = "#C78D46"
gold: str = gold_c
red_a: str = "#F7A1A3"
red_b: str = "#FF8080"
red_c: str = "#FC6255"
red_d: str = "#E65A4C"
red_e: str = "#CF5044"
pure_red: str = "#FF0000"
red: str = red_c
maroon_a: str = "#ECABC1"
maroon_b: str = "#EC92AB"
maroon_c: str = "#C55F73"
maroon_d: str = "#A24D61"
maroon_e: str = "#94424F"
maroon: str = maroon_c
purple_a: str = "#CAA3E8"
purple_b: str = "#B189C6"
purple_c: str = "#9A72AC"
purple_d: str = "#715582"
purple_e: str = "#644172"
purple: str = purple_c
pink: str = "#D147BD"
light_pink: str = "#DC75CD"
orange: str = "#FF862F"
light_brown: str = "#CD853F"
dark_brown: str = "#8B4513"
gray_brown: str = "#736357"
def print_constant_definitions():
"""
A simple function used to generate the constant values below. To run it
paste this function and the Colors class into a file and run them.
"""
constants_names: list[str] = []
for name in Colors.__members__.keys():
name_upper = name.upper()
constants_names.append(name_upper)
print(f"{name_upper} = Colors.{name}")
if "GRAY" in name_upper:
name_upper = name_upper.replace("GRAY", "GREY")
constants_names.append(name_upper)
print(f"{name_upper} = Colors.{name}")
constants_names_repr = '[\n "' + '",\n "'.join(constants_names) + '",\n]'
print(f"\n__all__ += {constants_names_repr}")
WHITE: str = "#FFFFFF"
GRAY_A: str = "#DDDDDD"
GREY_A: str = "#DDDDDD"
GRAY_B: str = "#BBBBBB"
GREY_B: str = "#BBBBBB"
GRAY_C: str = "#888888"
GREY_C: str = "#888888"
GRAY_D: str = "#444444"
GREY_D: str = "#444444"
GRAY_E: str = "#222222"
GREY_E: str = "#222222"
BLACK: str = "#000000"
LIGHTER_GRAY: str = "#DDDDDD"
LIGHTER_GREY: str = "#DDDDDD"
LIGHT_GRAY: str = "#BBBBBB"
LIGHT_GREY: str = "#BBBBBB"
GRAY: str = "#888888"
GREY: str = "#888888"
DARK_GRAY: str = "#444444"
DARK_GREY: str = "#444444"
DARKER_GRAY: str = "#222222"
DARKER_GREY: str = "#222222"
BLUE_A: str = "#C7E9F1"
BLUE_B: str = "#9CDCEB"
BLUE_C: str = "#58C4DD"
BLUE_D: str = "#29ABCA"
BLUE_E: str = "#236B8E"
PURE_BLUE: str = "#0000FF"
BLUE: str = "#58C4DD"
DARK_BLUE: str = "#236B8E"
TEAL_A: str = "#ACEAD7"
TEAL_B: str = "#76DDC0"
TEAL_C: str = "#5CD0B3"
TEAL_D: str = "#55C1A7"
TEAL_E: str = "#49A88F"
TEAL: str = "#5CD0B3"
GREEN_A: str = "#C9E2AE"
GREEN_B: str = "#A6CF8C"
GREEN_C: str = "#83C167"
GREEN_D: str = "#77B05D"
GREEN_E: str = "#699C52"
PURE_GREEN: str = "#00FF00"
GREEN: str = "#83C167"
YELLOW_A: str = "#FFF1B6"
YELLOW_B: str = "#FFEA94"
YELLOW_C: str = "#FFFF00"
YELLOW_D: str = "#F4D345"
YELLOW_E: str = "#E8C11C"
YELLOW: str = "#FFFF00"
GOLD_A: str = "#F7C797"
GOLD_B: str = "#F9B775"
GOLD_C: str = "#F0AC5F"
GOLD_D: str = "#E1A158"
GOLD_E: str = "#C78D46"
GOLD: str = "#F0AC5F"
RED_A: str = "#F7A1A3"
RED_B: str = "#FF8080"
RED_C: str = "#FC6255"
RED_D: str = "#E65A4C"
RED_E: str = "#CF5044"
PURE_RED: str = "#FF0000"
RED: str = "#FC6255"
MAROON_A: str = "#ECABC1"
MAROON_B: str = "#EC92AB"
MAROON_C: str = "#C55F73"
MAROON_D: str = "#A24D61"
MAROON_E: str = "#94424F"
MAROON: str = "#C55F73"
PURPLE_A: str = "#CAA3E8"
PURPLE_B: str = "#B189C6"
PURPLE_C: str = "#9A72AC"
PURPLE_D: str = "#715582"
PURPLE_E: str = "#644172"
PURPLE: str = "#9A72AC"
PINK: str = "#D147BD"
LIGHT_PINK: str = "#DC75CD"
ORANGE: str = "#FF862F"
LIGHT_BROWN: str = "#CD853F"
DARK_BROWN: str = "#8B4513"
GRAY_BROWN: str = "#736357"
GREY_BROWN: str = "#736357"
__all__ += [
"WHITE",
"GRAY_A",
"GREY_A",
"GRAY_B",
"GREY_B",
"GRAY_C",
"GREY_C",
"GRAY_D",
"GREY_D",
"GRAY_E",
"GREY_E",
"BLACK",
"LIGHTER_GRAY",
"LIGHTER_GREY",
"LIGHT_GRAY",
"LIGHT_GREY",
"GRAY",
"GREY",
"DARK_GRAY",
"DARK_GREY",
"DARKER_GRAY",
"DARKER_GREY",
"BLUE_A",
"BLUE_B",
"BLUE_C",
"BLUE_D",
"BLUE_E",
"PURE_BLUE",
"BLUE",
"DARK_BLUE",
"TEAL_A",
"TEAL_B",
"TEAL_C",
"TEAL_D",
"TEAL_E",
"TEAL",
"GREEN_A",
"GREEN_B",
"GREEN_C",
"GREEN_D",
"GREEN_E",
"PURE_GREEN",
"GREEN",
"YELLOW_A",
"YELLOW_B",
"YELLOW_C",
"YELLOW_D",
"YELLOW_E",
"YELLOW",
"GOLD_A",
"GOLD_B",
"GOLD_C",
"GOLD_D",
"GOLD_E",
"GOLD",
"RED_A",
"RED_B",
"RED_C",
"RED_D",
"RED_E",
"PURE_RED",
"RED",
"MAROON_A",
"MAROON_B",
"MAROON_C",
"MAROON_D",
"MAROON_E",
"MAROON",
"PURPLE_A",
"PURPLE_B",
"PURPLE_C",
"PURPLE_D",
"PURPLE_E",
"PURPLE",
"PINK",
"LIGHT_PINK",
"ORANGE",
"LIGHT_BROWN",
"DARK_BROWN",
"GRAY_BROWN",
"GREY_BROWN",
]
def color_to_rgb(color: Color | str) -> np.ndarray:
if isinstance(color, str):
return hex_to_rgb(color)
elif isinstance(color, Color):
return np.array(color.get_rgb())
else:
raise ValueError("Invalid color type: " + str(color))
def color_to_rgba(color: Color | str, alpha: float = 1) -> np.ndarray:
return np.array([*color_to_rgb(color), alpha])
def rgb_to_color(rgb: Iterable[float]) -> Color:
return Color(rgb=rgb)
def rgba_to_color(rgba: Iterable[float]) -> Color:
return rgb_to_color(rgba[:3])
def rgb_to_hex(rgb: Iterable[float]) -> str:
return "#" + "".join("%02x" % round(255 * x) for x in rgb)
def hex_to_rgb(hex_code: str) -> np.ndarray:
hex_part = hex_code[1:]
if len(hex_part) == 3:
hex_part = "".join([2 * c for c in hex_part])
return np.array([int(hex_part[i : i + 2], 16) / 255 for i in range(0, 6, 2)])
def invert_color(color: Color) -> Color:
return rgb_to_color(1.0 - color_to_rgb(color))
def color_to_int_rgb(color: Color) -> np.ndarray:
return (255 * color_to_rgb(color)).astype("uint8")
def color_to_int_rgba(color: Color, opacity: float = 1.0) -> np.ndarray:
alpha_multiplier = np.vectorize(lambda x: int(x * opacity))
return alpha_multiplier(np.append(color_to_int_rgb(color), 255))
def color_gradient(
reference_colors: Iterable[Color],
length_of_output: int,
) -> list[Color]:
if length_of_output == 0:
return reference_colors[0]
rgbs = list(map(color_to_rgb, reference_colors))
alphas = np.linspace(0, (len(rgbs) - 1), length_of_output)
floors = alphas.astype("int")
alphas_mod1 = alphas % 1
# End edge case
alphas_mod1[-1] = 1
floors[-1] = len(rgbs) - 2
return [
rgb_to_color(interpolate(rgbs[i], rgbs[i + 1], alpha))
for i, alpha in zip(floors, alphas_mod1)
]
def interpolate_color(color1: Color, color2: Color, alpha: float) -> Color:
rgb = interpolate(color_to_rgb(color1), color_to_rgb(color2), alpha)
return rgb_to_color(rgb)
def average_color(*colors: Color) -> Color:
rgbs = np.array(list(map(color_to_rgb, colors)))
mean_rgb = np.apply_along_axis(np.mean, 0, rgbs)
return rgb_to_color(mean_rgb)
def random_bright_color() -> Color:
color = random_color()
curr_rgb = color_to_rgb(color)
new_rgb = interpolate(curr_rgb, np.ones(len(curr_rgb)), 0.5)
return Color(rgb=new_rgb)
def random_color() -> Color:
return random.choice([c.value for c in list(Colors)])
def get_shaded_rgb(
rgb: np.ndarray,
point: np.ndarray,
unit_normal_vect: np.ndarray,
light_source: np.ndarray,
) -> np.ndarray:
to_sun = normalize(light_source - point)
factor = 0.5 * np.dot(unit_normal_vect, to_sun) ** 3
if factor < 0:
factor *= 0.5
result = rgb + factor
return result

234
manim/utils/color/AS2700.py Normal file
View file

@ -0,0 +1,234 @@
"""Australian Color Standard
In 1985 the Australian Independent Color Standard AS 2700 was created. In
this standard, all colors can be identified via a category code (one of
B -- Blue, G -- Green, N -- Neutrals (grey), P -- Purple, R -- Red, T -- Blue/Green,
X -- Yellow/Red, Y -- Yellow) and a number. The colors also have (natural) names.
To use the colors from this list, access them directly from the module (which
is exposed to Manim's global name space):
.. code:: pycon
>>> from manim import AS2700
>>> AS2700.B23_BRIGHT_BLUE
ManimColor('#174F90')
List of Color Constants
-----------------------
These hex values (taken from https://www.w3schools.com/colors/colors_australia.asp)
are non official approximate values intended to simulate AS 2700 colors:
.. automanimcolormodule:: manim.utils.color.AS2700
"""
from .core import ManimColor
B11_RICH_BLUE = ManimColor("#2B3770")
B12_ROYAL_BLUE = ManimColor("#2C3563")
B13_NAVY_BLUE = ManimColor("#28304D")
B14_SAPHHIRE = ManimColor("#28426B")
B15_MID_BLUE = ManimColor("#144B6F")
B21_ULTRAMARINE = ManimColor("#2C5098")
B22_HOMEBUSH_BLUE = ManimColor("#215097")
B23_BRIGHT_BLUE = ManimColor("#174F90")
B24_HARBOUR_BLUE = ManimColor("#1C6293")
B25_AQUA = ManimColor("#5097AC")
B32_POWDER_BLUE = ManimColor("#B7C8DB")
B33_MIST_BLUE = ManimColor("#E0E6E2")
B34_PARADISE_BLUE = ManimColor("#3499BA")
B35_PALE_BLUE = ManimColor("#CDE4E2")
B41_BLUEBELL = ManimColor("#5B94D1")
B42_PURPLE_BLUE = ManimColor("#5E7899")
B43_GREY_BLUE = ManimColor("#627C8D")
B44_LIGHT_GREY_BLUE = ManimColor("#C0C0C1")
B45_SKY_BLUE = ManimColor("#7DB7C7")
B51_PERIWINKLE = ManimColor("#3871AC")
B53_DARK_GREY_BLUE = ManimColor("#4F6572")
B55_STORM_BLUE = ManimColor("#3F7C94")
B61_CORAL_SEA = ManimColor("#2B3873")
B62_MIDNIGHT_BLUE = ManimColor("#292A34")
B64_CHARCOAL = ManimColor("#363E45")
G11_BOTTLE_GREEN = ManimColor("#253A32")
G12_HOLLY = ManimColor("#21432D")
G13_EMERALD = ManimColor("#195F35")
G14_MOSS_GREEN = ManimColor("#33572D")
G15_RAINFOREST_GREEN = ManimColor("#3D492D")
G16_TRAFFIC_GREEN = ManimColor("#305442")
G17_MINT_GREEN = ManimColor("#006B45")
G21_JADE = ManimColor("#127453")
G22_SERPENTINE = ManimColor("#78A681")
G23_SHAMROCK = ManimColor("#336634")
G24_FERN_TREE = ManimColor("#477036")
G25_OLIVE = ManimColor("#595B2A")
G26_APPLE_GREEN = ManimColor("#4E9843")
G27_HOMEBUSH_GREEN = ManimColor("#017F4D")
G31_VERTIGRIS = ManimColor("#468A65")
G32_OPALINE = ManimColor("#AFCBB8")
G33_LETTUCE = ManimColor("#7B9954")
G34_AVOCADO = ManimColor("#757C4C")
G35_LIME_GREEN = ManimColor("#89922E")
G36_KIKUYU = ManimColor("#95B43B")
G37_BEANSTALK = ManimColor("#45A56A")
G41_LAWN_GREEN = ManimColor("#0D875D")
G42_GLACIER = ManimColor("#D5E1D2")
G43_SURF_GREEN = ManimColor("#C8C8A7")
G44_PALM_GREEN = ManimColor("#99B179")
G45_CHARTREUSE = ManimColor("#C7C98D")
G46_CITRONELLA = ManimColor("#BFC83E")
G47_CRYSTAL_GREEN = ManimColor("#ADCCA8")
G51_SPRUCE = ManimColor("#05674F")
G52_EUCALYPTUS = ManimColor("#66755B")
G53_BANKSIA = ManimColor("#929479")
G54_MIST_GREEN = ManimColor("#7A836D")
G55_LICHEN = ManimColor("#A7A98C")
G56_SAGE_GREEN = ManimColor("#677249")
G61_DARK_GREEN = ManimColor("#283533")
G62_RIVERGUM = ManimColor("#617061")
G63_DEEP_BRONZE_GREEN = ManimColor("#333334")
G64_SLATE = ManimColor("#5E6153")
G65_TI_TREE = ManimColor("#5D5F4E")
G66_ENVIRONMENT_GREEN = ManimColor("#484C3F")
G67_ZUCCHINI = ManimColor("#2E443A")
N11_PEARL_GREY = ManimColor("#D8D3C7")
N12_PASTEL_GREY = ManimColor("#CCCCCC")
N14_WHITE = ManimColor("#FFFFFF")
N15_HOMEBUSH_GREY = ManimColor("#A29B93")
N22_CLOUD_GREY = ManimColor("#C4C1B9")
N23_NEUTRAL_GREY = ManimColor("#CCCCCC")
N24_SILVER_GREY = ManimColor("#BDC7C5")
N25_BIRCH_GREY = ManimColor("#ABA498")
N32_GREEN_GREY = ManimColor("#8E9282")
N33_LIGHTBOX_GREY = ManimColor("#ACADAD")
N35_LIGHT_GREY = ManimColor("#A6A7A1")
N41_OYSTER = ManimColor("#998F78")
N42_STORM_GREY = ManimColor("#858F88")
N43_PIPELINE_GREY = ManimColor("#999999")
N44_BRIDGE_GREY = ManimColor("#767779")
N45_KOALA_GREY = ManimColor("#928F88")
N52_MID_GREY = ManimColor("#727A77")
N53_BLUE_GREY = ManimColor("#7C8588")
N54_BASALT = ManimColor("#585C63")
N55_LEAD_GREY = ManimColor("#5E5C58")
N61_BLACK = ManimColor("#2A2A2C")
N63_PEWTER = ManimColor("#596064")
N64_DARK_GREY = ManimColor("#4B5259")
N65_GRAPHITE_GREY = ManimColor("#45474A")
P11_MAGENTA = ManimColor("#7B2B48")
P12_PURPLE = ManimColor("#85467B")
P13_VIOLET = ManimColor("#5D3A61")
P14_BLUEBERRY = ManimColor("#4C4176")
P21_SUNSET_PINK = ManimColor("#E3BBBD")
P22_CYCLAMEN = ManimColor("#83597D")
P23_LILAC = ManimColor("#A69FB1")
P24_JACKARANDA = ManimColor("#795F91")
P31_DUSTY_PINK = ManimColor("#DBBEBC")
P33_RIBBON_PINK = ManimColor("#D1BCC9")
P41_ERICA_PINK = ManimColor("#C55A83")
P42_MULBERRY = ManimColor("#A06574")
P43_WISTERIA = ManimColor("#756D91")
P52_PLUM = ManimColor("#6E3D4B")
R11_INTERNATIONAL_ORANGE = ManimColor("#CE482A")
R12_SCARLET = ManimColor("#CD392A")
R13_SIGNAL_RED = ManimColor("#BA312B")
R14_WARATAH = ManimColor("#AA2429")
R15_CRIMSON = ManimColor("#9E2429")
R21_TANGERINE = ManimColor("#E96957")
R22_HOMEBUSH_RED = ManimColor("#D83A2D")
R23_LOLLIPOP = ManimColor("#CC5058")
R24_STRAWBERRY = ManimColor("#B4292A")
R25_ROSE_PINK = ManimColor("#E8919C")
R32_APPLE_BLOSSOM = ManimColor("#F2E1D8")
R33_GHOST_GUM = ManimColor("#E8DAD4")
R34_MUSHROOM = ManimColor("#D7C0B6")
R35_DEEP_ROSE = ManimColor("#CD6D71")
R41_SHELL_PINK = ManimColor("#F9D9BB")
R42_SALMON_PINK = ManimColor("#D99679")
R43_RED_DUST = ManimColor("#D0674F")
R44_POSSUM = ManimColor("#A18881")
R45_RUBY = ManimColor("#8F3E5C")
R51_BURNT_PINK = ManimColor("#E19B8E")
R52_TERRACOTTA = ManimColor("#A04C36")
R53_RED_GUM = ManimColor("#8D4338")
R54_RASPBERRY = ManimColor("#852F31")
R55_CLARET = ManimColor("#67292D")
R62_VENETIAN_RED = ManimColor("#77372B")
R63_RED_OXIDE = ManimColor("#663334")
R64_DEEP_INDIAN_RED = ManimColor("#542E2B")
R65_MAROON = ManimColor("#3F2B3C")
T11_TROPICAL_BLUE = ManimColor("#006698")
T12_DIAMANTIA = ManimColor("#006C74")
T14_MALACHITE = ManimColor("#105154")
T15_TURQUOISE = ManimColor("#098587")
T22_ORIENTAL_BLUE = ManimColor("#358792")
T24_BLUE_JADE = ManimColor("#427F7E")
T32_HUON_GREEN = ManimColor("#72B3B1")
T33_SMOKE_BLUE = ManimColor("#9EB6B2")
T35_GREEN_ICE = ManimColor("#78AEA2")
T44_BLUE_GUM = ManimColor("#6A8A88")
T45_COOTAMUNDRA = ManimColor("#759E91")
T51_MOUNTAIN_BLUE = ManimColor("#295668")
T53_PEACOCK_BLUE = ManimColor("#245764")
T63_TEAL = ManimColor("#183F4E")
X11_BUTTERSCOTCH = ManimColor("#D38F43")
X12_PUMPKIN = ManimColor("#DD7E1A")
X13_MARIGOLD = ManimColor("#ED7F15")
X14_MANDARIN = ManimColor("#E45427")
X15_ORANGE = ManimColor("#E36C2B")
X21_PALE_OCHRE = ManimColor("#DAA45F")
X22_SAFFRON = ManimColor("#F6AA51")
X23_APRICOT = ManimColor("#FEB56D")
X24_ROCKMELON = ManimColor("#F6894B")
X31_RAFFIA = ManimColor("#EBC695")
X32_MAGNOLIA = ManimColor("#F1DEBE")
X33_WARM_WHITE = ManimColor("#F3E7D4")
X34_DRIFTWOOD = ManimColor("#D5C4AE")
X41_BUFF = ManimColor("#C28A44")
X42_BISCUIT = ManimColor("#DEBA92")
X43_BEIGE = ManimColor("#C9AA8C")
X45_CINNAMON = ManimColor("#AC826D")
X51_TAN = ManimColor("#8F5F32")
X52_COFFEE = ManimColor("#AD7948")
X53_GOLDEN_TAN = ManimColor("#925629")
X54_BROWN = ManimColor("#68452C")
X55_NUT_BROWN = ManimColor("#764832")
X61_WOMBAT = ManimColor("#6E5D52")
X62_DARK_EARTH = ManimColor("#6E5D52")
X63_IRONBARK = ManimColor("#443B36")
X64_CHOCOLATE = ManimColor("#4A3B31")
X65_DARK_BROWN = ManimColor("#4F372D")
Y11_CANARY = ManimColor("#E7BD11")
Y12_WATTLE = ManimColor("#E8AF01")
Y13_VIVID_YELLOW = ManimColor("#FCAE01")
Y14_GOLDEN_YELLOW = ManimColor("#F5A601")
Y15_SUNFLOWER = ManimColor("#FFA709")
Y16_INCA_GOLD = ManimColor("#DF8C19")
Y21_PRIMROSE = ManimColor("#F5CF5B")
Y22_CUSTARD = ManimColor("#EFD25C")
Y23_BUTTERCUP = ManimColor("#E0CD41")
Y24_STRAW = ManimColor("#E3C882")
Y25_DEEP_CREAM = ManimColor("#F3C968")
Y26_HOMEBUSH_GOLD = ManimColor("#FCC51A")
Y31_LILY_GREEN = ManimColor("#E3E3CD")
Y32_FLUMMERY = ManimColor("#E6DF9E")
Y33_PALE_PRIMROSE = ManimColor("#F5F3CE")
Y34_CREAM = ManimColor("#EFE3BE")
Y35_OFF_WHITE = ManimColor("#F1E9D5")
Y41_OLIVE_YELLOW = ManimColor("#8E7426")
Y42_MUSTARD = ManimColor("#C4A32E")
Y43_PARCHMENT = ManimColor("#D4C9A3")
Y44_SAND = ManimColor("#DCC18B")
Y45_MANILLA = ManimColor("#E5D0A7")
Y51_BRONZE_OLIVE = ManimColor("#695D3E")
Y52_CHAMOIS = ManimColor("#BEA873")
Y53_SANDSTONE = ManimColor("#D5BF8E")
Y54_OATMEAL = ManimColor("#CAAE82")
Y55_DEEP_STONE = ManimColor("#BC9969")
Y56_MERINO = ManimColor("#C9B79E")
Y61_BLACK_OLIVE = ManimColor("#47473B")
Y62_SUGAR_CANE = ManimColor("#BCA55C")
Y63_KHAKI = ManimColor("#826843")
Y65_MUSHROOM = ManimColor("#A39281")
Y66_MUDSTONE = ManimColor("#574E45")

315
manim/utils/color/BS381.py Normal file
View file

@ -0,0 +1,315 @@
"""British Color Standard
This module contains colors defined in one of the British Standards
for colors, BS381C. This standard specifies colors used in identification,
coding, and other special purposes. See https://www.britishstandardcolour.com/
for more information.
To use the colors from this list, access them directly from the module (which
is exposed to Manim's global name space):
.. code:: pycon
>>> from manim import BS381
>>> BS381.OXFORD_BLUE
ManimColor('#1F3057')
List of Color Constants
-----------------------
These hex values (taken from https://www.w3schools.com/colors/colors_british.asp)
are non official approximate values intended to simulate the ones defined
in the standard:
.. automanimcolormodule:: manim.utils.color.BS381
"""
from .core import ManimColor
BS381_101 = ManimColor("#94BFAC")
SKY_BLUE = ManimColor("#94BFAC")
BS381_102 = ManimColor("#5B9291")
TURQUOISE_BLUE = ManimColor("#5B9291")
BS381_103 = ManimColor("#3B6879")
PEACOCK_BLUE = ManimColor("#3B6879")
BS381_104 = ManimColor("#264D7E")
AZURE_BLUE = ManimColor("#264D7E")
BS381_105 = ManimColor("#1F3057")
OXFORD_BLUE = ManimColor("#1F3057")
BS381_106 = ManimColor("#2A283D")
ROYAL_BLUE = ManimColor("#2A283D")
BS381_107 = ManimColor("#3A73A9")
STRONG_BLUE = ManimColor("#3A73A9")
BS381_108 = ManimColor("#173679")
AIRCRAFT_BLUE = ManimColor("#173679")
BS381_109 = ManimColor("#1C5680")
MIDDLE_BLUE = ManimColor("#1C5680")
BS381_110 = ManimColor("#2C3E75")
ROUNDEL_BLUE = ManimColor("#2C3E75")
BS381_111 = ManimColor("#8CC5BB")
PALE_BLUE = ManimColor("#8CC5BB")
BS381_112 = ManimColor("#78ADC2")
ARCTIC_BLUE = ManimColor("#78ADC2")
FIESTA_BLUE = ManimColor("#78ADC2")
BS381_113 = ManimColor("#3F687D")
DEEP_SAXE_BLUE = ManimColor("#3F687D")
BS381_114 = ManimColor("#1F4B61")
RAIL_BLUE = ManimColor("#1F4B61")
BS381_115 = ManimColor("#5F88C1")
COBALT_BLUE = ManimColor("#5F88C1")
BS381_166 = ManimColor("#2458AF")
FRENCH_BLUE = ManimColor("#2458AF")
BS381_169 = ManimColor("#135B75")
TRAFFIC_BLUE = ManimColor("#135B75")
BS381_172 = ManimColor("#A7C6EB")
PALE_ROUNDEL_BLUE = ManimColor("#A7C6EB")
BS381_174 = ManimColor("#64A0AA")
ORIENT_BLUE = ManimColor("#64A0AA")
BS381_175 = ManimColor("#4F81C5")
LIGHT_FRENCH_BLUE = ManimColor("#4F81C5")
BS381_210 = ManimColor("#BBC9A5")
SKY = ManimColor("#BBC9A5")
BS381_216 = ManimColor("#BCD890")
EAU_DE_NIL = ManimColor("#BCD890")
BS381_217 = ManimColor("#96BF65")
SEA_GREEN = ManimColor("#96BF65")
BS381_218 = ManimColor("#698B47")
GRASS_GREEN = ManimColor("#698B47")
BS381_219 = ManimColor("#757639")
SAGE_GREEN = ManimColor("#757639")
BS381_220 = ManimColor("#4B5729")
OLIVE_GREEN = ManimColor("#4B5729")
BS381_221 = ManimColor("#507D3A")
BRILLIANT_GREEN = ManimColor("#507D3A")
BS381_222 = ManimColor("#6A7031")
LIGHT_BRONZE_GREEN = ManimColor("#6A7031")
BS381_223 = ManimColor("#49523A")
MIDDLE_BRONZE_GREEN = ManimColor("#49523A")
BS381_224 = ManimColor("#3E4630")
DEEP_BRONZE_GREEN = ManimColor("#3E4630")
BS381_225 = ManimColor("#406A28")
LIGHT_BRUNSWICK_GREEN = ManimColor("#406A28")
BS381_226 = ManimColor("#33533B")
MID_BRUNSWICK_GREEN = ManimColor("#33533B")
BS381_227 = ManimColor("#254432")
DEEP_BRUNSWICK_GREEN = ManimColor("#254432")
BS381_228 = ManimColor("#428B64")
EMERALD_GREEN = ManimColor("#428B64")
BS381_241 = ManimColor("#4F5241")
DARK_GREEN = ManimColor("#4F5241")
BS381_262 = ManimColor("#44945E")
BOLD_GREEN = ManimColor("#44945E")
BS381_267 = ManimColor("#476A4C")
DEEP_CHROME_GREEN = ManimColor("#476A4C")
TRAFFIC_GREEN = ManimColor("#476A4C")
BS381_275 = ManimColor("#8FC693")
OPALINE_GREEN = ManimColor("#8FC693")
BS381_276 = ManimColor("#2E4C1E")
LINCON_GREEN = ManimColor("#2E4C1E")
BS381_277 = ManimColor("#364A20")
CYPRESS_GREEN = ManimColor("#364A20")
BS381_278 = ManimColor("#87965A")
LIGHT_OLIVE_GREEN = ManimColor("#87965A")
BS381_279 = ManimColor("#3B3629")
STEEL_FURNITURE_GREEN = ManimColor("#3B3629")
BS381_280 = ManimColor("#68AB77")
VERDIGRIS_GREEN = ManimColor("#68AB77")
BS381_282 = ManimColor("#506B52")
FOREST_GREEN = ManimColor("#506B52")
BS381_283 = ManimColor("#7E8F6E")
AIRCRAFT_GREY_GREEN = ManimColor("#7E8F6E")
BS381_284 = ManimColor("#6B6F5A")
SPRUCE_GREEN = ManimColor("#6B6F5A")
BS381_285 = ManimColor("#5F5C4B")
NATO_GREEN = ManimColor("#5F5C4B")
BS381_298 = ManimColor("#4F5138")
OLIVE_DRAB = ManimColor("#4F5138")
BS381_309 = ManimColor("#FEEC04")
CANARY_YELLOW = ManimColor("#FEEC04")
BS381_310 = ManimColor("#FEF963")
PRIMROSE = ManimColor("#FEF963")
BS381_315 = ManimColor("#FEF96A")
GRAPEFRUIT = ManimColor("#FEF96A")
BS381_320 = ManimColor("#9E7339")
LIGHT_BROWN = ManimColor("#9E7339")
BS381_337 = ManimColor("#4C4A3C")
VERY_DARK_DRAB = ManimColor("#4C4A3C")
BS381_350 = ManimColor("#7B6B4F")
DARK_EARTH = ManimColor("#7B6B4F")
BS381_352 = ManimColor("#FCED96")
PALE_CREAM = ManimColor("#FCED96")
BS381_353 = ManimColor("#FDF07A")
DEEP_CREAM = ManimColor("#FDF07A")
BS381_354 = ManimColor("#E9BB43")
PRIMROSE_2 = ManimColor("#E9BB43")
BS381_355 = ManimColor("#FDD906")
LEMON = ManimColor("#FDD906")
BS381_356 = ManimColor("#FCC808")
GOLDEN_YELLOW = ManimColor("#FCC808")
BS381_358 = ManimColor("#F6C870")
LIGHT_BUFF = ManimColor("#F6C870")
BS381_359 = ManimColor("#DBAC50")
MIDDLE_BUFF = ManimColor("#DBAC50")
BS381_361 = ManimColor("#D4B97D")
LIGHT_STONE = ManimColor("#D4B97D")
BS381_362 = ManimColor("#AC7C42")
MIDDLE_STONE = ManimColor("#AC7C42")
BS381_363 = ManimColor("#FDE706")
BOLD_YELLOW = ManimColor("#FDE706")
BS381_364 = ManimColor("#CEC093")
PORTLAND_STONE = ManimColor("#CEC093")
BS381_365 = ManimColor("#F4F0BD")
VELLUM = ManimColor("#F4F0BD")
BS381_366 = ManimColor("#F5E7A1")
LIGHT_BEIGE = ManimColor("#F5E7A1")
BS381_367 = ManimColor("#FEF6BF")
MANILLA = ManimColor("#fef6bf")
BS381_368 = ManimColor("#DD7B00")
TRAFFIC_YELLOW = ManimColor("#DD7B00")
BS381_369 = ManimColor("#FEEBA8")
BISCUIT = ManimColor("#feeba8")
BS381_380 = ManimColor("#BBA38A")
CAMOUFLAGE_DESERT_SAND = ManimColor("#BBA38A")
BS381_384 = ManimColor("#EEDFA5")
LIGHT_STRAW = ManimColor("#EEDFA5")
BS381_385 = ManimColor("#E8C88F")
LIGHT_BISCUIT = ManimColor("#E8C88F")
BS381_386 = ManimColor("#E6C18D")
CHAMPAGNE = ManimColor("#e6c18d")
BS381_387 = ManimColor("#CFB48A")
SUNRISE = ManimColor("#cfb48a")
SUNSHINE = ManimColor("#cfb48a")
BS381_388 = ManimColor("#E4CF93")
BEIGE = ManimColor("#e4cf93")
BS381_389 = ManimColor("#B2A788")
CAMOUFLAGE_BEIGE = ManimColor("#B2A788")
BS381_397 = ManimColor("#F3D163")
JASMINE_YELLOW = ManimColor("#F3D163")
BS381_411 = ManimColor("#74542F")
MIDDLE_BROWN = ManimColor("#74542F")
BS381_412 = ManimColor("#5C422E")
DARK_BROWN = ManimColor("#5C422E")
BS381_413 = ManimColor("#402D21")
NUT_BROWN = ManimColor("#402D21")
BS381_414 = ManimColor("#A86C29")
GOLDEN_BROWN = ManimColor("#A86C29")
BS381_415 = ManimColor("#61361E")
IMPERIAL_BROWN = ManimColor("#61361E")
BS381_420 = ManimColor("#A89177")
DARK_CAMOUFLAGE_DESERT_SAND = ManimColor("#A89177")
BS381_435 = ManimColor("#845B4D")
CAMOUFLAGE_RED = ManimColor("#845B4D")
BS381_436 = ManimColor("#564B47")
DARK_CAMOUFLAGE_BROWN = ManimColor("#564B47")
BS381_439 = ManimColor("#753B1E")
ORANGE_BROWN = ManimColor("#753B1E")
BS381_443 = ManimColor("#C98A71")
SALMON = ManimColor("#c98a71")
BS381_444 = ManimColor("#A65341")
TERRACOTTA = ManimColor("#a65341")
BS381_445 = ManimColor("#83422B")
VENETIAN_RED = ManimColor("#83422B")
BS381_446 = ManimColor("#774430")
RED_OXIDE = ManimColor("#774430")
BS381_447 = ManimColor("#F3B28B")
SALMON_PINK = ManimColor("#F3B28B")
BS381_448 = ManimColor("#67403A")
DEEP_INDIAN_RED = ManimColor("#67403A")
BS381_449 = ManimColor("#693B3F")
LIGHT_PURPLE_BROWN = ManimColor("#693B3F")
BS381_452 = ManimColor("#613339")
DARK_CRIMSON = ManimColor("#613339")
BS381_453 = ManimColor("#FBDED6")
SHELL_PINK = ManimColor("#FBDED6")
BS381_454 = ManimColor("#E8A1A2")
PALE_ROUNDEL_RED = ManimColor("#E8A1A2")
BS381_460 = ManimColor("#BD8F56")
DEEP_BUFF = ManimColor("#BD8F56")
BS381_473 = ManimColor("#793932")
GULF_RED = ManimColor("#793932")
BS381_489 = ManimColor("#8D5B41")
LEAF_BROWN = ManimColor("#8D5B41")
BS381_490 = ManimColor("#573320")
BEECH_BROWN = ManimColor("#573320")
BS381_499 = ManimColor("#59493E")
SERVICE_BROWN = ManimColor("#59493E")
BS381_536 = ManimColor("#BB3016")
POPPY = ManimColor("#bb3016")
BS381_537 = ManimColor("#DD3420")
SIGNAL_RED = ManimColor("#DD3420")
BS381_538 = ManimColor("#C41C22")
POST_OFFICE_RED = ManimColor("#C41C22")
CHERRY = ManimColor("#c41c22")
BS381_539 = ManimColor("#D21E2B")
CURRANT_RED = ManimColor("#D21E2B")
BS381_540 = ManimColor("#8B1A32")
CRIMSON = ManimColor("#8b1a32")
BS381_541 = ManimColor("#471B21")
MAROON = ManimColor("#471b21")
BS381_542 = ManimColor("#982D57")
RUBY = ManimColor("#982d57")
BS381_557 = ManimColor("#EF841E")
LIGHT_ORANGE = ManimColor("#EF841E")
BS381_564 = ManimColor("#DD3524")
BOLD_RED = ManimColor("#DD3524")
BS381_568 = ManimColor("#FB9C06")
APRICOT = ManimColor("#fb9c06")
BS381_570 = ManimColor("#A83C19")
TRAFFIC_RED = ManimColor("#A83C19")
BS381_591 = ManimColor("#D04E09")
DEEP_ORANGE = ManimColor("#D04E09")
BS381_592 = ManimColor("#E45523")
INTERNATIONAL_ORANGE = ManimColor("#E45523")
BS381_593 = ManimColor("#F24816")
RAIL_RED = ManimColor("#F24816")
AZO_ORANGE = ManimColor("#F24816")
BS381_626 = ManimColor("#A0A9AA")
CAMOUFLAGE_GREY = ManimColor("#A0A9AA")
BS381_627 = ManimColor("#BEC0B8")
LIGHT_AIRCRAFT_GREY = ManimColor("#BEC0B8")
BS381_628 = ManimColor("#9D9D7E")
SILVER_GREY = ManimColor("#9D9D7E")
BS381_629 = ManimColor("#7A838B")
DARK_CAMOUFLAGE_GREY = ManimColor("#7A838B")
BS381_630 = ManimColor("#A5AD98")
FRENCH_GREY = ManimColor("#A5AD98")
BS381_631 = ManimColor("#9AAA9F")
LIGHT_GREY = ManimColor("#9AAA9F")
BS381_632 = ManimColor("#6B7477")
DARK_ADMIRALTY_GREY = ManimColor("#6B7477")
BS381_633 = ManimColor("#424C53")
RAF_BLUE_GREY = ManimColor("#424C53")
BS381_634 = ManimColor("#6F7264")
SLATE = ManimColor("#6f7264")
BS381_635 = ManimColor("#525B55")
LEAD = ManimColor("#525b55")
BS381_636 = ManimColor("#5F7682")
PRU_BLUE = ManimColor("#5F7682")
BS381_637 = ManimColor("#8E9B9C")
MEDIUM_SEA_GREY = ManimColor("#8E9B9C")
BS381_638 = ManimColor("#6C7377")
DARK_SEA_GREY = ManimColor("#6C7377")
BS381_639 = ManimColor("#667563")
LIGHT_SLATE_GREY = ManimColor("#667563")
BS381_640 = ManimColor("#566164")
EXTRA_DARK_SEA_GREY = ManimColor("#566164")
BS381_642 = ManimColor("#282B2F")
NIGHT = ManimColor("#282b2f")
BS381_671 = ManimColor("#4E5355")
MIDDLE_GRAPHITE = ManimColor("#4E5355")
BS381_676 = ManimColor("#A9B7B9")
LIGHT_WEATHERWORK_GREY = ManimColor("#A9B7B9")
BS381_677 = ManimColor("#676F76")
DARK_WEATHERWORK_GREY = ManimColor("#676F76")
BS381_692 = ManimColor("#7B93A3")
SMOKE_GREY = ManimColor("#7B93A3")
BS381_693 = ManimColor("#88918D")
AIRCRAFT_GREY = ManimColor("#88918D")
BS381_694 = ManimColor("#909A92")
DOVE_GREY = ManimColor("#909A92")
BS381_697 = ManimColor("#B6D3CC")
LIGHT_ADMIRALTY_GREY = ManimColor("#B6D3CC")
BS381_796 = ManimColor("#6E4A75")
DARK_VIOLET = ManimColor("#6E4A75")
BS381_797 = ManimColor("#C9A8CE")
LIGHT_VIOLET = ManimColor("#C9A8CE")

530
manim/utils/color/X11.py Normal file
View file

@ -0,0 +1,530 @@
# from https://www.w3schools.com/colors/colors_x11.asp
"""X11 Colors
These color and their names (taken from
https://www.w3schools.com/colors/colors_x11.asp) were developed at the
Massachusetts Intitute of Technology (MIT) during
the development of color based computer display system.
To use the colors from this list, access them directly from the module (which
is exposed to Manim's global name space):
.. code:: pycon
>>> from manim import X11
>>> X11.BEIGE
ManimColor('#F5F5DC')
List of Color Constants
-----------------------
.. automanimcolormodule:: manim.utils.color.X11
"""
from .core import ManimColor
ALICEBLUE = ManimColor("#F0F8FF")
ANTIQUEWHITE = ManimColor("#FAEBD7")
ANTIQUEWHITE1 = ManimColor("#FFEFDB")
ANTIQUEWHITE2 = ManimColor("#EEDFCC")
ANTIQUEWHITE3 = ManimColor("#CDC0B0")
ANTIQUEWHITE4 = ManimColor("#8B8378")
AQUAMARINE1 = ManimColor("#7FFFD4")
AQUAMARINE2 = ManimColor("#76EEC6")
AQUAMARINE4 = ManimColor("#458B74")
AZURE1 = ManimColor("#F0FFFF")
AZURE2 = ManimColor("#E0EEEE")
AZURE3 = ManimColor("#C1CDCD")
AZURE4 = ManimColor("#838B8B")
BEIGE = ManimColor("#F5F5DC")
BISQUE1 = ManimColor("#FFE4C4")
BISQUE2 = ManimColor("#EED5B7")
BISQUE3 = ManimColor("#CDB79E")
BISQUE4 = ManimColor("#8B7D6B")
BLACK = ManimColor("#000000")
BLANCHEDALMOND = ManimColor("#FFEBCD")
BLUE1 = ManimColor("#0000FF")
BLUE2 = ManimColor("#0000EE")
BLUE4 = ManimColor("#00008B")
BLUEVIOLET = ManimColor("#8A2BE2")
BROWN = ManimColor("#A52A2A")
BROWN1 = ManimColor("#FF4040")
BROWN2 = ManimColor("#EE3B3B")
BROWN3 = ManimColor("#CD3333")
BROWN4 = ManimColor("#8B2323")
BURLYWOOD = ManimColor("#DEB887")
BURLYWOOD1 = ManimColor("#FFD39B")
BURLYWOOD2 = ManimColor("#EEC591")
BURLYWOOD3 = ManimColor("#CDAA7D")
BURLYWOOD4 = ManimColor("#8B7355")
CADETBLUE = ManimColor("#5F9EA0")
CADETBLUE1 = ManimColor("#98F5FF")
CADETBLUE2 = ManimColor("#8EE5EE")
CADETBLUE3 = ManimColor("#7AC5CD")
CADETBLUE4 = ManimColor("#53868B")
CHARTREUSE1 = ManimColor("#7FFF00")
CHARTREUSE2 = ManimColor("#76EE00")
CHARTREUSE3 = ManimColor("#66CD00")
CHARTREUSE4 = ManimColor("#458B00")
CHOCOLATE = ManimColor("#D2691E")
CHOCOLATE1 = ManimColor("#FF7F24")
CHOCOLATE2 = ManimColor("#EE7621")
CHOCOLATE3 = ManimColor("#CD661D")
CORAL = ManimColor("#FF7F50")
CORAL1 = ManimColor("#FF7256")
CORAL2 = ManimColor("#EE6A50")
CORAL3 = ManimColor("#CD5B45")
CORAL4 = ManimColor("#8B3E2F")
CORNFLOWERBLUE = ManimColor("#6495ED")
CORNSILK1 = ManimColor("#FFF8DC")
CORNSILK2 = ManimColor("#EEE8CD")
CORNSILK3 = ManimColor("#CDC8B1")
CORNSILK4 = ManimColor("#8B8878")
CYAN1 = ManimColor("#00FFFF")
CYAN2 = ManimColor("#00EEEE")
CYAN3 = ManimColor("#00CDCD")
CYAN4 = ManimColor("#008B8B")
DARKGOLDENROD = ManimColor("#B8860B")
DARKGOLDENROD1 = ManimColor("#FFB90F")
DARKGOLDENROD2 = ManimColor("#EEAD0E")
DARKGOLDENROD3 = ManimColor("#CD950C")
DARKGOLDENROD4 = ManimColor("#8B6508")
DARKGREEN = ManimColor("#006400")
DARKKHAKI = ManimColor("#BDB76B")
DARKOLIVEGREEN = ManimColor("#556B2F")
DARKOLIVEGREEN1 = ManimColor("#CAFF70")
DARKOLIVEGREEN2 = ManimColor("#BCEE68")
DARKOLIVEGREEN3 = ManimColor("#A2CD5A")
DARKOLIVEGREEN4 = ManimColor("#6E8B3D")
DARKORANGE = ManimColor("#FF8C00")
DARKORANGE1 = ManimColor("#FF7F00")
DARKORANGE2 = ManimColor("#EE7600")
DARKORANGE3 = ManimColor("#CD6600")
DARKORANGE4 = ManimColor("#8B4500")
DARKORCHID = ManimColor("#9932CC")
DARKORCHID1 = ManimColor("#BF3EFF")
DARKORCHID2 = ManimColor("#B23AEE")
DARKORCHID3 = ManimColor("#9A32CD")
DARKORCHID4 = ManimColor("#68228B")
DARKSALMON = ManimColor("#E9967A")
DARKSEAGREEN = ManimColor("#8FBC8F")
DARKSEAGREEN1 = ManimColor("#C1FFC1")
DARKSEAGREEN2 = ManimColor("#B4EEB4")
DARKSEAGREEN3 = ManimColor("#9BCD9B")
DARKSEAGREEN4 = ManimColor("#698B69")
DARKSLATEBLUE = ManimColor("#483D8B")
DARKSLATEGRAY = ManimColor("#2F4F4F")
DARKSLATEGRAY1 = ManimColor("#97FFFF")
DARKSLATEGRAY2 = ManimColor("#8DEEEE")
DARKSLATEGRAY3 = ManimColor("#79CDCD")
DARKSLATEGRAY4 = ManimColor("#528B8B")
DARKTURQUOISE = ManimColor("#00CED1")
DARKVIOLET = ManimColor("#9400D3")
DEEPPINK1 = ManimColor("#FF1493")
DEEPPINK2 = ManimColor("#EE1289")
DEEPPINK3 = ManimColor("#CD1076")
DEEPPINK4 = ManimColor("#8B0A50")
DEEPSKYBLUE1 = ManimColor("#00BFFF")
DEEPSKYBLUE2 = ManimColor("#00B2EE")
DEEPSKYBLUE3 = ManimColor("#009ACD")
DEEPSKYBLUE4 = ManimColor("#00688B")
DIMGRAY = ManimColor("#696969")
DODGERBLUE1 = ManimColor("#1E90FF")
DODGERBLUE2 = ManimColor("#1C86EE")
DODGERBLUE3 = ManimColor("#1874CD")
DODGERBLUE4 = ManimColor("#104E8B")
FIREBRICK = ManimColor("#B22222")
FIREBRICK1 = ManimColor("#FF3030")
FIREBRICK2 = ManimColor("#EE2C2C")
FIREBRICK3 = ManimColor("#CD2626")
FIREBRICK4 = ManimColor("#8B1A1A")
FLORALWHITE = ManimColor("#FFFAF0")
FORESTGREEN = ManimColor("#228B22")
GAINSBORO = ManimColor("#DCDCDC")
GHOSTWHITE = ManimColor("#F8F8FF")
GOLD1 = ManimColor("#FFD700")
GOLD2 = ManimColor("#EEC900")
GOLD3 = ManimColor("#CDAD00")
GOLD4 = ManimColor("#8B7500")
GOLDENROD = ManimColor("#DAA520")
GOLDENROD1 = ManimColor("#FFC125")
GOLDENROD2 = ManimColor("#EEB422")
GOLDENROD3 = ManimColor("#CD9B1D")
GOLDENROD4 = ManimColor("#8B6914")
GRAY = ManimColor("#BEBEBE")
GRAY1 = ManimColor("#030303")
GRAY2 = ManimColor("#050505")
GRAY3 = ManimColor("#080808")
GRAY4 = ManimColor("#0A0A0A")
GRAY5 = ManimColor("#0D0D0D")
GRAY6 = ManimColor("#0F0F0F")
GRAY7 = ManimColor("#121212")
GRAY8 = ManimColor("#141414")
GRAY9 = ManimColor("#171717")
GRAY10 = ManimColor("#1A1A1A")
GRAY11 = ManimColor("#1C1C1C")
GRAY12 = ManimColor("#1F1F1F")
GRAY13 = ManimColor("#212121")
GRAY14 = ManimColor("#242424")
GRAY15 = ManimColor("#262626")
GRAY16 = ManimColor("#292929")
GRAY17 = ManimColor("#2B2B2B")
GRAY18 = ManimColor("#2E2E2E")
GRAY19 = ManimColor("#303030")
GRAY20 = ManimColor("#333333")
GRAY21 = ManimColor("#363636")
GRAY22 = ManimColor("#383838")
GRAY23 = ManimColor("#3B3B3B")
GRAY24 = ManimColor("#3D3D3D")
GRAY25 = ManimColor("#404040")
GRAY26 = ManimColor("#424242")
GRAY27 = ManimColor("#454545")
GRAY28 = ManimColor("#474747")
GRAY29 = ManimColor("#4A4A4A")
GRAY30 = ManimColor("#4D4D4D")
GRAY31 = ManimColor("#4F4F4F")
GRAY32 = ManimColor("#525252")
GRAY33 = ManimColor("#545454")
GRAY34 = ManimColor("#575757")
GRAY35 = ManimColor("#595959")
GRAY36 = ManimColor("#5C5C5C")
GRAY37 = ManimColor("#5E5E5E")
GRAY38 = ManimColor("#616161")
GRAY39 = ManimColor("#636363")
GRAY40 = ManimColor("#666666")
GRAY41 = ManimColor("#696969")
GRAY42 = ManimColor("#6B6B6B")
GRAY43 = ManimColor("#6E6E6E")
GRAY44 = ManimColor("#707070")
GRAY45 = ManimColor("#737373")
GRAY46 = ManimColor("#757575")
GRAY47 = ManimColor("#787878")
GRAY48 = ManimColor("#7A7A7A")
GRAY49 = ManimColor("#7D7D7D")
GRAY50 = ManimColor("#7F7F7F")
GRAY51 = ManimColor("#828282")
GRAY52 = ManimColor("#858585")
GRAY53 = ManimColor("#878787")
GRAY54 = ManimColor("#8A8A8A")
GRAY55 = ManimColor("#8C8C8C")
GRAY56 = ManimColor("#8F8F8F")
GRAY57 = ManimColor("#919191")
GRAY58 = ManimColor("#949494")
GRAY59 = ManimColor("#969696")
GRAY60 = ManimColor("#999999")
GRAY61 = ManimColor("#9C9C9C")
GRAY62 = ManimColor("#9E9E9E")
GRAY63 = ManimColor("#A1A1A1")
GRAY64 = ManimColor("#A3A3A3")
GRAY65 = ManimColor("#A6A6A6")
GRAY66 = ManimColor("#A8A8A8")
GRAY67 = ManimColor("#ABABAB")
GRAY68 = ManimColor("#ADADAD")
GRAY69 = ManimColor("#B0B0B0")
GRAY70 = ManimColor("#B3B3B3")
GRAY71 = ManimColor("#B5B5B5")
GRAY72 = ManimColor("#B8B8B8")
GRAY73 = ManimColor("#BABABA")
GRAY74 = ManimColor("#BDBDBD")
GRAY75 = ManimColor("#BFBFBF")
GRAY76 = ManimColor("#C2C2C2")
GRAY77 = ManimColor("#C4C4C4")
GRAY78 = ManimColor("#C7C7C7")
GRAY79 = ManimColor("#C9C9C9")
GRAY80 = ManimColor("#CCCCCC")
GRAY81 = ManimColor("#CFCFCF")
GRAY82 = ManimColor("#D1D1D1")
GRAY83 = ManimColor("#D4D4D4")
GRAY84 = ManimColor("#D6D6D6")
GRAY85 = ManimColor("#D9D9D9")
GRAY86 = ManimColor("#DBDBDB")
GRAY87 = ManimColor("#DEDEDE")
GRAY88 = ManimColor("#E0E0E0")
GRAY89 = ManimColor("#E3E3E3")
GRAY90 = ManimColor("#E5E5E5")
GRAY91 = ManimColor("#E8E8E8")
GRAY92 = ManimColor("#EBEBEB")
GRAY93 = ManimColor("#EDEDED")
GRAY94 = ManimColor("#F0F0F0")
GRAY95 = ManimColor("#F2F2F2")
GRAY97 = ManimColor("#F7F7F7")
GRAY98 = ManimColor("#FAFAFA")
GRAY99 = ManimColor("#FCFCFC")
GREEN1 = ManimColor("#00FF00")
GREEN2 = ManimColor("#00EE00")
GREEN3 = ManimColor("#00CD00")
GREEN4 = ManimColor("#008B00")
GREENYELLOW = ManimColor("#ADFF2F")
HONEYDEW1 = ManimColor("#F0FFF0")
HONEYDEW2 = ManimColor("#E0EEE0")
HONEYDEW3 = ManimColor("#C1CDC1")
HONEYDEW4 = ManimColor("#838B83")
HOTPINK = ManimColor("#FF69B4")
HOTPINK1 = ManimColor("#FF6EB4")
HOTPINK2 = ManimColor("#EE6AA7")
HOTPINK3 = ManimColor("#CD6090")
HOTPINK4 = ManimColor("#8B3A62")
INDIANRED = ManimColor("#CD5C5C")
INDIANRED1 = ManimColor("#FF6A6A")
INDIANRED2 = ManimColor("#EE6363")
INDIANRED3 = ManimColor("#CD5555")
INDIANRED4 = ManimColor("#8B3A3A")
IVORY1 = ManimColor("#FFFFF0")
IVORY2 = ManimColor("#EEEEE0")
IVORY3 = ManimColor("#CDCDC1")
IVORY4 = ManimColor("#8B8B83")
KHAKI = ManimColor("#F0E68C")
KHAKI1 = ManimColor("#FFF68F")
KHAKI2 = ManimColor("#EEE685")
KHAKI3 = ManimColor("#CDC673")
KHAKI4 = ManimColor("#8B864E")
LAVENDER = ManimColor("#E6E6FA")
LAVENDERBLUSH1 = ManimColor("#FFF0F5")
LAVENDERBLUSH2 = ManimColor("#EEE0E5")
LAVENDERBLUSH3 = ManimColor("#CDC1C5")
LAVENDERBLUSH4 = ManimColor("#8B8386")
LAWNGREEN = ManimColor("#7CFC00")
LEMONCHIFFON1 = ManimColor("#FFFACD")
LEMONCHIFFON2 = ManimColor("#EEE9BF")
LEMONCHIFFON3 = ManimColor("#CDC9A5")
LEMONCHIFFON4 = ManimColor("#8B8970")
LIGHT = ManimColor("#EEDD82")
LIGHTBLUE = ManimColor("#ADD8E6")
LIGHTBLUE1 = ManimColor("#BFEFFF")
LIGHTBLUE2 = ManimColor("#B2DFEE")
LIGHTBLUE3 = ManimColor("#9AC0CD")
LIGHTBLUE4 = ManimColor("#68838B")
LIGHTCORAL = ManimColor("#F08080")
LIGHTCYAN1 = ManimColor("#E0FFFF")
LIGHTCYAN2 = ManimColor("#D1EEEE")
LIGHTCYAN3 = ManimColor("#B4CDCD")
LIGHTCYAN4 = ManimColor("#7A8B8B")
LIGHTGOLDENROD1 = ManimColor("#FFEC8B")
LIGHTGOLDENROD2 = ManimColor("#EEDC82")
LIGHTGOLDENROD3 = ManimColor("#CDBE70")
LIGHTGOLDENROD4 = ManimColor("#8B814C")
LIGHTGOLDENRODYELLOW = ManimColor("#FAFAD2")
LIGHTGRAY = ManimColor("#D3D3D3")
LIGHTPINK = ManimColor("#FFB6C1")
LIGHTPINK1 = ManimColor("#FFAEB9")
LIGHTPINK2 = ManimColor("#EEA2AD")
LIGHTPINK3 = ManimColor("#CD8C95")
LIGHTPINK4 = ManimColor("#8B5F65")
LIGHTSALMON1 = ManimColor("#FFA07A")
LIGHTSALMON2 = ManimColor("#EE9572")
LIGHTSALMON3 = ManimColor("#CD8162")
LIGHTSALMON4 = ManimColor("#8B5742")
LIGHTSEAGREEN = ManimColor("#20B2AA")
LIGHTSKYBLUE = ManimColor("#87CEFA")
LIGHTSKYBLUE1 = ManimColor("#B0E2FF")
LIGHTSKYBLUE2 = ManimColor("#A4D3EE")
LIGHTSKYBLUE3 = ManimColor("#8DB6CD")
LIGHTSKYBLUE4 = ManimColor("#607B8B")
LIGHTSLATEBLUE = ManimColor("#8470FF")
LIGHTSLATEGRAY = ManimColor("#778899")
LIGHTSTEELBLUE = ManimColor("#B0C4DE")
LIGHTSTEELBLUE1 = ManimColor("#CAE1FF")
LIGHTSTEELBLUE2 = ManimColor("#BCD2EE")
LIGHTSTEELBLUE3 = ManimColor("#A2B5CD")
LIGHTSTEELBLUE4 = ManimColor("#6E7B8B")
LIGHTYELLOW1 = ManimColor("#FFFFE0")
LIGHTYELLOW2 = ManimColor("#EEEED1")
LIGHTYELLOW3 = ManimColor("#CDCDB4")
LIGHTYELLOW4 = ManimColor("#8B8B7A")
LIMEGREEN = ManimColor("#32CD32")
LINEN = ManimColor("#FAF0E6")
MAGENTA = ManimColor("#FF00FF")
MAGENTA2 = ManimColor("#EE00EE")
MAGENTA3 = ManimColor("#CD00CD")
MAGENTA4 = ManimColor("#8B008B")
MAROON = ManimColor("#B03060")
MAROON1 = ManimColor("#FF34B3")
MAROON2 = ManimColor("#EE30A7")
MAROON3 = ManimColor("#CD2990")
MAROON4 = ManimColor("#8B1C62")
MEDIUM = ManimColor("#66CDAA")
MEDIUMAQUAMARINE = ManimColor("#66CDAA")
MEDIUMBLUE = ManimColor("#0000CD")
MEDIUMORCHID = ManimColor("#BA55D3")
MEDIUMORCHID1 = ManimColor("#E066FF")
MEDIUMORCHID2 = ManimColor("#D15FEE")
MEDIUMORCHID3 = ManimColor("#B452CD")
MEDIUMORCHID4 = ManimColor("#7A378B")
MEDIUMPURPLE = ManimColor("#9370DB")
MEDIUMPURPLE1 = ManimColor("#AB82FF")
MEDIUMPURPLE2 = ManimColor("#9F79EE")
MEDIUMPURPLE3 = ManimColor("#8968CD")
MEDIUMPURPLE4 = ManimColor("#5D478B")
MEDIUMSEAGREEN = ManimColor("#3CB371")
MEDIUMSLATEBLUE = ManimColor("#7B68EE")
MEDIUMSPRINGGREEN = ManimColor("#00FA9A")
MEDIUMTURQUOISE = ManimColor("#48D1CC")
MEDIUMVIOLETRED = ManimColor("#C71585")
MIDNIGHTBLUE = ManimColor("#191970")
MINTCREAM = ManimColor("#F5FFFA")
MISTYROSE1 = ManimColor("#FFE4E1")
MISTYROSE2 = ManimColor("#EED5D2")
MISTYROSE3 = ManimColor("#CDB7B5")
MISTYROSE4 = ManimColor("#8B7D7B")
MOCCASIN = ManimColor("#FFE4B5")
NAVAJOWHITE1 = ManimColor("#FFDEAD")
NAVAJOWHITE2 = ManimColor("#EECFA1")
NAVAJOWHITE3 = ManimColor("#CDB38B")
NAVAJOWHITE4 = ManimColor("#8B795E")
NAVYBLUE = ManimColor("#000080")
OLDLACE = ManimColor("#FDF5E6")
OLIVEDRAB = ManimColor("#6B8E23")
OLIVEDRAB1 = ManimColor("#C0FF3E")
OLIVEDRAB2 = ManimColor("#B3EE3A")
OLIVEDRAB4 = ManimColor("#698B22")
ORANGE1 = ManimColor("#FFA500")
ORANGE2 = ManimColor("#EE9A00")
ORANGE3 = ManimColor("#CD8500")
ORANGE4 = ManimColor("#8B5A00")
ORANGERED1 = ManimColor("#FF4500")
ORANGERED2 = ManimColor("#EE4000")
ORANGERED3 = ManimColor("#CD3700")
ORANGERED4 = ManimColor("#8B2500")
ORCHID = ManimColor("#DA70D6")
ORCHID1 = ManimColor("#FF83FA")
ORCHID2 = ManimColor("#EE7AE9")
ORCHID3 = ManimColor("#CD69C9")
ORCHID4 = ManimColor("#8B4789")
PALE = ManimColor("#DB7093")
PALEGOLDENROD = ManimColor("#EEE8AA")
PALEGREEN = ManimColor("#98FB98")
PALEGREEN1 = ManimColor("#9AFF9A")
PALEGREEN2 = ManimColor("#90EE90")
PALEGREEN3 = ManimColor("#7CCD7C")
PALEGREEN4 = ManimColor("#548B54")
PALETURQUOISE = ManimColor("#AFEEEE")
PALETURQUOISE1 = ManimColor("#BBFFFF")
PALETURQUOISE2 = ManimColor("#AEEEEE")
PALETURQUOISE3 = ManimColor("#96CDCD")
PALETURQUOISE4 = ManimColor("#668B8B")
PALEVIOLETRED = ManimColor("#DB7093")
PALEVIOLETRED1 = ManimColor("#FF82AB")
PALEVIOLETRED2 = ManimColor("#EE799F")
PALEVIOLETRED3 = ManimColor("#CD6889")
PALEVIOLETRED4 = ManimColor("#8B475D")
PAPAYAWHIP = ManimColor("#FFEFD5")
PEACHPUFF1 = ManimColor("#FFDAB9")
PEACHPUFF2 = ManimColor("#EECBAD")
PEACHPUFF3 = ManimColor("#CDAF95")
PEACHPUFF4 = ManimColor("#8B7765")
PINK = ManimColor("#FFC0CB")
PINK1 = ManimColor("#FFB5C5")
PINK2 = ManimColor("#EEA9B8")
PINK3 = ManimColor("#CD919E")
PINK4 = ManimColor("#8B636C")
PLUM = ManimColor("#DDA0DD")
PLUM1 = ManimColor("#FFBBFF")
PLUM2 = ManimColor("#EEAEEE")
PLUM3 = ManimColor("#CD96CD")
PLUM4 = ManimColor("#8B668B")
POWDERBLUE = ManimColor("#B0E0E6")
PURPLE = ManimColor("#A020F0")
PURPLE1 = ManimColor("#9B30FF")
PURPLE2 = ManimColor("#912CEE")
PURPLE3 = ManimColor("#7D26CD")
PURPLE4 = ManimColor("#551A8B")
RED1 = ManimColor("#FF0000")
RED2 = ManimColor("#EE0000")
RED3 = ManimColor("#CD0000")
RED4 = ManimColor("#8B0000")
ROSYBROWN = ManimColor("#BC8F8F")
ROSYBROWN1 = ManimColor("#FFC1C1")
ROSYBROWN2 = ManimColor("#EEB4B4")
ROSYBROWN3 = ManimColor("#CD9B9B")
ROSYBROWN4 = ManimColor("#8B6969")
ROYALBLUE = ManimColor("#4169E1")
ROYALBLUE1 = ManimColor("#4876FF")
ROYALBLUE2 = ManimColor("#436EEE")
ROYALBLUE3 = ManimColor("#3A5FCD")
ROYALBLUE4 = ManimColor("#27408B")
SADDLEBROWN = ManimColor("#8B4513")
SALMON = ManimColor("#FA8072")
SALMON1 = ManimColor("#FF8C69")
SALMON2 = ManimColor("#EE8262")
SALMON3 = ManimColor("#CD7054")
SALMON4 = ManimColor("#8B4C39")
SANDYBROWN = ManimColor("#F4A460")
SEAGREEN1 = ManimColor("#54FF9F")
SEAGREEN2 = ManimColor("#4EEE94")
SEAGREEN3 = ManimColor("#43CD80")
SEAGREEN4 = ManimColor("#2E8B57")
SEASHELL1 = ManimColor("#FFF5EE")
SEASHELL2 = ManimColor("#EEE5DE")
SEASHELL3 = ManimColor("#CDC5BF")
SEASHELL4 = ManimColor("#8B8682")
SIENNA = ManimColor("#A0522D")
SIENNA1 = ManimColor("#FF8247")
SIENNA2 = ManimColor("#EE7942")
SIENNA3 = ManimColor("#CD6839")
SIENNA4 = ManimColor("#8B4726")
SKYBLUE = ManimColor("#87CEEB")
SKYBLUE1 = ManimColor("#87CEFF")
SKYBLUE2 = ManimColor("#7EC0EE")
SKYBLUE3 = ManimColor("#6CA6CD")
SKYBLUE4 = ManimColor("#4A708B")
SLATEBLUE = ManimColor("#6A5ACD")
SLATEBLUE1 = ManimColor("#836FFF")
SLATEBLUE2 = ManimColor("#7A67EE")
SLATEBLUE3 = ManimColor("#6959CD")
SLATEBLUE4 = ManimColor("#473C8B")
SLATEGRAY = ManimColor("#708090")
SLATEGRAY1 = ManimColor("#C6E2FF")
SLATEGRAY2 = ManimColor("#B9D3EE")
SLATEGRAY3 = ManimColor("#9FB6CD")
SLATEGRAY4 = ManimColor("#6C7B8B")
SNOW1 = ManimColor("#FFFAFA")
SNOW2 = ManimColor("#EEE9E9")
SNOW3 = ManimColor("#CDC9C9")
SNOW4 = ManimColor("#8B8989")
SPRINGGREEN1 = ManimColor("#00FF7F")
SPRINGGREEN2 = ManimColor("#00EE76")
SPRINGGREEN3 = ManimColor("#00CD66")
SPRINGGREEN4 = ManimColor("#008B45")
STEELBLUE = ManimColor("#4682B4")
STEELBLUE1 = ManimColor("#63B8FF")
STEELBLUE2 = ManimColor("#5CACEE")
STEELBLUE3 = ManimColor("#4F94CD")
STEELBLUE4 = ManimColor("#36648B")
TAN = ManimColor("#D2B48C")
TAN1 = ManimColor("#FFA54F")
TAN2 = ManimColor("#EE9A49")
TAN3 = ManimColor("#CD853F")
TAN4 = ManimColor("#8B5A2B")
THISTLE = ManimColor("#D8BFD8")
THISTLE1 = ManimColor("#FFE1FF")
THISTLE2 = ManimColor("#EED2EE")
THISTLE3 = ManimColor("#CDB5CD")
THISTLE4 = ManimColor("#8B7B8B")
TOMATO1 = ManimColor("#FF6347")
TOMATO2 = ManimColor("#EE5C42")
TOMATO3 = ManimColor("#CD4F39")
TOMATO4 = ManimColor("#8B3626")
TURQUOISE = ManimColor("#40E0D0")
TURQUOISE1 = ManimColor("#00F5FF")
TURQUOISE2 = ManimColor("#00E5EE")
TURQUOISE3 = ManimColor("#00C5CD")
TURQUOISE4 = ManimColor("#00868B")
VIOLET = ManimColor("#EE82EE")
VIOLETRED = ManimColor("#D02090")
VIOLETRED1 = ManimColor("#FF3E96")
VIOLETRED2 = ManimColor("#EE3A8C")
VIOLETRED3 = ManimColor("#CD3278")
VIOLETRED4 = ManimColor("#8B2252")
WHEAT = ManimColor("#F5DEB3")
WHEAT1 = ManimColor("#FFE7BA")
WHEAT2 = ManimColor("#EED8AE")
WHEAT3 = ManimColor("#CDBA96")
WHEAT4 = ManimColor("#8B7E66")
WHITE = ManimColor("#FFFFFF")
WHITESMOKE = ManimColor("#F5F5F5")
YELLOW1 = ManimColor("#FFFF00")
YELLOW2 = ManimColor("#EEEE00")
YELLOW3 = ManimColor("#CDCD00")
YELLOW4 = ManimColor("#8B8B00")
YELLOWGREEN = ManimColor("#9ACD32")

949
manim/utils/color/XKCD.py Normal file
View file

@ -0,0 +1,949 @@
"""Colors from the XKCD Color Name Survey
XKCD is a popular `web comic <https://xkcd.com/353/>`__ created by Randall Munroe.
His "`Color Name Survey <http://blog.xkcd.com/2010/05/03/color-survey-results/>`__" (with
200000 participants) resulted in a list of nearly 1000 color names.
While the ``XKCD`` module is exposed to Manim's global name space, the colors included
in it are not. This means that in order to use the colors, access them via the module name:
.. code:: pycon
>>> from manim import XKCD
>>> XKCD.MANGO
ManimColor('#FFA62B')
List of Color Constants
-----------------------
These hex values are non official approximate values intended to simulate the colors in HTML,
taken from https://www.w3schools.com/colors/colors_xkcd.asp.
.. automanimcolormodule:: manim.utils.color.XKCD
"""
from .core import ManimColor
ACIDGREEN = ManimColor("#8FFE09")
ADOBE = ManimColor("#BD6C48")
ALGAE = ManimColor("#54AC68")
ALGAEGREEN = ManimColor("#21C36F")
ALMOSTBLACK = ManimColor("#070D0D")
AMBER = ManimColor("#FEB308")
AMETHYST = ManimColor("#9B5FC0")
APPLE = ManimColor("#6ECB3C")
APPLEGREEN = ManimColor("#76CD26")
APRICOT = ManimColor("#FFB16D")
AQUA = ManimColor("#13EAC9")
AQUABLUE = ManimColor("#02D8E9")
AQUAGREEN = ManimColor("#12E193")
AQUAMARINE = ManimColor("#2EE8BB")
ARMYGREEN = ManimColor("#4B5D16")
ASPARAGUS = ManimColor("#77AB56")
AUBERGINE = ManimColor("#3D0734")
AUBURN = ManimColor("#9A3001")
AVOCADO = ManimColor("#90B134")
AVOCADOGREEN = ManimColor("#87A922")
AZUL = ManimColor("#1D5DEC")
AZURE = ManimColor("#069AF3")
BABYBLUE = ManimColor("#A2CFFE")
BABYGREEN = ManimColor("#8CFF9E")
BABYPINK = ManimColor("#FFB7CE")
BABYPOO = ManimColor("#AB9004")
BABYPOOP = ManimColor("#937C00")
BABYPOOPGREEN = ManimColor("#8F9805")
BABYPUKEGREEN = ManimColor("#B6C406")
BABYPURPLE = ManimColor("#CA9BF7")
BABYSHITBROWN = ManimColor("#AD900D")
BABYSHITGREEN = ManimColor("#889717")
BANANA = ManimColor("#FFFF7E")
BANANAYELLOW = ManimColor("#FAFE4B")
BARBIEPINK = ManimColor("#FE46A5")
BARFGREEN = ManimColor("#94AC02")
BARNEY = ManimColor("#AC1DB8")
BARNEYPURPLE = ManimColor("#A00498")
BATTLESHIPGREY = ManimColor("#6B7C85")
BEIGE = ManimColor("#E6DAA6")
BERRY = ManimColor("#990F4B")
BILE = ManimColor("#B5C306")
BLACK = ManimColor("#000000")
BLAND = ManimColor("#AFA88B")
BLOOD = ManimColor("#770001")
BLOODORANGE = ManimColor("#FE4B03")
BLOODRED = ManimColor("#980002")
BLUE = ManimColor("#0343DF")
BLUEBERRY = ManimColor("#464196")
BLUEBLUE = ManimColor("#2242C7")
BLUEGREEN = ManimColor("#0F9B8E")
BLUEGREY = ManimColor("#85A3B2")
BLUEPURPLE = ManimColor("#5A06EF")
BLUEVIOLET = ManimColor("#5D06E9")
BLUEWITHAHINTOFPURPLE = ManimColor("#533CC6")
BLUEYGREEN = ManimColor("#2BB179")
BLUEYGREY = ManimColor("#89A0B0")
BLUEYPURPLE = ManimColor("#6241C7")
BLUISH = ManimColor("#2976BB")
BLUISHGREEN = ManimColor("#10A674")
BLUISHGREY = ManimColor("#748B97")
BLUISHPURPLE = ManimColor("#703BE7")
BLURPLE = ManimColor("#5539CC")
BLUSH = ManimColor("#F29E8E")
BLUSHPINK = ManimColor("#FE828C")
BOOGER = ManimColor("#9BB53C")
BOOGERGREEN = ManimColor("#96B403")
BORDEAUX = ManimColor("#7B002C")
BORINGGREEN = ManimColor("#63B365")
BOTTLEGREEN = ManimColor("#044A05")
BRICK = ManimColor("#A03623")
BRICKORANGE = ManimColor("#C14A09")
BRICKRED = ManimColor("#8F1402")
BRIGHTAQUA = ManimColor("#0BF9EA")
BRIGHTBLUE = ManimColor("#0165FC")
BRIGHTCYAN = ManimColor("#41FDFE")
BRIGHTGREEN = ManimColor("#01FF07")
BRIGHTLAVENDER = ManimColor("#C760FF")
BRIGHTLIGHTBLUE = ManimColor("#26F7FD")
BRIGHTLIGHTGREEN = ManimColor("#2DFE54")
BRIGHTLILAC = ManimColor("#C95EFB")
BRIGHTLIME = ManimColor("#87FD05")
BRIGHTLIMEGREEN = ManimColor("#65FE08")
BRIGHTMAGENTA = ManimColor("#FF08E8")
BRIGHTOLIVE = ManimColor("#9CBB04")
BRIGHTORANGE = ManimColor("#FF5B00")
BRIGHTPINK = ManimColor("#FE01B1")
BRIGHTPURPLE = ManimColor("#BE03FD")
BRIGHTRED = ManimColor("#FF000D")
BRIGHTSEAGREEN = ManimColor("#05FFA6")
BRIGHTSKYBLUE = ManimColor("#02CCFE")
BRIGHTTEAL = ManimColor("#01F9C6")
BRIGHTTURQUOISE = ManimColor("#0FFEF9")
BRIGHTVIOLET = ManimColor("#AD0AFD")
BRIGHTYELLOW = ManimColor("#FFFD01")
BRIGHTYELLOWGREEN = ManimColor("#9DFF00")
BRITISHRACINGGREEN = ManimColor("#05480D")
BRONZE = ManimColor("#A87900")
BROWN = ManimColor("#653700")
BROWNGREEN = ManimColor("#706C11")
BROWNGREY = ManimColor("#8D8468")
BROWNISH = ManimColor("#9C6D57")
BROWNISHGREEN = ManimColor("#6A6E09")
BROWNISHGREY = ManimColor("#86775F")
BROWNISHORANGE = ManimColor("#CB7723")
BROWNISHPINK = ManimColor("#C27E79")
BROWNISHPURPLE = ManimColor("#76424E")
BROWNISHRED = ManimColor("#9E3623")
BROWNISHYELLOW = ManimColor("#C9B003")
BROWNORANGE = ManimColor("#B96902")
BROWNRED = ManimColor("#922B05")
BROWNYELLOW = ManimColor("#B29705")
BROWNYGREEN = ManimColor("#6F6C0A")
BROWNYORANGE = ManimColor("#CA6B02")
BRUISE = ManimColor("#7E4071")
BUBBLEGUM = ManimColor("#FF6CB5")
BUBBLEGUMPINK = ManimColor("#FF69AF")
BUFF = ManimColor("#FEF69E")
BURGUNDY = ManimColor("#610023")
BURNTORANGE = ManimColor("#C04E01")
BURNTRED = ManimColor("#9F2305")
BURNTSIENA = ManimColor("#B75203")
BURNTSIENNA = ManimColor("#B04E0F")
BURNTUMBER = ManimColor("#A0450E")
BURNTYELLOW = ManimColor("#D5AB09")
BURPLE = ManimColor("#6832E3")
BUTTER = ManimColor("#FFFF81")
BUTTERSCOTCH = ManimColor("#FDB147")
BUTTERYELLOW = ManimColor("#FFFD74")
CADETBLUE = ManimColor("#4E7496")
CAMEL = ManimColor("#C69F59")
CAMO = ManimColor("#7F8F4E")
CAMOGREEN = ManimColor("#526525")
CAMOUFLAGEGREEN = ManimColor("#4B6113")
CANARY = ManimColor("#FDFF63")
CANARYYELLOW = ManimColor("#FFFE40")
CANDYPINK = ManimColor("#FF63E9")
CARAMEL = ManimColor("#AF6F09")
CARMINE = ManimColor("#9D0216")
CARNATION = ManimColor("#FD798F")
CARNATIONPINK = ManimColor("#FF7FA7")
CAROLINABLUE = ManimColor("#8AB8FE")
CELADON = ManimColor("#BEFDB7")
CELERY = ManimColor("#C1FD95")
CEMENT = ManimColor("#A5A391")
CERISE = ManimColor("#DE0C62")
CERULEAN = ManimColor("#0485D1")
CERULEANBLUE = ManimColor("#056EEE")
CHARCOAL = ManimColor("#343837")
CHARCOALGREY = ManimColor("#3C4142")
CHARTREUSE = ManimColor("#C1F80A")
CHERRY = ManimColor("#CF0234")
CHERRYRED = ManimColor("#F7022A")
CHESTNUT = ManimColor("#742802")
CHOCOLATE = ManimColor("#3D1C02")
CHOCOLATEBROWN = ManimColor("#411900")
CINNAMON = ManimColor("#AC4F06")
CLARET = ManimColor("#680018")
CLAY = ManimColor("#B66A50")
CLAYBROWN = ManimColor("#B2713D")
CLEARBLUE = ManimColor("#247AFD")
COBALT = ManimColor("#1E488F")
COBALTBLUE = ManimColor("#030AA7")
COCOA = ManimColor("#875F42")
COFFEE = ManimColor("#A6814C")
COOLBLUE = ManimColor("#4984B8")
COOLGREEN = ManimColor("#33B864")
COOLGREY = ManimColor("#95A3A6")
COPPER = ManimColor("#B66325")
CORAL = ManimColor("#FC5A50")
CORALPINK = ManimColor("#FF6163")
CORNFLOWER = ManimColor("#6A79F7")
CORNFLOWERBLUE = ManimColor("#5170D7")
CRANBERRY = ManimColor("#9E003A")
CREAM = ManimColor("#FFFFC2")
CREME = ManimColor("#FFFFB6")
CRIMSON = ManimColor("#8C000F")
CUSTARD = ManimColor("#FFFD78")
CYAN = ManimColor("#00FFFF")
DANDELION = ManimColor("#FEDF08")
DARK = ManimColor("#1B2431")
DARKAQUA = ManimColor("#05696B")
DARKAQUAMARINE = ManimColor("#017371")
DARKBEIGE = ManimColor("#AC9362")
DARKBLUE = ManimColor("#030764")
DARKBLUEGREEN = ManimColor("#005249")
DARKBLUEGREY = ManimColor("#1F3B4D")
DARKBROWN = ManimColor("#341C02")
DARKCORAL = ManimColor("#CF524E")
DARKCREAM = ManimColor("#FFF39A")
DARKCYAN = ManimColor("#0A888A")
DARKFORESTGREEN = ManimColor("#002D04")
DARKFUCHSIA = ManimColor("#9D0759")
DARKGOLD = ManimColor("#B59410")
DARKGRASSGREEN = ManimColor("#388004")
DARKGREEN = ManimColor("#054907")
DARKGREENBLUE = ManimColor("#1F6357")
DARKGREY = ManimColor("#363737")
DARKGREYBLUE = ManimColor("#29465B")
DARKHOTPINK = ManimColor("#D90166")
DARKINDIGO = ManimColor("#1F0954")
DARKISHBLUE = ManimColor("#014182")
DARKISHGREEN = ManimColor("#287C37")
DARKISHPINK = ManimColor("#DA467D")
DARKISHPURPLE = ManimColor("#751973")
DARKISHRED = ManimColor("#A90308")
DARKKHAKI = ManimColor("#9B8F55")
DARKLAVENDER = ManimColor("#856798")
DARKLILAC = ManimColor("#9C6DA5")
DARKLIME = ManimColor("#84B701")
DARKLIMEGREEN = ManimColor("#7EBD01")
DARKMAGENTA = ManimColor("#960056")
DARKMAROON = ManimColor("#3C0008")
DARKMAUVE = ManimColor("#874C62")
DARKMINT = ManimColor("#48C072")
DARKMINTGREEN = ManimColor("#20C073")
DARKMUSTARD = ManimColor("#A88905")
DARKNAVY = ManimColor("#000435")
DARKNAVYBLUE = ManimColor("#00022E")
DARKOLIVE = ManimColor("#373E02")
DARKOLIVEGREEN = ManimColor("#3C4D03")
DARKORANGE = ManimColor("#C65102")
DARKPASTELGREEN = ManimColor("#56AE57")
DARKPEACH = ManimColor("#DE7E5D")
DARKPERIWINKLE = ManimColor("#665FD1")
DARKPINK = ManimColor("#CB416B")
DARKPLUM = ManimColor("#3F012C")
DARKPURPLE = ManimColor("#35063E")
DARKRED = ManimColor("#840000")
DARKROSE = ManimColor("#B5485D")
DARKROYALBLUE = ManimColor("#02066F")
DARKSAGE = ManimColor("#598556")
DARKSALMON = ManimColor("#C85A53")
DARKSAND = ManimColor("#A88F59")
DARKSEAFOAM = ManimColor("#1FB57A")
DARKSEAFOAMGREEN = ManimColor("#3EAF76")
DARKSEAGREEN = ManimColor("#11875D")
DARKSKYBLUE = ManimColor("#448EE4")
DARKSLATEBLUE = ManimColor("#214761")
DARKTAN = ManimColor("#AF884A")
DARKTAUPE = ManimColor("#7F684E")
DARKTEAL = ManimColor("#014D4E")
DARKTURQUOISE = ManimColor("#045C5A")
DARKVIOLET = ManimColor("#34013F")
DARKYELLOW = ManimColor("#D5B60A")
DARKYELLOWGREEN = ManimColor("#728F02")
DEEPAQUA = ManimColor("#08787F")
DEEPBLUE = ManimColor("#040273")
DEEPBROWN = ManimColor("#410200")
DEEPGREEN = ManimColor("#02590F")
DEEPLAVENDER = ManimColor("#8D5EB7")
DEEPLILAC = ManimColor("#966EBD")
DEEPMAGENTA = ManimColor("#A0025C")
DEEPORANGE = ManimColor("#DC4D01")
DEEPPINK = ManimColor("#CB0162")
DEEPPURPLE = ManimColor("#36013F")
DEEPRED = ManimColor("#9A0200")
DEEPROSE = ManimColor("#C74767")
DEEPSEABLUE = ManimColor("#015482")
DEEPSKYBLUE = ManimColor("#0D75F8")
DEEPTEAL = ManimColor("#00555A")
DEEPTURQUOISE = ManimColor("#017374")
DEEPVIOLET = ManimColor("#490648")
DENIM = ManimColor("#3B638C")
DENIMBLUE = ManimColor("#3B5B92")
DESERT = ManimColor("#CCAD60")
DIARRHEA = ManimColor("#9F8303")
DIRT = ManimColor("#8A6E45")
DIRTBROWN = ManimColor("#836539")
DIRTYBLUE = ManimColor("#3F829D")
DIRTYGREEN = ManimColor("#667E2C")
DIRTYORANGE = ManimColor("#C87606")
DIRTYPINK = ManimColor("#CA7B80")
DIRTYPURPLE = ManimColor("#734A65")
DIRTYYELLOW = ManimColor("#CDC50A")
DODGERBLUE = ManimColor("#3E82FC")
DRAB = ManimColor("#828344")
DRABGREEN = ManimColor("#749551")
DRIEDBLOOD = ManimColor("#4B0101")
DUCKEGGBLUE = ManimColor("#C3FBF4")
DULLBLUE = ManimColor("#49759C")
DULLBROWN = ManimColor("#876E4B")
DULLGREEN = ManimColor("#74A662")
DULLORANGE = ManimColor("#D8863B")
DULLPINK = ManimColor("#D5869D")
DULLPURPLE = ManimColor("#84597E")
DULLRED = ManimColor("#BB3F3F")
DULLTEAL = ManimColor("#5F9E8F")
DULLYELLOW = ManimColor("#EEDC5B")
DUSK = ManimColor("#4E5481")
DUSKBLUE = ManimColor("#26538D")
DUSKYBLUE = ManimColor("#475F94")
DUSKYPINK = ManimColor("#CC7A8B")
DUSKYPURPLE = ManimColor("#895B7B")
DUSKYROSE = ManimColor("#BA6873")
DUST = ManimColor("#B2996E")
DUSTYBLUE = ManimColor("#5A86AD")
DUSTYGREEN = ManimColor("#76A973")
DUSTYLAVENDER = ManimColor("#AC86A8")
DUSTYORANGE = ManimColor("#F0833A")
DUSTYPINK = ManimColor("#D58A94")
DUSTYPURPLE = ManimColor("#825F87")
DUSTYRED = ManimColor("#B9484E")
DUSTYROSE = ManimColor("#C0737A")
DUSTYTEAL = ManimColor("#4C9085")
EARTH = ManimColor("#A2653E")
EASTERGREEN = ManimColor("#8CFD7E")
EASTERPURPLE = ManimColor("#C071FE")
ECRU = ManimColor("#FEFFCA")
EGGPLANT = ManimColor("#380835")
EGGPLANTPURPLE = ManimColor("#430541")
EGGSHELL = ManimColor("#FFFCC4")
EGGSHELLBLUE = ManimColor("#C4FFF7")
ELECTRICBLUE = ManimColor("#0652FF")
ELECTRICGREEN = ManimColor("#21FC0D")
ELECTRICLIME = ManimColor("#A8FF04")
ELECTRICPINK = ManimColor("#FF0490")
ELECTRICPURPLE = ManimColor("#AA23FF")
EMERALD = ManimColor("#01A049")
EMERALDGREEN = ManimColor("#028F1E")
EVERGREEN = ManimColor("#05472A")
FADEDBLUE = ManimColor("#658CBB")
FADEDGREEN = ManimColor("#7BB274")
FADEDORANGE = ManimColor("#F0944D")
FADEDPINK = ManimColor("#DE9DAC")
FADEDPURPLE = ManimColor("#916E99")
FADEDRED = ManimColor("#D3494E")
FADEDYELLOW = ManimColor("#FEFF7F")
FAWN = ManimColor("#CFAF7B")
FERN = ManimColor("#63A950")
FERNGREEN = ManimColor("#548D44")
FIREENGINERED = ManimColor("#FE0002")
FLATBLUE = ManimColor("#3C73A8")
FLATGREEN = ManimColor("#699D4C")
FLUORESCENTGREEN = ManimColor("#08FF08")
FLUROGREEN = ManimColor("#0AFF02")
FOAMGREEN = ManimColor("#90FDA9")
FOREST = ManimColor("#0B5509")
FORESTGREEN = ManimColor("#06470C")
FORRESTGREEN = ManimColor("#154406")
FRENCHBLUE = ManimColor("#436BAD")
FRESHGREEN = ManimColor("#69D84F")
FROGGREEN = ManimColor("#58BC08")
FUCHSIA = ManimColor("#ED0DD9")
GOLD = ManimColor("#DBB40C")
GOLDEN = ManimColor("#F5BF03")
GOLDENBROWN = ManimColor("#B27A01")
GOLDENROD = ManimColor("#F9BC08")
GOLDENYELLOW = ManimColor("#FEC615")
GRAPE = ManimColor("#6C3461")
GRAPEFRUIT = ManimColor("#FD5956")
GRAPEPURPLE = ManimColor("#5D1451")
GRASS = ManimColor("#5CAC2D")
GRASSGREEN = ManimColor("#3F9B0B")
GRASSYGREEN = ManimColor("#419C03")
GREEN = ManimColor("#15B01A")
GREENAPPLE = ManimColor("#5EDC1F")
GREENBLUE = ManimColor("#01C08D")
GREENBROWN = ManimColor("#544E03")
GREENGREY = ManimColor("#77926F")
GREENISH = ManimColor("#40A368")
GREENISHBEIGE = ManimColor("#C9D179")
GREENISHBLUE = ManimColor("#0B8B87")
GREENISHBROWN = ManimColor("#696112")
GREENISHCYAN = ManimColor("#2AFEB7")
GREENISHGREY = ManimColor("#96AE8D")
GREENISHTAN = ManimColor("#BCCB7A")
GREENISHTEAL = ManimColor("#32BF84")
GREENISHTURQUOISE = ManimColor("#00FBB0")
GREENISHYELLOW = ManimColor("#CDFD02")
GREENTEAL = ManimColor("#0CB577")
GREENYBLUE = ManimColor("#42B395")
GREENYBROWN = ManimColor("#696006")
GREENYELLOW = ManimColor("#B5CE08")
GREENYGREY = ManimColor("#7EA07A")
GREENYYELLOW = ManimColor("#C6F808")
GREY = ManimColor("#929591")
GREYBLUE = ManimColor("#647D8E")
GREYBROWN = ManimColor("#7F7053")
GREYGREEN = ManimColor("#86A17D")
GREYISH = ManimColor("#A8A495")
GREYISHBLUE = ManimColor("#5E819D")
GREYISHBROWN = ManimColor("#7A6A4F")
GREYISHGREEN = ManimColor("#82A67D")
GREYISHPINK = ManimColor("#C88D94")
GREYISHPURPLE = ManimColor("#887191")
GREYISHTEAL = ManimColor("#719F91")
GREYPINK = ManimColor("#C3909B")
GREYPURPLE = ManimColor("#826D8C")
GREYTEAL = ManimColor("#5E9B8A")
GROSSGREEN = ManimColor("#A0BF16")
GUNMETAL = ManimColor("#536267")
HAZEL = ManimColor("#8E7618")
HEATHER = ManimColor("#A484AC")
HELIOTROPE = ManimColor("#D94FF5")
HIGHLIGHTERGREEN = ManimColor("#1BFC06")
HOSPITALGREEN = ManimColor("#9BE5AA")
HOTGREEN = ManimColor("#25FF29")
HOTMAGENTA = ManimColor("#F504C9")
HOTPINK = ManimColor("#FF028D")
HOTPURPLE = ManimColor("#CB00F5")
HUNTERGREEN = ManimColor("#0B4008")
ICE = ManimColor("#D6FFFA")
ICEBLUE = ManimColor("#D7FFFE")
ICKYGREEN = ManimColor("#8FAE22")
INDIANRED = ManimColor("#850E04")
INDIGO = ManimColor("#380282")
INDIGOBLUE = ManimColor("#3A18B1")
IRIS = ManimColor("#6258C4")
IRISHGREEN = ManimColor("#019529")
IVORY = ManimColor("#FFFFCB")
JADE = ManimColor("#1FA774")
JADEGREEN = ManimColor("#2BAF6A")
JUNGLEGREEN = ManimColor("#048243")
KELLEYGREEN = ManimColor("#009337")
KELLYGREEN = ManimColor("#02AB2E")
KERMITGREEN = ManimColor("#5CB200")
KEYLIME = ManimColor("#AEFF6E")
KHAKI = ManimColor("#AAA662")
KHAKIGREEN = ManimColor("#728639")
KIWI = ManimColor("#9CEF43")
KIWIGREEN = ManimColor("#8EE53F")
LAVENDER = ManimColor("#C79FEF")
LAVENDERBLUE = ManimColor("#8B88F8")
LAVENDERPINK = ManimColor("#DD85D7")
LAWNGREEN = ManimColor("#4DA409")
LEAF = ManimColor("#71AA34")
LEAFGREEN = ManimColor("#5CA904")
LEAFYGREEN = ManimColor("#51B73B")
LEATHER = ManimColor("#AC7434")
LEMON = ManimColor("#FDFF52")
LEMONGREEN = ManimColor("#ADF802")
LEMONLIME = ManimColor("#BFFE28")
LEMONYELLOW = ManimColor("#FDFF38")
LICHEN = ManimColor("#8FB67B")
LIGHTAQUA = ManimColor("#8CFFDB")
LIGHTAQUAMARINE = ManimColor("#7BFDC7")
LIGHTBEIGE = ManimColor("#FFFEB6")
LIGHTBLUE = ManimColor("#7BC8F6")
LIGHTBLUEGREEN = ManimColor("#7EFBB3")
LIGHTBLUEGREY = ManimColor("#B7C9E2")
LIGHTBLUISHGREEN = ManimColor("#76FDA8")
LIGHTBRIGHTGREEN = ManimColor("#53FE5C")
LIGHTBROWN = ManimColor("#AD8150")
LIGHTBURGUNDY = ManimColor("#A8415B")
LIGHTCYAN = ManimColor("#ACFFFC")
LIGHTEGGPLANT = ManimColor("#894585")
LIGHTERGREEN = ManimColor("#75FD63")
LIGHTERPURPLE = ManimColor("#A55AF4")
LIGHTFORESTGREEN = ManimColor("#4F9153")
LIGHTGOLD = ManimColor("#FDDC5C")
LIGHTGRASSGREEN = ManimColor("#9AF764")
LIGHTGREEN = ManimColor("#76FF7B")
LIGHTGREENBLUE = ManimColor("#56FCA2")
LIGHTGREENISHBLUE = ManimColor("#63F7B4")
LIGHTGREY = ManimColor("#D8DCD6")
LIGHTGREYBLUE = ManimColor("#9DBCD4")
LIGHTGREYGREEN = ManimColor("#B7E1A1")
LIGHTINDIGO = ManimColor("#6D5ACF")
LIGHTISHBLUE = ManimColor("#3D7AFD")
LIGHTISHGREEN = ManimColor("#61E160")
LIGHTISHPURPLE = ManimColor("#A552E6")
LIGHTISHRED = ManimColor("#FE2F4A")
LIGHTKHAKI = ManimColor("#E6F2A2")
LIGHTLAVENDAR = ManimColor("#EFC0FE")
LIGHTLAVENDER = ManimColor("#DFC5FE")
LIGHTLIGHTBLUE = ManimColor("#CAFFFB")
LIGHTLIGHTGREEN = ManimColor("#C8FFB0")
LIGHTLILAC = ManimColor("#EDC8FF")
LIGHTLIME = ManimColor("#AEFD6C")
LIGHTLIMEGREEN = ManimColor("#B9FF66")
LIGHTMAGENTA = ManimColor("#FA5FF7")
LIGHTMAROON = ManimColor("#A24857")
LIGHTMAUVE = ManimColor("#C292A1")
LIGHTMINT = ManimColor("#B6FFBB")
LIGHTMINTGREEN = ManimColor("#A6FBB2")
LIGHTMOSSGREEN = ManimColor("#A6C875")
LIGHTMUSTARD = ManimColor("#F7D560")
LIGHTNAVY = ManimColor("#155084")
LIGHTNAVYBLUE = ManimColor("#2E5A88")
LIGHTNEONGREEN = ManimColor("#4EFD54")
LIGHTOLIVE = ManimColor("#ACBF69")
LIGHTOLIVEGREEN = ManimColor("#A4BE5C")
LIGHTORANGE = ManimColor("#FDAA48")
LIGHTPASTELGREEN = ManimColor("#B2FBA5")
LIGHTPEACH = ManimColor("#FFD8B1")
LIGHTPEAGREEN = ManimColor("#C4FE82")
LIGHTPERIWINKLE = ManimColor("#C1C6FC")
LIGHTPINK = ManimColor("#FFD1DF")
LIGHTPLUM = ManimColor("#9D5783")
LIGHTPURPLE = ManimColor("#BF77F6")
LIGHTRED = ManimColor("#FF474C")
LIGHTROSE = ManimColor("#FFC5CB")
LIGHTROYALBLUE = ManimColor("#3A2EFE")
LIGHTSAGE = ManimColor("#BCECAC")
LIGHTSALMON = ManimColor("#FEA993")
LIGHTSEAFOAM = ManimColor("#A0FEBF")
LIGHTSEAFOAMGREEN = ManimColor("#a7ffb5")
LIGHTSEAGREEN = ManimColor("#98F6B0")
LIGHTSKYBLUE = ManimColor("#C6FCFF")
LIGHTTAN = ManimColor("#FBEEAC")
LIGHTTEAL = ManimColor("#90E4C1")
LIGHTTURQUOISE = ManimColor("#7EF4CC")
LIGHTURPLE = ManimColor("#B36FF6")
LIGHTVIOLET = ManimColor("#D6B4FC")
LIGHTYELLOW = ManimColor("#FFFE7A")
LIGHTYELLOWGREEN = ManimColor("#CCFD7F")
LIGHTYELLOWISHGREEN = ManimColor("#C2FF89")
LILAC = ManimColor("#CEA2FD")
LILIAC = ManimColor("#C48EFD")
LIME = ManimColor("#AAFF32")
LIMEGREEN = ManimColor("#89FE05")
LIMEYELLOW = ManimColor("#D0FE1D")
LIPSTICK = ManimColor("#D5174E")
LIPSTICKRED = ManimColor("#C0022F")
MACARONIANDCHEESE = ManimColor("#EFB435")
MAGENTA = ManimColor("#C20078")
MAHOGANY = ManimColor("#4A0100")
MAIZE = ManimColor("#F4D054")
MANGO = ManimColor("#FFA62B")
MANILLA = ManimColor("#FFFA86")
MARIGOLD = ManimColor("#FCC006")
MARINE = ManimColor("#042E60")
MARINEBLUE = ManimColor("#01386A")
MAROON = ManimColor("#650021")
MAUVE = ManimColor("#AE7181")
MEDIUMBLUE = ManimColor("#2C6FBB")
MEDIUMBROWN = ManimColor("#7F5112")
MEDIUMGREEN = ManimColor("#39AD48")
MEDIUMGREY = ManimColor("#7D7F7C")
MEDIUMPINK = ManimColor("#F36196")
MEDIUMPURPLE = ManimColor("#9E43A2")
MELON = ManimColor("#FF7855")
MERLOT = ManimColor("#730039")
METALLICBLUE = ManimColor("#4F738E")
MIDBLUE = ManimColor("#276AB3")
MIDGREEN = ManimColor("#50A747")
MIDNIGHT = ManimColor("#03012D")
MIDNIGHTBLUE = ManimColor("#020035")
MIDNIGHTPURPLE = ManimColor("#280137")
MILITARYGREEN = ManimColor("#667C3E")
MILKCHOCOLATE = ManimColor("#7F4E1E")
MINT = ManimColor("#9FFEB0")
MINTGREEN = ManimColor("#8FFF9F")
MINTYGREEN = ManimColor("#0BF77D")
MOCHA = ManimColor("#9D7651")
MOSS = ManimColor("#769958")
MOSSGREEN = ManimColor("#658B38")
MOSSYGREEN = ManimColor("#638B27")
MUD = ManimColor("#735C12")
MUDBROWN = ManimColor("#60460F")
MUDDYBROWN = ManimColor("#886806")
MUDDYGREEN = ManimColor("#657432")
MUDDYYELLOW = ManimColor("#BFAC05")
MUDGREEN = ManimColor("#606602")
MULBERRY = ManimColor("#920A4E")
MURKYGREEN = ManimColor("#6C7A0E")
MUSHROOM = ManimColor("#BA9E88")
MUSTARD = ManimColor("#CEB301")
MUSTARDBROWN = ManimColor("#AC7E04")
MUSTARDGREEN = ManimColor("#A8B504")
MUSTARDYELLOW = ManimColor("#D2BD0A")
MUTEDBLUE = ManimColor("#3B719F")
MUTEDGREEN = ManimColor("#5FA052")
MUTEDPINK = ManimColor("#D1768F")
MUTEDPURPLE = ManimColor("#805B87")
NASTYGREEN = ManimColor("#70B23F")
NAVY = ManimColor("#01153E")
NAVYBLUE = ManimColor("#001146")
NAVYGREEN = ManimColor("#35530A")
NEONBLUE = ManimColor("#04D9FF")
NEONGREEN = ManimColor("#0CFF0C")
NEONPINK = ManimColor("#FE019A")
NEONPURPLE = ManimColor("#BC13FE")
NEONRED = ManimColor("#FF073A")
NEONYELLOW = ManimColor("#CFFF04")
NICEBLUE = ManimColor("#107AB0")
NIGHTBLUE = ManimColor("#040348")
OCEAN = ManimColor("#017B92")
OCEANBLUE = ManimColor("#03719C")
OCEANGREEN = ManimColor("#3D9973")
OCHER = ManimColor("#BF9B0C")
OCHRE = ManimColor("#BF9005")
OCRE = ManimColor("#C69C04")
OFFBLUE = ManimColor("#5684AE")
OFFGREEN = ManimColor("#6BA353")
OFFWHITE = ManimColor("#FFFFE4")
OFFYELLOW = ManimColor("#F1F33F")
OLDPINK = ManimColor("#C77986")
OLDROSE = ManimColor("#C87F89")
OLIVE = ManimColor("#6E750E")
OLIVEBROWN = ManimColor("#645403")
OLIVEDRAB = ManimColor("#6F7632")
OLIVEGREEN = ManimColor("#677A04")
OLIVEYELLOW = ManimColor("#C2B709")
ORANGE = ManimColor("#F97306")
ORANGEBROWN = ManimColor("#BE6400")
ORANGEISH = ManimColor("#FD8D49")
ORANGEPINK = ManimColor("#FF6F52")
ORANGERED = ManimColor("#FE420F")
ORANGEYBROWN = ManimColor("#B16002")
ORANGEYELLOW = ManimColor("#FFAD01")
ORANGEYRED = ManimColor("#FA4224")
ORANGEYYELLOW = ManimColor("#FDB915")
ORANGISH = ManimColor("#FC824A")
ORANGISHBROWN = ManimColor("#B25F03")
ORANGISHRED = ManimColor("#F43605")
ORCHID = ManimColor("#C875C4")
PALE = ManimColor("#FFF9D0")
PALEAQUA = ManimColor("#B8FFEB")
PALEBLUE = ManimColor("#D0FEFE")
PALEBROWN = ManimColor("#B1916E")
PALECYAN = ManimColor("#B7FFFA")
PALEGOLD = ManimColor("#FDDE6C")
PALEGREEN = ManimColor("#C7FDB5")
PALEGREY = ManimColor("#FDFDFE")
PALELAVENDER = ManimColor("#EECFFE")
PALELIGHTGREEN = ManimColor("#B1FC99")
PALELILAC = ManimColor("#E4CBFF")
PALELIME = ManimColor("#BEFD73")
PALELIMEGREEN = ManimColor("#B1FF65")
PALEMAGENTA = ManimColor("#D767AD")
PALEMAUVE = ManimColor("#FED0FC")
PALEOLIVE = ManimColor("#B9CC81")
PALEOLIVEGREEN = ManimColor("#B1D27B")
PALEORANGE = ManimColor("#FFA756")
PALEPEACH = ManimColor("#FFE5AD")
PALEPINK = ManimColor("#FFCFDC")
PALEPURPLE = ManimColor("#B790D4")
PALERED = ManimColor("#D9544D")
PALEROSE = ManimColor("#FDC1C5")
PALESALMON = ManimColor("#FFB19A")
PALESKYBLUE = ManimColor("#BDF6FE")
PALETEAL = ManimColor("#82CBB2")
PALETURQUOISE = ManimColor("#A5FBD5")
PALEVIOLET = ManimColor("#CEAEFA")
PALEYELLOW = ManimColor("#FFFF84")
PARCHMENT = ManimColor("#FEFCAF")
PASTELBLUE = ManimColor("#A2BFFE")
PASTELGREEN = ManimColor("#B0FF9D")
PASTELORANGE = ManimColor("#FF964F")
PASTELPINK = ManimColor("#FFBACD")
PASTELPURPLE = ManimColor("#CAA0FF")
PASTELRED = ManimColor("#DB5856")
PASTELYELLOW = ManimColor("#FFFE71")
PEA = ManimColor("#A4BF20")
PEACH = ManimColor("#FFB07C")
PEACHYPINK = ManimColor("#FF9A8A")
PEACOCKBLUE = ManimColor("#016795")
PEAGREEN = ManimColor("#8EAB12")
PEAR = ManimColor("#CBF85F")
PEASOUP = ManimColor("#929901")
PEASOUPGREEN = ManimColor("#94A617")
PERIWINKLE = ManimColor("#8E82FE")
PERIWINKLEBLUE = ManimColor("#8F99FB")
PERRYWINKLE = ManimColor("#8F8CE7")
PETROL = ManimColor("#005F6A")
PIGPINK = ManimColor("#E78EA5")
PINE = ManimColor("#2B5D34")
PINEGREEN = ManimColor("#0A481E")
PINK = ManimColor("#FF81C0")
PINKISH = ManimColor("#D46A7E")
PINKISHBROWN = ManimColor("#B17261")
PINKISHGREY = ManimColor("#C8ACA9")
PINKISHORANGE = ManimColor("#FF724C")
PINKISHPURPLE = ManimColor("#D648D7")
PINKISHRED = ManimColor("#F10C45")
PINKISHTAN = ManimColor("#D99B82")
PINKPURPLE = ManimColor("#EF1DE7")
PINKRED = ManimColor("#F5054F")
PINKY = ManimColor("#FC86AA")
PINKYPURPLE = ManimColor("#C94CBE")
PINKYRED = ManimColor("#FC2647")
PISSYELLOW = ManimColor("#DDD618")
PISTACHIO = ManimColor("#C0FA8B")
PLUM = ManimColor("#580F41")
PLUMPURPLE = ManimColor("#4E0550")
POISONGREEN = ManimColor("#40FD14")
POO = ManimColor("#8F7303")
POOBROWN = ManimColor("#885F01")
POOP = ManimColor("#7F5E00")
POOPBROWN = ManimColor("#7A5901")
POOPGREEN = ManimColor("#6F7C00")
POWDERBLUE = ManimColor("#B1D1FC")
POWDERPINK = ManimColor("#FFB2D0")
PRIMARYBLUE = ManimColor("#0804F9")
PRUSSIANBLUE = ManimColor("#004577")
PUCE = ManimColor("#A57E52")
PUKE = ManimColor("#A5A502")
PUKEBROWN = ManimColor("#947706")
PUKEGREEN = ManimColor("#9AAE07")
PUKEYELLOW = ManimColor("#C2BE0E")
PUMPKIN = ManimColor("#E17701")
PUMPKINORANGE = ManimColor("#FB7D07")
PUREBLUE = ManimColor("#0203E2")
PURPLE = ManimColor("#7E1E9C")
PURPLEBLUE = ManimColor("#5D21D0")
PURPLEBROWN = ManimColor("#673A3F")
PURPLEGREY = ManimColor("#866F85")
PURPLEISH = ManimColor("#98568D")
PURPLEISHBLUE = ManimColor("#6140EF")
PURPLEISHPINK = ManimColor("#DF4EC8")
PURPLEPINK = ManimColor("#D725DE")
PURPLERED = ManimColor("#990147")
PURPLEY = ManimColor("#8756E4")
PURPLEYBLUE = ManimColor("#5F34E7")
PURPLEYGREY = ManimColor("#947E94")
PURPLEYPINK = ManimColor("#C83CB9")
PURPLISH = ManimColor("#94568C")
PURPLISHBLUE = ManimColor("#601EF9")
PURPLISHBROWN = ManimColor("#6B4247")
PURPLISHGREY = ManimColor("#7A687F")
PURPLISHPINK = ManimColor("#CE5DAE")
PURPLISHRED = ManimColor("#B0054B")
PURPLY = ManimColor("#983FB2")
PURPLYBLUE = ManimColor("#661AEE")
PURPLYPINK = ManimColor("#F075E6")
PUTTY = ManimColor("#BEAE8A")
RACINGGREEN = ManimColor("#014600")
RADIOACTIVEGREEN = ManimColor("#2CFA1F")
RASPBERRY = ManimColor("#B00149")
RAWSIENNA = ManimColor("#9A6200")
RAWUMBER = ManimColor("#A75E09")
REALLYLIGHTBLUE = ManimColor("#D4FFFF")
RED = ManimColor("#E50000")
REDBROWN = ManimColor("#8B2E16")
REDDISH = ManimColor("#C44240")
REDDISHBROWN = ManimColor("#7F2B0A")
REDDISHGREY = ManimColor("#997570")
REDDISHORANGE = ManimColor("#F8481C")
REDDISHPINK = ManimColor("#FE2C54")
REDDISHPURPLE = ManimColor("#910951")
REDDYBROWN = ManimColor("#6E1005")
REDORANGE = ManimColor("#FD3C06")
REDPINK = ManimColor("#FA2A55")
REDPURPLE = ManimColor("#820747")
REDVIOLET = ManimColor("#9E0168")
REDWINE = ManimColor("#8C0034")
RICHBLUE = ManimColor("#021BF9")
RICHPURPLE = ManimColor("#720058")
ROBINEGGBLUE = ManimColor("#8AF1FE")
ROBINSEGG = ManimColor("#6DEDFD")
ROBINSEGGBLUE = ManimColor("#98EFF9")
ROSA = ManimColor("#FE86A4")
ROSE = ManimColor("#CF6275")
ROSEPINK = ManimColor("#F7879A")
ROSERED = ManimColor("#BE013C")
ROSYPINK = ManimColor("#F6688E")
ROGUE = ManimColor("#AB1239")
ROYAL = ManimColor("#0C1793")
ROYALBLUE = ManimColor("#0504AA")
ROYALPURPLE = ManimColor("#4B006E")
RUBY = ManimColor("#CA0147")
RUSSET = ManimColor("#A13905")
RUST = ManimColor("#A83C09")
RUSTBROWN = ManimColor("#8B3103")
RUSTORANGE = ManimColor("#C45508")
RUSTRED = ManimColor("#AA2704")
RUSTYORANGE = ManimColor("#CD5909")
RUSTYRED = ManimColor("#AF2F0D")
SAFFRON = ManimColor("#FEB209")
SAGE = ManimColor("#87AE73")
SAGEGREEN = ManimColor("#88B378")
SALMON = ManimColor("#FF796C")
SALMONPINK = ManimColor("#FE7B7C")
SAND = ManimColor("#E2CA76")
SANDBROWN = ManimColor("#CBA560")
SANDSTONE = ManimColor("#C9AE74")
SANDY = ManimColor("#F1DA7A")
SANDYBROWN = ManimColor("#C4A661")
SANDYELLOW = ManimColor("#FCE166")
SANDYYELLOW = ManimColor("#FDEE73")
SAPGREEN = ManimColor("#5C8B15")
SAPPHIRE = ManimColor("#2138AB")
SCARLET = ManimColor("#BE0119")
SEA = ManimColor("#3C9992")
SEABLUE = ManimColor("#047495")
SEAFOAM = ManimColor("#80F9AD")
SEAFOAMBLUE = ManimColor("#78D1B6")
SEAFOAMGREEN = ManimColor("#7AF9AB")
SEAGREEN = ManimColor("#53FCA1")
SEAWEED = ManimColor("#18D17B")
SEAWEEDGREEN = ManimColor("#35AD6B")
SEPIA = ManimColor("#985E2B")
SHAMROCK = ManimColor("#01B44C")
SHAMROCKGREEN = ManimColor("#02C14D")
SHIT = ManimColor("#7F5F00")
SHITBROWN = ManimColor("#7B5804")
SHITGREEN = ManimColor("#758000")
SHOCKINGPINK = ManimColor("#FE02A2")
SICKGREEN = ManimColor("#9DB92C")
SICKLYGREEN = ManimColor("#94B21C")
SICKLYYELLOW = ManimColor("#D0E429")
SIENNA = ManimColor("#A9561E")
SILVER = ManimColor("#C5C9C7")
SKY = ManimColor("#82CAFC")
SKYBLUE = ManimColor("#75BBFD")
SLATE = ManimColor("#516572")
SLATEBLUE = ManimColor("#5B7C99")
SLATEGREEN = ManimColor("#658D6D")
SLATEGREY = ManimColor("#59656D")
SLIMEGREEN = ManimColor("#99CC04")
SNOT = ManimColor("#ACBB0D")
SNOTGREEN = ManimColor("#9DC100")
SOFTBLUE = ManimColor("#6488EA")
SOFTGREEN = ManimColor("#6FC276")
SOFTPINK = ManimColor("#FDB0C0")
SOFTPURPLE = ManimColor("#A66FB5")
SPEARMINT = ManimColor("#1EF876")
SPRINGGREEN = ManimColor("#A9F971")
SPRUCE = ManimColor("#0A5F38")
SQUASH = ManimColor("#F2AB15")
STEEL = ManimColor("#738595")
STEELBLUE = ManimColor("#5A7D9A")
STEELGREY = ManimColor("#6F828A")
STONE = ManimColor("#ADA587")
STORMYBLUE = ManimColor("#507B9C")
STRAW = ManimColor("#FCF679")
STRAWBERRY = ManimColor("#FB2943")
STRONGBLUE = ManimColor("#0C06F7")
STRONGPINK = ManimColor("#FF0789")
SUNFLOWER = ManimColor("#FFC512")
SUNFLOWERYELLOW = ManimColor("#FFDA03")
SUNNYYELLOW = ManimColor("#FFF917")
SUNSHINEYELLOW = ManimColor("#FFFD37")
SUNYELLOW = ManimColor("#FFDF22")
SWAMP = ManimColor("#698339")
SWAMPGREEN = ManimColor("#748500")
TAN = ManimColor("#D1B26F")
TANBROWN = ManimColor("#AB7E4C")
TANGERINE = ManimColor("#FF9408")
TANGREEN = ManimColor("#A9BE70")
TAUPE = ManimColor("#B9A281")
TEA = ManimColor("#65AB7C")
TEAGREEN = ManimColor("#BDF8A3")
TEAL = ManimColor("#029386")
TEALBLUE = ManimColor("#01889F")
TEALGREEN = ManimColor("#25A36F")
TEALISH = ManimColor("#24BCA8")
TEALISHGREEN = ManimColor("#0CDC73")
TERRACOTA = ManimColor("#CB6843")
TERRACOTTA = ManimColor("#C9643B")
TIFFANYBLUE = ManimColor("#7BF2DA")
TOMATO = ManimColor("#EF4026")
TOMATORED = ManimColor("#EC2D01")
TOPAZ = ManimColor("#13BBAF")
TOUPE = ManimColor("#C7AC7D")
TOXICGREEN = ManimColor("#61DE2A")
TREEGREEN = ManimColor("#2A7E19")
TRUEBLUE = ManimColor("#010FCC")
TRUEGREEN = ManimColor("#089404")
TURQUOISE = ManimColor("#06C2AC")
TURQUOISEBLUE = ManimColor("#06B1C4")
TURQUOISEGREEN = ManimColor("#04F489")
TURTLEGREEN = ManimColor("#75B84F")
TWILIGHT = ManimColor("#4E518B")
TWILIGHTBLUE = ManimColor("#0A437A")
UGLYBLUE = ManimColor("#31668A")
UGLYBROWN = ManimColor("#7D7103")
UGLYGREEN = ManimColor("#7A9703")
UGLYPINK = ManimColor("#CD7584")
UGLYPURPLE = ManimColor("#A442A0")
UGLYYELLOW = ManimColor("#D0C101")
ULTRAMARINE = ManimColor("#2000B1")
ULTRAMARINEBLUE = ManimColor("#1805DB")
UMBER = ManimColor("#B26400")
VELVET = ManimColor("#750851")
VERMILION = ManimColor("#F4320C")
VERYDARKBLUE = ManimColor("#000133")
VERYDARKBROWN = ManimColor("#1D0200")
VERYDARKGREEN = ManimColor("#062E03")
VERYDARKPURPLE = ManimColor("#2A0134")
VERYLIGHTBLUE = ManimColor("#D5FFFF")
VERYLIGHTBROWN = ManimColor("#D3B683")
VERYLIGHTGREEN = ManimColor("#D1FFBD")
VERYLIGHTPINK = ManimColor("#FFF4F2")
VERYLIGHTPURPLE = ManimColor("#F6CEFC")
VERYPALEBLUE = ManimColor("#D6FFFE")
VERYPALEGREEN = ManimColor("#CFFDBC")
VIBRANTBLUE = ManimColor("#0339F8")
VIBRANTGREEN = ManimColor("#0ADD08")
VIBRANTPURPLE = ManimColor("#AD03DE")
VIOLET = ManimColor("#9A0EEA")
VIOLETBLUE = ManimColor("#510AC9")
VIOLETPINK = ManimColor("#FB5FFC")
VIOLETRED = ManimColor("#A50055")
VIRIDIAN = ManimColor("#1E9167")
VIVIDBLUE = ManimColor("#152EFF")
VIVIDGREEN = ManimColor("#2FEF10")
VIVIDPURPLE = ManimColor("#9900FA")
VOMIT = ManimColor("#A2A415")
VOMITGREEN = ManimColor("#89A203")
VOMITYELLOW = ManimColor("#C7C10C")
WARMBLUE = ManimColor("#4B57DB")
WARMBROWN = ManimColor("#964E02")
WARMGREY = ManimColor("#978A84")
WARMPINK = ManimColor("#FB5581")
WARMPURPLE = ManimColor("#952E8F")
WASHEDOUTGREEN = ManimColor("#BCF5A6")
WATERBLUE = ManimColor("#0E87CC")
WATERMELON = ManimColor("#FD4659")
WEIRDGREEN = ManimColor("#3AE57F")
WHEAT = ManimColor("#FBDD7E")
WHITE = ManimColor("#FFFFFF")
WINDOWSBLUE = ManimColor("#3778BF")
WINE = ManimColor("#80013F")
WINERED = ManimColor("#7B0323")
WINTERGREEN = ManimColor("#20F986")
WISTERIA = ManimColor("#A87DC2")
YELLOW = ManimColor("#FFFF14")
YELLOWBROWN = ManimColor("#B79400")
YELLOWGREEN = ManimColor("#BBF90F")
YELLOWISH = ManimColor("#FAEE66")
YELLOWISHBROWN = ManimColor("#9B7A01")
YELLOWISHGREEN = ManimColor("#B0DD16")
YELLOWISHORANGE = ManimColor("#FFAB0F")
YELLOWISHTAN = ManimColor("#FCFC81")
YELLOWOCHRE = ManimColor("#CB9D06")
YELLOWORANGE = ManimColor("#FCB001")
YELLOWTAN = ManimColor("#FFE36E")
YELLOWYBROWN = ManimColor("#AE8B0C")
YELLOWYGREEN = ManimColor("#BFF128")

View file

@ -0,0 +1,58 @@
"""Utilities for working with colors and predefined color constants.
Color data structure
--------------------
.. autosummary::
:toctree: ../reference
core
Predefined colors
-----------------
There are several predefined colors available in Manim:
- The colors listed in :mod:`.color.manim_colors` are loaded into
Manim's global name space.
- The colors in :mod:`.color.AS2700`, :mod:`.color.BS381`, :mod:`.color.X11`,
and :mod:`.color.XKCD` need to be accessed via their module (which are available
in Manim's global name space), or imported separately. For example:
.. code:: pycon
>>> from manim import XKCD
>>> XKCD.AVOCADO
ManimColor('#90B134')
Or, alternatively:
.. code:: pycon
>>> from manim.utils.color.XKCD import AVOCADO
>>> AVOCADO
ManimColor('#90B134')
The following modules contain the predefined color constants:
.. autosummary::
:toctree: ../reference
manim_colors
AS2700
BS381
XKCD
X11
"""
from typing import Dict, List
from . import AS2700, BS381, X11, XKCD
from .core import *
from .manim_colors import *
_all_color_dict: Dict[str, ManimColor] = {
k: v for k, v in globals().items() if isinstance(v, ManimColor)
}

998
manim/utils/color/core.py Normal file
View file

@ -0,0 +1,998 @@
"""Manim's (internal) color data structure and some utilities for
color conversion.
This module contains the implementation of :class:`.ManimColor`,
the data structure internally used to represent colors.
"""
from __future__ import annotations
# logger = _config.logger
import colorsys
import random
from typing import Any, Sequence, Union
import numpy as np
from typing_extensions import Literal, TypeAlias
from ...utils.space_ops import normalize
ManimColorDType: TypeAlias = np.float64
ManimFloat: TypeAlias = np.float64
ManimInt: TypeAlias = np.int64
RGB_Array_Float: TypeAlias = "np.ndarray[Literal[3], np.dtype[ManimFloat]]"
RGB_Tuple_Float: TypeAlias = "tuple[float, float, float]"
RGB_Array_Int: TypeAlias = "np.ndarray[Literal[3], np.dtype[ManimInt]]"
RGB_Tuple_Int: TypeAlias = "tuple[int, int, int]"
RGBA_Array_Float: TypeAlias = "np.ndarray[Literal[4], np.dtype[ManimFloat]]"
RGBA_Tuple_Float: TypeAlias = "tuple[float, float, float, float]"
RGBA_Array_Int: TypeAlias = "np.ndarray[Literal[4], np.dtype[ManimInt]]"
RGBA_Tuple_Int: TypeAlias = "tuple[int, int, int, int]"
HSV_Array_Float: TypeAlias = RGB_Array_Float
HSV_Tuple_Float: TypeAlias = RGB_Tuple_Float
ManimColorInternal: TypeAlias = "np.ndarray[Literal[4], np.dtype[ManimColorDType]]"
import re
re_hex = re.compile("((?<=#)|(?<=0x))[A-F0-9]{6,8}", re.IGNORECASE)
class ManimColor:
"""Internal representation of a color.
The ManimColor class is the main class for the representation of a color.
It's internal representation is a 4 element array of floats corresponding
to a [r,g,b,a] value where r,g,b,a can be between 0 to 1.
This is done in order to reduce the amount of color inconsitencies by constantly
casting between integers and floats which introduces errors.
The class can accept any value of type :class:`ParsableManimColor` i.e.
ManimColor, int, str, RGB_Tuple_Int, RGB_Tuple_Float, RGBA_Tuple_Int, RGBA_Tuple_Float, RGB_Array_Int,
RGB_Array_Float, RGBA_Array_Int, RGBA_Array_Float
ManimColor itself only accepts singular values and will directly interpret them into a single color if possible
Be careful when passing strings to ManimColor it can create a big overhead for the color processing.
If you want to parse a list of colors use the function :meth:`parse` in :class:`ManimColor` which assumes that
you are going to pass a list of color so arrays will not bei interpreted as a single color.
.. warning::
If you pass an array of numbers to :meth:`parse` it will interpret the r,g,b,a numbers in that array as colors
so instead of the expect singular color you get and array with 4 colors.
For conversion behaviors see the _internal functions for further documentation
Parameters
----------
value
Some representation of a color (e.g., a string or
a suitable tuple).
alpha
The opacity of the color. By default, colors are
fully opaque (value 1.0).
"""
def __init__(
self,
value: ParsableManimColor,
alpha: float = 1.0,
) -> None:
if value is None:
self._internal_value = np.array((0, 0, 0, alpha), dtype=ManimColorDType)
elif isinstance(value, ManimColor):
# logger.info(
# "ManimColor was passed another ManimColor. This is probably not what "
# "you want. Created a copy of the passed ManimColor instead."
# )
self._internal_value = value._internal_value
elif isinstance(value, int):
self._internal_value = ManimColor._internal_from_integer(value, alpha)
elif isinstance(value, str):
result = re_hex.search(value)
if result is not None:
self._internal_value = ManimColor._internal_from_hex_string(
result.group(), alpha
)
else:
# This is not expected to be called on module initialization time
# It can be horribly slow to convert a string to a color because
# it has to access the dictionary of colors and find the right color
self._internal_value = ManimColor._internal_from_string(value)
elif isinstance(value, (list, tuple, np.ndarray)):
length = len(value)
if all(isinstance(x, float) for x in value):
if length == 3:
self._internal_value = ManimColor._internal_from_rgb(value, alpha) # type: ignore
elif length == 4:
self._internal_value = ManimColor._internal_from_rgba(value) # type: ignore
else:
raise ValueError(
f"ManimColor only accepts lists/tuples/arrays of length 3 or 4, not {length}"
)
else:
if length == 3:
self._internal_value = ManimColor._internal_from_int_rgb(
value, alpha # type: ignore
)
elif length == 4:
self._internal_value = ManimColor._internal_from_int_rgba(value) # type: ignore
else:
raise ValueError(
f"ManimColor only accepts lists/tuples/arrays of length 3 or 4, not {length}"
)
elif hasattr(value, "get_hex") and callable(value.get_hex):
result = re_hex.search(value.get_hex())
if result is None:
raise ValueError(f"Failed to parse a color from {value}")
self._internal_value = ManimColor._internal_from_hex_string(
result.group(), alpha
)
else:
# logger.error(f"Invalid color value: {value}")
raise TypeError(
"ManimColor only accepts int, str, list[int, int, int], "
"list[int, int, int, int], list[float, float, float], "
f"list[float, float, float, float], not {type(value)}"
)
@property
def _internal_value(self) -> ManimColorInternal:
"""Returns the internal value of the current Manim color [r,g,b,a] float array
Returns
-------
ManimColorInternal
internal color representation
"""
return self.__value
@_internal_value.setter
def _internal_value(self, value: ManimColorInternal) -> None:
"""Overwrites the internal color value of the ManimColor object
Parameters
----------
value : ManimColorInternal
The value which will overwrite the current color
Raises
------
TypeError
Raises a TypeError if an invalid array is passed
"""
if not isinstance(value, np.ndarray):
raise TypeError("value must be a numpy array")
if value.shape[0] != 4:
raise TypeError("Array must have 4 values exactly")
self.__value: ManimColorInternal = value
@staticmethod
def _internal_from_integer(value: int, alpha: float) -> ManimColorInternal:
return np.asarray(
(
((value >> 16) & 0xFF) / 255,
((value >> 8) & 0xFF) / 255,
((value >> 0) & 0xFF) / 255,
alpha,
),
dtype=ManimColorDType,
)
# TODO: Maybe make 8 nibble hex also convertible ?
@staticmethod
def _internal_from_hex_string(hex: str, alpha: float) -> ManimColorInternal:
"""Internal function for converting a hex string into the internal representation of a ManimColor.
.. warning::
This does not accept any prefixes like # or similar in front of the hex string.
This is just intended for the raw hex part
*For internal use only*
Parameters
----------
hex : str
hex string to be parsed
alpha : float
alpha value used for the color
Returns
-------
ManimColorInternal
Internal color representation
"""
if len(hex) == 6:
hex += "00"
tmp = int(hex, 16)
return np.asarray(
(
((tmp >> 24) & 0xFF) / 255,
((tmp >> 16) & 0xFF) / 255,
((tmp >> 8) & 0xFF) / 255,
alpha,
),
dtype=ManimColorDType,
)
@staticmethod
def _internal_from_int_rgb(
rgb: RGB_Tuple_Int, alpha: float = 1.0
) -> ManimColorInternal:
"""Internal function for converting a rgb tuple of integers into the internal representation of a ManimColor.
*For internal use only*
Parameters
----------
rgb : RGB_Tuple_Int
integer rgb tuple to be parsed
alpha : float, optional
optional alpha value, by default 1.0
Returns
-------
ManimColorInternal
Internal color representation
"""
value: np.ndarray = np.asarray(rgb, dtype=ManimColorDType).copy() / 255
value.resize(4, refcheck=False)
value[3] = alpha
return value
@staticmethod
def _internal_from_rgb(
rgb: RGB_Tuple_Float, alpha: float = 1.0
) -> ManimColorInternal:
"""Internal function for converting a rgb tuple of floats into the internal representation of a ManimColor.
*For internal use only*
Parameters
----------
rgb : RGB_Tuple_Float
float rgb tuple to be parsed
alpha : float, optional
optional alpha value, by default 1.0
Returns
-------
ManimColorInternal
Internal color representation
"""
value: np.ndarray = np.asarray(rgb, dtype=ManimColorDType).copy()
value.resize(4, refcheck=False)
value[3] = alpha
return value
@staticmethod
def _internal_from_int_rgba(rgba: RGBA_Tuple_Int) -> ManimColorInternal:
"""Internal function for converting a rgba tuple of integers into the internal representation of a ManimColor.
*For internal use only*
Parameters
----------
rgba : RGBA_Tuple_Int
int rgba tuple to be parsed
Returns
-------
ManimColorInternal
Internal color representation
"""
return np.asarray(rgba, dtype=ManimColorDType) / 255
@staticmethod
def _internal_from_rgba(rgba: RGBA_Tuple_Float) -> ManimColorInternal:
"""Internal function for converting a rgba tuple of floats into the internal representation of a ManimColor.
*For internal use only*
Parameters
----------
rgba : RGBA_Tuple_Float
int rgba tuple to be parsed
Returns
-------
ManimColorInternal
Internal color representation
"""
return np.asarray(rgba, dtype=ManimColorDType)
@staticmethod
def _internal_from_string(name: str) -> ManimColorInternal:
"""Internal function for converting a string into the internal representation of a ManimColor.
This is not used for hex strings, please refer to :meth:`_internal_from_hex` for this functionality.
*For internal use only*
Parameters
----------
name : str
The color name to be parsed into a color. Refer to the different color Modules in the documentation Page to
find the corresponding Color names.
Returns
-------
ManimColorInternal
Internal color representation
Raises
------
ValueError
Raises a ValueError if the color name is not present with manim
"""
from . import _all_color_dict
upper_name = name.upper()
if upper_name in _all_color_dict:
return _all_color_dict[upper_name]._internal_value
else:
raise ValueError(f"Color {name} not found")
def to_integer(self) -> int:
"""Converts the current ManimColor into an integer
Returns
-------
int
integer representation of the color
.. warning::
This will return only the rgb part of the color
"""
return int.from_bytes(
(self._internal_value[:3] * 255).astype(int).tobytes(), "big"
)
def to_rgb(self) -> RGB_Array_Float:
"""Converts the current ManimColor into a rgb array of floats
Returns
-------
RGB_Array_Float
rgb array with 3 elements of type float
"""
return self._internal_value[:3]
def to_int_rgb(self) -> RGB_Array_Int:
"""Converts the current ManimColor into a rgb array of int
Returns
-------
RGB_Array_Int
rgb array with 3 elements of type int
"""
return (self._internal_value[:3] * 255).astype(int)
def to_rgba(self) -> RGBA_Array_Float:
"""Converts the current ManimColor into a rgba array of floats
Returns
-------
RGBA_Array_Float
rgba array with 4 elements of type float
"""
return self._internal_value
def to_int_rgba(self) -> RGBA_Array_Int:
"""Converts the current ManimColor into a rgba array of int
Returns
-------
RGBA_Array_Int
rgba array with 4 elements of type int
"""
return (self._internal_value * 255).astype(int)
def to_rgba_with_alpha(self, alpha: float) -> RGBA_Array_Float:
"""Converts the current ManimColor into a rgba array of float as :meth:`to_rgba` but you can change the alpha
value.
Parameters
----------
alpha : float
alpha value to be used in the return value
Returns
-------
RGBA_Array_Float
rgba array with 4 elements of type float
"""
return np.fromiter((*self._internal_value[:3], alpha), dtype=ManimColorDType)
def to_int_rgba_with_alpha(self, alpha: float) -> RGBA_Array_Int:
"""Converts the current ManimColor into a rgba array of integers as :meth:`to_int_rgba` but you can change the alpha
value.
Parameters
----------
alpha : float
alpha value to be used for the return value. (Will automatically be scaled from 0-1 to 0-255 so just pass 0-1)
Returns
-------
RGBA_Array_Int
rgba array with 4 elements of type int
"""
tmp = self._internal_value * 255
tmp[3] = alpha * 255
return tmp.astype(int)
def to_hex(self, with_alpha: bool = False) -> str:
"""Converts the manim color to a hexadecimal representation of the color
Parameters
----------
with_alpha : bool, optional
Changes the result from 6 to 8 values where the last 2 nibbles represent the alpha value of 0-255,
by default False
Returns
-------
str
A hex string starting with a # with either 6 or 8 nibbles depending on your input, by default 6 i.e #XXXXXX
"""
tmp = f"#{int(self._internal_value[0]*255):02X}{int(self._internal_value[1]*255):02X}{int(self._internal_value[2]*255):02X}"
if with_alpha:
tmp += f"{int(self._internal_value[3]*255):02X}"
return tmp
def to_hsv(self) -> HSV_Array_Float:
"""Converts the Manim Color to HSV array.
.. note::
Be careful this returns an array in the form `[h, s, v]` where the elements are floats.
This might be confusing because rgb can also be an array of floats so you might want to annotate the usage
of this function in your code by typing the variables with :class:`HSV_Array_Float` in order to differentiate
between rgb arrays and hsv arrays
Returns
-------
HSV_Array_Float
A hsv array containing 3 elements of type float ranging from 0 to 1
"""
return colorsys.rgb_to_hsv(*self.to_rgb())
def invert(self, with_alpha=False) -> ManimColor:
"""Returns an linearly inverted version of the color (no inplace changes)
Parameters
----------
with_alpha : bool, optional
if true the alpha value will be inverted too, by default False
.. note::
This can result in unintended behavior where objects are not displayed because their alpha
value is suddenly 0 or very low. Please keep that in mind when setting this to true
Returns
-------
ManimColor
The linearly inverted ManimColor
"""
return ManimColor(1.0 - self._internal_value, with_alpha)
def interpolate(self, other: ManimColor, alpha: float) -> ManimColor:
"""Interpolates between the current and the given ManimColor an returns the interpolated color
Parameters
----------
other : ManimColor
The other ManimColor to be used for interpolation
alpha : float
A point on the line in rgba colorspace connecting the two colors i.e. the interpolation point
0 corresponds to the current ManimColor and 1 corresponds to the other ManimColor
Returns
-------
ManimColor
The interpolated ManimColor
"""
return ManimColor(
self._internal_value * (1 - alpha) + other._internal_value * alpha
)
@classmethod
def from_rgb(
cls,
rgb: RGB_Array_Float | RGB_Tuple_Float | RGB_Array_Int | RGB_Tuple_Int,
alpha: float = 1.0,
) -> ManimColor:
"""Creates a ManimColor from an RGB Array. Automagically decides which type it is int/float
.. warning::
Please make sure that your elements are not floats if you want integers. A 5.0 will result in the input
being interpreted as if it was a float rgb array with the value 5.0 and not the integer 5
Parameters
----------
rgb : RGB_Array_Float | RGB_Tuple_Float | RGB_Array_Int | RGB_Tuple_Int
Any 3 Element Iterable
alpha : float, optional
alpha value to be used in the color, by default 1.0
Returns
-------
ManimColor
Returns the ManimColor object
"""
return cls(rgb, alpha)
@classmethod
def from_rgba(
cls, rgba: RGBA_Array_Float | RGBA_Tuple_Float | RGBA_Array_Int | RGBA_Tuple_Int
) -> ManimColor:
"""Creates a ManimColor from an RGBA Array. Automagically decides which type it is int/float
.. warning::
Please make sure that your elements are not floats if you want integers. A 5.0 will result in the input
being interpreted as if it was a float rgb array with the value 5.0 and not the integer 5
Parameters
----------
rgba : RGBA_Array_Float | RGBA_Tuple_Float | RGBA_Array_Int | RGBA_Tuple_Int
Any 4 Element Iterable
Returns
-------
ManimColor
Returns the ManimColor object
"""
return cls(rgba)
@classmethod
def from_hex(cls, hex: str, alpha: float = 1.0) -> ManimColor:
"""Creates a Manim Color from a hex string, prefixes allowed # and 0x
Parameters
----------
hex : str
The hex string to be converted (currently only supports 6 nibbles)
alpha : float, optional
alpha value to be used for the hex string, by default 1.0
Returns
-------
ManimColor
The ManimColor represented by the hex string
"""
return cls(hex, alpha)
@classmethod
def from_hsv(
cls, hsv: HSV_Array_Float | HSV_Tuple_Float, alpha: float = 1.0
) -> ManimColor:
"""Creates a ManimColor from an HSV Array
Parameters
----------
hsv : HSV_Array_Float | HSV_Tuple_Float
Any 3 Element Iterable containing floats from 0-1
alpha : float, optional
the alpha value to be used, by default 1.0
Returns
-------
ManimColor
The ManimColor with the corresponding RGB values to the HSV
"""
rgb = colorsys.hsv_to_rgb(*hsv)
return cls(rgb, alpha)
@classmethod
def parse(
cls,
color: ParsableManimColor | list[ParsableManimColor] | None,
alpha: float = 1.0,
) -> ManimColor | list[ManimColor]:
"""
Handles the parsing of a list of colors or a single color.
Parameters
----------
color
The color or list of colors to parse. Note that this function can not accept rgba tuples. It will assume that you mean list[ManimColor] and will return a list of ManimColors.
alpha
The alpha value to use if a single color is passed. or if a list of colors is passed to set the value of all colors.
Returns
-------
ManimColor
Either a list of colors or a singular color depending on the input
"""
if isinstance(color, (list, tuple)):
return [cls(c, alpha) for c in color] # type: ignore
return cls(color, alpha) # type: ignore
@staticmethod
def gradient(colors: list[ManimColor], length: int):
"""This is not implemented by now refer to :func:`color_gradient` for a working implementation for now"""
# TODO: implement proper gradient, research good implementation for this or look at 3b1b implementation
raise NotImplementedError
def __repr__(self) -> str:
return f"{self.__class__.__name__}('{self.to_hex()}')"
def __str__(self) -> str:
return f"{self.to_hex()}"
def __eq__(self, other: object) -> bool:
if not isinstance(other, ManimColor):
raise TypeError(
f"Cannot compare {self.__class__.__name__} with {other.__class__.__name__}"
)
return np.allclose(self._internal_value, other._internal_value)
def __add__(self, other: ManimColor) -> ManimColor:
return ManimColor(self._internal_value + other._internal_value)
def __sub__(self, other: ManimColor) -> ManimColor:
return ManimColor(self._internal_value - other._internal_value)
def __mul__(self, other: ManimColor) -> ManimColor:
return ManimColor(self._internal_value * other._internal_value)
def __truediv__(self, other: ManimColor) -> ManimColor:
return ManimColor(self._internal_value / other._internal_value)
def __floordiv__(self, other: ManimColor) -> ManimColor:
return ManimColor(self._internal_value // other._internal_value)
def __mod__(self, other: ManimColor) -> ManimColor:
return ManimColor(self._internal_value % other._internal_value)
def __pow__(self, other: ManimColor) -> ManimColor:
return ManimColor(self._internal_value**other._internal_value)
def __and__(self, other: ManimColor) -> ManimColor:
return ManimColor(self.to_integer() & other.to_integer())
def __or__(self, other: ManimColor) -> ManimColor:
return ManimColor(self.to_integer() | other.to_integer())
def __xor__(self, other: ManimColor) -> ManimColor:
return ManimColor(self.to_integer() ^ other.to_integer())
ParsableManimColor: TypeAlias = Union[
ManimColor,
int,
str,
RGB_Tuple_Int,
RGB_Tuple_Float,
RGBA_Tuple_Int,
RGBA_Tuple_Float,
RGB_Array_Int,
RGB_Array_Float,
RGBA_Array_Int,
RGBA_Array_Float,
]
"""ParsableManimColor is the representation for all types that are parsable to a color in manim"""
def color_to_rgb(color: ParsableManimColor) -> RGB_Array_Float:
"""Helper function for use in functional style programming refer to :meth:`to_rgb` in :class:`ManimColor`
Parameters
----------
color : ParsableManimColor
A color
Returns
-------
RGB_Array_Float
the corresponding rgb array
"""
return ManimColor(color).to_rgb()
def color_to_rgba(color: ParsableManimColor, alpha: float = 1) -> RGBA_Array_Float:
"""Helper function for use in functional style programming refer to :meth:`to_rgba_with_alpha` in :class:`ManimColor`
Parameters
----------
color : ParsableManimColor
A color
alpha : float, optional
alpha value to be used in the color, by default 1
Returns
-------
RGBA_Array_Float
the corresponding rgba array
"""
return ManimColor(color).to_rgba_with_alpha(alpha)
def color_to_int_rgb(color: ManimColor) -> RGB_Array_Int:
"""Helper function for use in functional style programming refer to :meth:`to_int_rgb` in :class:`ManimColor`
Parameters
----------
color : ManimColor
A color
Returns
-------
RGB_Array_Int
the corresponding int rgb array
"""
return ManimColor(color).to_int_rgb()
def color_to_int_rgba(color: ManimColor, alpha: float = 1.0) -> RGBA_Array_Int:
"""Helper function for use in functional style programming refer to :meth:`to_int_rgba_with_alpha` in :class:`ManimColor`
Parameters
----------
color : ManimColor
A color
alpha : float, optional
alpha value to be used in the color, by default 1.0
Returns
-------
RGBA_Array_Int
the corresponding int rgba array
"""
return ManimColor(color).to_int_rgba_with_alpha(alpha)
def rgb_to_color(rgb: RGB_Array_Float | RGB_Tuple_Float) -> ManimColor:
"""Helper function for use in functional style programming refer to :meth:`from_rgb` in :class:`ManimColor`
Parameters
----------
rgb : RGB_Array_Float | RGB_Tuple_Float
A 3 element iterable
Returns
-------
ManimColor
A ManimColor with the corresponding value
"""
return ManimColor.from_rgb(rgb)
def rgba_to_color(rgba: RGBA_Array_Float | RGBA_Tuple_Float) -> ManimColor:
"""Helper function for use in functional style programming refer to :meth:`from_rgba` in :class:`ManimColor`
Parameters
----------
rgba : RGBA_Array_Float | RGBA_Tuple_Float
A 4 element iterable
Returns
-------
ManimColor
A ManimColor with the corresponding value
"""
return ManimColor.from_rgba(rgba)
def rgb_to_hex(rgb: RGB_Array_Float | RGB_Tuple_Float) -> str:
"""Helper function for use in functional style programming refer to :meth:`from_rgb` in :class:`ManimColor`
Parameters
----------
rgb : RGB_Array_Float | RGB_Tuple_Float
A 3 element iterable
Returns
-------
str
A hex representation of the color, refer to :meth:`to_hex` in :class:`ManimColor`
"""
return ManimColor.from_rgb(rgb).to_hex()
def hex_to_rgb(hex_code: str) -> RGB_Array_Float:
"""Helper function for use in functional style programming refer to :meth:`to_hex` in :class:`ManimColor`
Parameters
----------
hex_code : str
A hex string representing a color
Returns
-------
RGB_Array_Float
RGB array representing the color
"""
return ManimColor(hex_code).to_rgb()
def invert_color(color: ManimColor) -> ManimColor:
"""Helper function for use in functional style programming refer to :meth:`invert` in :class:`ManimColor`
Parameters
----------
color : ManimColor
A ManimColor
Returns
-------
ManimColor
The linearly inverted ManimColor
"""
return color.invert()
def interpolate_arrays(
arr1: np.ndarray[Any, Any], arr2: np.ndarray[Any, Any], alpha: float
) -> np.ndarray:
"""Helper function used in Manim to fade between two objects smoothly
Parameters
----------
arr1 : np.ndarray[Any, Any]
The first array of colors
arr2 : np.ndarray[Any, Any]
The second array of colors
alpha : float
The alpha value corresponding to the interpolation point between the two inputs
Returns
-------
np.ndarray
The interpolated value of the to arrays
"""
return (1 - alpha) * arr1 + alpha * arr2
def color_gradient(
reference_colors: Sequence[ParsableManimColor],
length_of_output: int,
) -> list[ManimColor] | ManimColor:
"""Creates a list of colors interpolated between the input array of colors with a specific number of colors
Parameters
----------
reference_colors : Sequence[ParsableManimColor]
The colors to be interpolated between or spread apart
length_of_output : int
The number of colors that the output should have, ideally more than the input
Returns
-------
list[ManimColor] | ManimColor
A list of ManimColor's which has the interpolated colors
"""
if length_of_output == 0:
return ManimColor(reference_colors[0])
if len(reference_colors) == 1:
return [ManimColor(reference_colors[0])] * length_of_output
rgbs = list(map(color_to_rgb, reference_colors))
alphas = np.linspace(0, (len(rgbs) - 1), length_of_output)
floors = alphas.astype("int")
alphas_mod1 = alphas % 1
# End edge case
alphas_mod1[-1] = 1
floors[-1] = len(rgbs) - 2
return [
rgb_to_color((rgbs[i] * (1 - alpha)) + (rgbs[i + 1] * alpha))
for i, alpha in zip(floors, alphas_mod1)
]
def interpolate_color(
color1: ManimColor, color2: ManimColor, alpha: float
) -> ManimColor:
"""Standalone function to interpolate two ManimColors and get the result refer to :meth:`interpolate` in :class:`ManimColor`
Parameters
----------
color1 : ManimColor
First ManimColor
color2 : ManimColor
Second ManimColor
alpha : float
The alpha value determining the point of interpolation between the colors
Returns
-------
ManimColor
The interpolated ManimColor
"""
return color1.interpolate(color2, alpha)
def average_color(*colors: ManimColor) -> ManimColor:
"""Determines the Average color of the given parameters
Returns
-------
ManimColor
The average color of the input
"""
rgbs = np.array(list(map(color_to_rgb, colors)))
mean_rgb = np.apply_along_axis(np.mean, 0, rgbs)
return rgb_to_color(mean_rgb)
def random_bright_color() -> ManimColor:
"""Returns you a random bright color
.. warning::
This operation is very expensive please keep in mind the performance loss.
Returns
-------
ManimColor
A bright ManimColor
"""
color = random_color()
curr_rgb = color_to_rgb(color)
new_rgb = interpolate_arrays(curr_rgb, np.ones(len(curr_rgb)), 0.5)
return ManimColor(new_rgb)
def random_color() -> ManimColor:
"""Return you a random ManimColor
.. warning::
This operation is very expensive please keep in mind the performance loss.
Returns
-------
ManimColor
_description_
"""
import manim.utils.color.manim_colors as manim_colors
return random.choice(manim_colors._all_manim_colors)
def get_shaded_rgb(
rgb: np.ndarray,
point: np.ndarray,
unit_normal_vect: np.ndarray,
light_source: np.ndarray,
) -> RGBA_Array_Float:
to_sun = normalize(light_source - point)
factor = 0.5 * np.dot(unit_normal_vect, to_sun) ** 3
if factor < 0:
factor *= 0.5
result = rgb + factor
return result
__all__ = [
"ManimColor",
"ManimColorDType",
"ParsableManimColor",
"color_to_rgb",
"color_to_rgba",
"color_to_int_rgb",
"color_to_int_rgba",
"rgb_to_color",
"rgba_to_color",
"rgb_to_hex",
"hex_to_rgb",
"invert_color",
"interpolate_arrays",
"color_gradient",
"interpolate_color",
"average_color",
"random_bright_color",
"random_color",
"get_shaded_rgb",
]

View file

@ -0,0 +1,220 @@
"""Colors included in the global name space.
These colors form Manim's default color space.
.. manim:: ColorsOverview
:save_last_frame:
:hide_source:
import manim.utils.color.manim_colors as Colors
class ColorsOverview(Scene):
def construct(self):
def color_group(color):
group = VGroup(
*[
Line(ORIGIN, RIGHT * 1.5, stroke_width=35, color=getattr(Colors, name.upper()))
for name in subnames(color)
]
).arrange_submobjects(buff=0.4, direction=DOWN)
name = Text(color).scale(0.6).next_to(group, UP, buff=0.3)
if any(decender in color for decender in "gjpqy"):
name.shift(DOWN * 0.08)
group.add(name)
return group
def subnames(name):
return [name + "_" + char for char in "abcde"]
color_groups = VGroup(
*[
color_group(color)
for color in [
"blue",
"teal",
"green",
"yellow",
"gold",
"red",
"maroon",
"purple",
]
]
).arrange_submobjects(buff=0.2, aligned_edge=DOWN)
for line, char in zip(color_groups[0], "abcde"):
color_groups.add(Text(char).scale(0.6).next_to(line, LEFT, buff=0.2))
def named_lines_group(length, colors, names, text_colors, align_to_block):
lines = VGroup(
*[
Line(
ORIGIN,
RIGHT * length,
stroke_width=55,
color=getattr(Colors, color.upper()),
)
for color in colors
]
).arrange_submobjects(buff=0.6, direction=DOWN)
for line, name, color in zip(lines, names, text_colors):
line.add(Text(name, color=color).scale(0.6).move_to(line))
lines.next_to(color_groups, DOWN, buff=0.5).align_to(
color_groups[align_to_block], LEFT
)
return lines
other_colors = (
"pink",
"light_pink",
"orange",
"light_brown",
"dark_brown",
"gray_brown",
)
other_lines = named_lines_group(
3.2,
other_colors,
other_colors,
[BLACK] * 4 + [WHITE] * 2,
0,
)
gray_lines = named_lines_group(
6.6,
["white"] + subnames("gray") + ["black"],
[
"white",
"lighter_gray / gray_a",
"light_gray / gray_b",
"gray / gray_c",
"dark_gray / gray_d",
"darker_gray / gray_e",
"black",
],
[BLACK] * 3 + [WHITE] * 4,
2,
)
pure_colors = (
"pure_red",
"pure_green",
"pure_blue",
)
pure_lines = named_lines_group(
3.2,
pure_colors,
pure_colors,
[BLACK, BLACK, WHITE],
6,
)
self.add(color_groups, other_lines, gray_lines, pure_lines)
VGroup(*self.mobjects).move_to(ORIGIN)
.. automanimcolormodule:: manim.utils.color.manim_colors
"""
from typing import List
from .core import ManimColor
WHITE: ManimColor = ManimColor("#FFFFFF")
GRAY_A: ManimColor = ManimColor("#DDDDDD")
GREY_A: ManimColor = ManimColor("#DDDDDD")
GRAY_B: ManimColor = ManimColor("#BBBBBB")
GREY_B: ManimColor = ManimColor("#BBBBBB")
GRAY_C: ManimColor = ManimColor("#888888")
GREY_C: ManimColor = ManimColor("#888888")
GRAY_D: ManimColor = ManimColor("#444444")
GREY_D: ManimColor = ManimColor("#444444")
GRAY_E: ManimColor = ManimColor("#222222")
GREY_E: ManimColor = ManimColor("#222222")
BLACK: ManimColor = ManimColor("#000000")
LIGHTER_GRAY: ManimColor = ManimColor("#DDDDDD")
LIGHTER_GREY: ManimColor = ManimColor("#DDDDDD")
LIGHT_GRAY: ManimColor = ManimColor("#BBBBBB")
LIGHT_GREY: ManimColor = ManimColor("#BBBBBB")
GRAY: ManimColor = ManimColor("#888888")
GREY: ManimColor = ManimColor("#888888")
DARK_GRAY: ManimColor = ManimColor("#444444")
DARK_GREY: ManimColor = ManimColor("#444444")
DARKER_GRAY: ManimColor = ManimColor("#222222")
DARKER_GREY: ManimColor = ManimColor("#222222")
BLUE_A: ManimColor = ManimColor("#C7E9F1")
BLUE_B: ManimColor = ManimColor("#9CDCEB")
BLUE_C: ManimColor = ManimColor("#58C4DD")
BLUE_D: ManimColor = ManimColor("#29ABCA")
BLUE_E: ManimColor = ManimColor("#236B8E")
PURE_BLUE: ManimColor = ManimColor("#0000FF")
BLUE: ManimColor = ManimColor("#58C4DD")
DARK_BLUE: ManimColor = ManimColor("#236B8E")
TEAL_A: ManimColor = ManimColor("#ACEAD7")
TEAL_B: ManimColor = ManimColor("#76DDC0")
TEAL_C: ManimColor = ManimColor("#5CD0B3")
TEAL_D: ManimColor = ManimColor("#55C1A7")
TEAL_E: ManimColor = ManimColor("#49A88F")
TEAL: ManimColor = ManimColor("#5CD0B3")
GREEN_A: ManimColor = ManimColor("#C9E2AE")
GREEN_B: ManimColor = ManimColor("#A6CF8C")
GREEN_C: ManimColor = ManimColor("#83C167")
GREEN_D: ManimColor = ManimColor("#77B05D")
GREEN_E: ManimColor = ManimColor("#699C52")
PURE_GREEN: ManimColor = ManimColor("#00FF00")
GREEN: ManimColor = ManimColor("#83C167")
YELLOW_A: ManimColor = ManimColor("#FFF1B6")
YELLOW_B: ManimColor = ManimColor("#FFEA94")
YELLOW_C: ManimColor = ManimColor("#FFFF00")
YELLOW_D: ManimColor = ManimColor("#F4D345")
YELLOW_E: ManimColor = ManimColor("#E8C11C")
YELLOW: ManimColor = ManimColor("#FFFF00")
GOLD_A: ManimColor = ManimColor("#F7C797")
GOLD_B: ManimColor = ManimColor("#F9B775")
GOLD_C: ManimColor = ManimColor("#F0AC5F")
GOLD_D: ManimColor = ManimColor("#E1A158")
GOLD_E: ManimColor = ManimColor("#C78D46")
GOLD: ManimColor = ManimColor("#F0AC5F")
RED_A: ManimColor = ManimColor("#F7A1A3")
RED_B: ManimColor = ManimColor("#FF8080")
RED_C: ManimColor = ManimColor("#FC6255")
RED_D: ManimColor = ManimColor("#E65A4C")
RED_E: ManimColor = ManimColor("#CF5044")
PURE_RED: ManimColor = ManimColor("#FF0000")
RED: ManimColor = ManimColor("#FC6255")
MAROON_A: ManimColor = ManimColor("#ECABC1")
MAROON_B: ManimColor = ManimColor("#EC92AB")
MAROON_C: ManimColor = ManimColor("#C55F73")
MAROON_D: ManimColor = ManimColor("#A24D61")
MAROON_E: ManimColor = ManimColor("#94424F")
MAROON: ManimColor = ManimColor("#C55F73")
PURPLE_A: ManimColor = ManimColor("#CAA3E8")
PURPLE_B: ManimColor = ManimColor("#B189C6")
PURPLE_C: ManimColor = ManimColor("#9A72AC")
PURPLE_D: ManimColor = ManimColor("#715582")
PURPLE_E: ManimColor = ManimColor("#644172")
PURPLE: ManimColor = ManimColor("#9A72AC")
PINK: ManimColor = ManimColor("#D147BD")
LIGHT_PINK: ManimColor = ManimColor("#DC75CD")
ORANGE: ManimColor = ManimColor("#FF862F")
LIGHT_BROWN: ManimColor = ManimColor("#CD853F")
DARK_BROWN: ManimColor = ManimColor("#8B4513")
GRAY_BROWN: ManimColor = ManimColor("#736357")
GREY_BROWN: ManimColor = ManimColor("#736357")
# Colors used for Manim Community's logo and banner
LOGO_WHITE = ManimColor("#ECE7E2")
LOGO_GREEN = ManimColor("#87C2A5")
LOGO_BLUE = ManimColor("#525893")
LOGO_RED = ManimColor("#E07A5F")
LOGO_BLACK = ManimColor("#343434")
_all_manim_colors: List[ManimColor] = [
x for x in globals().values() if isinstance(x, ManimColor)
]

View file

@ -0,0 +1,92 @@
from __future__ import annotations
import inspect
from docutils import nodes
from docutils.parsers.rst import Directive
from sphinx.application import Sphinx
from manim import ManimColor
def setup(app: Sphinx) -> None:
app.add_directive("automanimcolormodule", ManimColorModuleDocumenter)
class ManimColorModuleDocumenter(Directive):
objtype = "automanimcolormodule"
required_arguments = 1
has_content = True
def add_directive_header(self, sig: str) -> None:
super().add_directive_header(sig)
def run(
self,
) -> None:
module_name = self.arguments[0]
try:
import importlib
module = importlib.import_module(module_name)
except ImportError:
return [
nodes.error(
None,
nodes.paragraph(text="Failed to import module '%s'" % module_name),
)
]
# Number of Colors displayed in one row
num_color_cols = 2
table = nodes.table(align="center")
tgroup = nodes.tgroup(cols=num_color_cols * 2)
table += tgroup
for _ in range(num_color_cols * 2):
tgroup += nodes.colspec(colwidth=1)
# Create header rows for the table
thead = nodes.thead()
row = nodes.row()
for _ in range(num_color_cols):
col1 = nodes.paragraph(text="Color Name")
col2 = nodes.paragraph(text="RGB Hex Code")
row += nodes.entry("", col1)
row += nodes.entry("", col2)
thead += row
tgroup += thead
color_elements = []
for member_name, member_obj in inspect.getmembers(module):
if isinstance(member_obj, ManimColor):
r, g, b = member_obj.to_rgb()
luminance = 0.2126 * r + 0.7152 * g + 0.0722 * b
# Choose the font color based on the background luminance
if luminance > 0.5:
font_color = "black"
else:
font_color = "white"
color_elements.append((member_name, member_obj.to_hex(), font_color))
tbody = nodes.tbody()
for base_i in range(0, len(color_elements), num_color_cols):
row = nodes.row()
for member_name, hex_code, font_color in color_elements[
base_i : base_i + num_color_cols
]:
col1 = nodes.literal(text=member_name)
col2 = nodes.raw(
"",
f'<div style="background-color:{hex_code};padding: 0.25rem 0;border-radius:8px;margin: 0.5rem 0.2rem"><code style="color:{font_color};">{hex_code}</code></div>',
format="html",
)
row += nodes.entry("", col1)
row += nodes.entry("", col2)
tbody += row
tgroup += tbody
return [table]

View file

@ -26,7 +26,7 @@ render scenes that are defined within doctests, for example::
>>> from manim import Create, Dot, RED, Scene
>>> dot = Dot(color=RED)
>>> dot.color
<Color #fc6255>
ManimColor('#FC6255')
>>> class DirectiveDoctestExample(Scene):
... def construct(self):
... self.play(Create(dot))

View file

@ -44,7 +44,6 @@ import numpy as np
from mapbox_earcut import triangulate_float32 as earcut
from scipy.spatial.transform import Rotation
from .. import config
from ..constants import DOWN, OUT, PI, RIGHT, TAU, UP, RendererType
from ..utils.iterables import adjacent_pairs
@ -69,34 +68,19 @@ def quaternion_mult(
Union[np.ndarray, List[Union[float, np.ndarray]]]
Returns a list of product of two quaternions.
"""
if config.renderer == RendererType.OPENGL:
if len(quats) == 0:
return [1, 0, 0, 0]
result = quats[0]
for next_quat in quats[1:]:
w1, x1, y1, z1 = result
w2, x2, y2, z2 = next_quat
result = [
w1 * w2 - x1 * x2 - y1 * y2 - z1 * z2,
w1 * x2 + x1 * w2 + y1 * z2 - z1 * y2,
w1 * y2 + y1 * w2 + z1 * x2 - x1 * z2,
w1 * z2 + z1 * w2 + x1 * y2 - y1 * x2,
]
return result
elif config.renderer == RendererType.CAIRO:
q1 = quats[0]
q2 = quats[1]
w1, x1, y1, z1 = q1
w2, x2, y2, z2 = q2
return np.array(
[
w1 * w2 - x1 * x2 - y1 * y2 - z1 * z2,
w1 * x2 + x1 * w2 + y1 * z2 - z1 * y2,
w1 * y2 + y1 * w2 + z1 * x2 - x1 * z2,
w1 * z2 + z1 * w2 + x1 * y2 - y1 * x2,
],
)
if len(quats) == 0:
return [1, 0, 0, 0]
result = quats[0]
for next_quat in quats[1:]:
w1, x1, y1, z1 = result
w2, x2, y2, z2 = next_quat
result = [
w1 * w2 - x1 * x2 - y1 * y2 - z1 * z2,
w1 * x2 + x1 * w2 + y1 * z2 - z1 * y2,
w1 * y2 + y1 * w2 + z1 * x2 - x1 * z2,
w1 * z2 + z1 * w2 + x1 * y2 - y1 * x2,
]
return result
def quaternion_from_angle_axis(
@ -122,12 +106,9 @@ def quaternion_from_angle_axis(
List[float]
Gives back a quaternion from the angle and axis
"""
if config.renderer == RendererType.OPENGL:
if not axis_normalized:
axis = normalize(axis)
return [math.cos(angle / 2), *(math.sin(angle / 2) * axis)]
elif config.renderer == RendererType.CAIRO:
return np.append(np.cos(angle / 2), np.sin(angle / 2) * normalize(axis))
if not axis_normalized:
axis = normalize(axis)
return [math.cos(angle / 2), *(math.sin(angle / 2) * axis)]
def angle_axis_from_quaternion(quaternion: Sequence[float]) -> Sequence[float]:

1695
poetry.lock generated

File diff suppressed because it is too large Load diff

View file

@ -29,7 +29,6 @@ packages = [
python = ">=3.8,<3.12"
click = ">=7.2,<=9.0"
click-default-group = "^1.2.2"
colour = "^0.1.5"
numpy = "^1.19"
Pillow = ">=9.1,<10.0"
scipy = "^1.7.3"

View file

@ -1,7 +1,5 @@
from __future__ import annotations
from colour import Color
from manim import *
from tests.helpers.path_utils import get_svg_resource
@ -9,21 +7,21 @@ from tests.helpers.path_utils import get_svg_resource
def test_set_fill_color():
expected_color = "#FF862F"
svg = SVGMobject(get_svg_resource("heart.svg"), fill_color=expected_color)
assert svg.fill_color == Color(expected_color)
assert svg.fill_color.to_hex() == expected_color
def test_set_stroke_color():
expected_color = "#FFFDDD"
svg = SVGMobject(get_svg_resource("heart.svg"), stroke_color=expected_color)
assert svg.stroke_color == Color(expected_color)
assert svg.stroke_color.to_hex() == expected_color
def test_set_color_sets_fill_and_stroke():
expected_color = "#EEE777"
svg = SVGMobject(get_svg_resource("heart.svg"), color=expected_color)
assert svg.color == Color(expected_color)
assert svg.fill_color == Color(expected_color)
assert svg.stroke_color == Color(expected_color)
assert svg.color.to_hex() == expected_color
assert svg.fill_color.to_hex() == expected_color
assert svg.stroke_color.to_hex() == expected_color
def test_set_fill_opacity():
@ -45,7 +43,7 @@ def test_fill_overrides_color():
color="#123123",
fill_color=expected_color,
)
assert svg.fill_color == Color(expected_color)
assert svg.fill_color.to_hex() == expected_color
def test_stroke_overrides_color():
@ -55,7 +53,7 @@ def test_stroke_overrides_color():
color="#334433",
stroke_color=expected_color,
)
assert svg.stroke_color == Color(expected_color)
assert svg.stroke_color.to_hex() == expected_color
def test_single_path_turns_into_sequence_of_points():

View file

@ -1,7 +1,5 @@
from __future__ import annotations
from colour import Color
from manim import RED, DecimalNumber, Integer
@ -44,4 +42,6 @@ def test_color_when_number_of_digits_changes():
the number of digits changes."""
mob = Integer(color=RED)
mob.set_value(42)
assert all(submob.stroke_color == Color(RED) for submob in mob.submobjects)
assert all(
submob.stroke_color.to_hex() == RED.to_hex() for submob in mob.submobjects
)

View file

@ -1,7 +1,5 @@
from __future__ import annotations
from colour import Color
from manim.mobject.text.text_mobject import MarkupText, Text
@ -13,11 +11,3 @@ def test_font_size():
assert round(text_string.font_size, 5) == 14.4
assert round(markuptext_string.font_size, 5) == 14.4
def test_non_str_color():
"""Test that the Text and MarkupText can accept non_str color values
i.e. colour.Color(red)."""
text = Text("test_color_inheritance", color=Color("blue"))
markup_text = MarkupText("test_color_inheritance", color=Color("blue"))

View file

@ -1,14 +1,12 @@
from __future__ import annotations
from colour import Color
import manim.utils.color as C
from manim import VMobject
def test_stroke_props_in_ctor():
m = VMobject(stroke_color=C.ORANGE, stroke_width=10)
assert m.stroke_color == Color(C.ORANGE)
assert m.stroke_color.to_hex() == C.ORANGE.to_hex()
assert m.stroke_width == 10
@ -17,7 +15,7 @@ def test_set_stroke():
m.set_stroke(color=C.ORANGE, width=2, opacity=0.8)
assert m.stroke_width == 2
assert m.stroke_opacity == 0.8
assert m.stroke_color == Color(C.ORANGE)
assert m.stroke_color.to_hex() == C.ORANGE.to_hex()
def test_set_background_stroke():
@ -25,4 +23,4 @@ def test_set_background_stroke():
m.set_stroke(color=C.ORANGE, width=2, opacity=0.8, background=True)
assert m.background_stroke_width == 2
assert m.background_stroke_opacity == 0.8
assert m.background_stroke_color == C.ORANGE
assert m.background_stroke_color.to_hex() == C.ORANGE.to_hex()

View file

@ -25,7 +25,7 @@ def test_background_color():
S.renderer.get_frame()[0, 0], np.array([67, 111, 128, 255])
)
S.camera.background_color = "#fff"
S.camera.background_color = "#ffffff"
S.renderer.update_frame(S)
np.testing.assert_array_equal(
S.renderer.get_frame()[0, 0], np.array([255, 255, 255, 255])
@ -35,17 +35,17 @@ def test_background_color():
S.camera.background_opacity = 0.5
S.renderer.update_frame(S)
np.testing.assert_array_equal(
S.renderer.get_frame()[0, 0], np.array([93, 127, 93, 127])
S.renderer.get_frame()[0, 0], np.array([187, 255, 187, 127])
)
def test_set_color():
m = Mobject()
assert m.color.hex == "#fff"
assert m.color.to_hex() == "#FFFFFF"
m.set_color(BLACK)
assert m.color.hex == "#000"
assert m.color.to_hex() == "#000000"
m = VMobject()
assert m.color.hex == "#fff"
assert m.color.to_hex() == "#FFFFFF"
m.set_color(BLACK)
assert m.color.hex == "#000"
assert m.color.to_hex() == "#000000"

View file

@ -0,0 +1,22 @@
from __future__ import annotations
import numpy as np
import numpy.testing as nt
from manim.utils.color import BLACK, WHITE, ManimColor, ManimColorDType
def test_init_with_int() -> None:
color = ManimColor(0x123456, 0.5)
nt.assert_array_equal(
color._internal_value,
np.array([0x12, 0x34, 0x56, 0.5 * 255], dtype=ManimColorDType) / 255,
)
color = BLACK
nt.assert_array_equal(
color._internal_value, np.array([0, 0, 0, 1.0], dtype=ManimColorDType)
)
color = WHITE
nt.assert_array_equal(
color._internal_value, np.array([1.0, 1.0, 1.0, 1.0], dtype=ManimColorDType)
)

View file

@ -1,7 +1,6 @@
from __future__ import annotations
import numpy as np
from colour import Color
from manim import BLACK, BLUE, GREEN, PURE_BLUE, PURE_GREEN, PURE_RED, Scene
from manim.mobject.opengl.opengl_mobject import OpenGLMobject
@ -16,19 +15,19 @@ def test_import_color(using_opengl_renderer):
def test_background_color(using_opengl_renderer):
S = Scene()
S.renderer.background_color = "#ff0000"
S.renderer.background_color = "#FF0000"
S.renderer.update_frame(S)
np.testing.assert_array_equal(
S.renderer.get_frame()[0, 0], np.array([255, 0, 0, 255])
)
S.renderer.background_color = "#436f80"
S.renderer.background_color = "#436F80"
S.renderer.update_frame(S)
np.testing.assert_array_equal(
S.renderer.get_frame()[0, 0], np.array([67, 111, 128, 255])
)
S.renderer.background_color = "#fff"
S.renderer.background_color = "#FFFFFF"
S.renderer.update_frame(S)
np.testing.assert_array_equal(
S.renderer.get_frame()[0, 0], np.array([255, 255, 255, 255])
@ -37,138 +36,138 @@ def test_background_color(using_opengl_renderer):
def test_set_color(using_opengl_renderer):
m = OpenGLMobject()
assert m.color.hex == "#fff"
assert m.color.to_hex() == "#FFFFFF"
np.alltrue(m.rgbas == np.array((0.0, 0.0, 0.0, 1.0)))
m.set_color(BLACK)
assert m.color.hex == "#000"
assert m.color.to_hex() == "#000000"
np.alltrue(m.rgbas == np.array((1.0, 1.0, 1.0, 1.0)))
m.set_color(PURE_GREEN, opacity=0.5)
assert m.color.hex == "#0f0"
assert m.color.to_hex() == "#00FF00"
np.alltrue(m.rgbas == np.array((0.0, 1.0, 0.0, 0.5)))
m = OpenGLVMobject()
assert m.color.hex == "#fff"
assert m.color.to_hex() == "#FFFFFF"
np.alltrue(m.fill_rgba == np.array((0.0, 0.0, 0.0, 1.0)))
np.alltrue(m.stroke_rgba == np.array((0.0, 0.0, 0.0, 1.0)))
m.set_color(BLACK)
assert m.color.hex == "#000"
assert m.color.to_hex() == "#000000"
np.alltrue(m.fill_rgba == np.array((1.0, 1.0, 1.0, 1.0)))
np.alltrue(m.stroke_rgba == np.array((1.0, 1.0, 1.0, 1.0)))
m.set_color(PURE_GREEN, opacity=0.5)
assert m.color.hex == "#0f0"
assert m.color.to_hex() == "#00FF00"
np.alltrue(m.fill_rgba == np.array((0.0, 1.0, 0.0, 0.5)))
np.alltrue(m.stroke_rgba == np.array((0.0, 1.0, 0.0, 0.5)))
def test_set_fill_color(using_opengl_renderer):
m = OpenGLVMobject()
assert m.fill_color.hex == "#fff"
assert m.fill_color.to_hex() == "#FFFFFF"
np.alltrue(m.fill_rgba == np.array((0.0, 1.0, 0.0, 0.5)))
m.set_fill(BLACK)
assert m.fill_color.hex == "#000"
assert m.fill_color.to_hex() == "#000000"
np.alltrue(m.fill_rgba == np.array((1.0, 1.0, 1.0, 1.0)))
m.set_fill(PURE_GREEN, opacity=0.5)
assert m.fill_color.hex == "#0f0"
assert m.fill_color.to_hex() == "#00FF00"
np.alltrue(m.fill_rgba == np.array((0.0, 1.0, 0.0, 0.5)))
def test_set_stroke_color(using_opengl_renderer):
m = OpenGLVMobject()
assert m.stroke_color.hex == "#fff"
assert m.stroke_color.to_hex() == "#FFFFFF"
np.alltrue(m.stroke_rgba == np.array((0.0, 1.0, 0.0, 0.5)))
m.set_stroke(BLACK)
assert m.stroke_color.hex == "#000"
assert m.stroke_color.to_hex() == "#000000"
np.alltrue(m.stroke_rgba == np.array((1.0, 1.0, 1.0, 1.0)))
m.set_stroke(PURE_GREEN, opacity=0.5)
assert m.stroke_color.hex == "#0f0"
assert m.stroke_color.to_hex() == "#00FF00"
np.alltrue(m.stroke_rgba == np.array((0.0, 1.0, 0.0, 0.5)))
def test_set_fill(using_opengl_renderer):
m = OpenGLMobject()
assert m.color.hex == "#fff"
assert m.color.to_hex() == "#FFFFFF"
m.set_color(BLACK)
assert m.color.hex == "#000"
assert m.color.to_hex() == "#000000"
m = OpenGLVMobject()
assert m.color.hex == "#fff"
assert m.color.to_hex() == "#FFFFFF"
m.set_color(BLACK)
assert m.color.hex == "#000"
assert m.color.to_hex() == "#000000"
def test_set_color_handles_lists_of_strs(using_opengl_renderer):
m = OpenGLVMobject()
assert m.color.hex == "#fff"
assert m.color.to_hex() == "#FFFFFF"
m.set_color([BLACK, BLUE, GREEN])
assert m.get_colors()[0] == Color(BLACK)
assert m.get_colors()[1] == Color(BLUE)
assert m.get_colors()[2] == Color(GREEN)
assert m.get_colors()[0] == BLACK
assert m.get_colors()[1] == BLUE
assert m.get_colors()[2] == GREEN
assert m.get_fill_colors()[0] == Color(BLACK)
assert m.get_fill_colors()[1] == Color(BLUE)
assert m.get_fill_colors()[2] == Color(GREEN)
assert m.get_fill_colors()[0] == BLACK
assert m.get_fill_colors()[1] == BLUE
assert m.get_fill_colors()[2] == GREEN
assert m.get_stroke_colors()[0] == Color(BLACK)
assert m.get_stroke_colors()[1] == Color(BLUE)
assert m.get_stroke_colors()[2] == Color(GREEN)
assert m.get_stroke_colors()[0] == BLACK
assert m.get_stroke_colors()[1] == BLUE
assert m.get_stroke_colors()[2] == GREEN
def test_set_color_handles_lists_of_color_objects(using_opengl_renderer):
m = OpenGLVMobject()
assert m.color.hex == "#fff"
m.set_color([Color(PURE_BLUE), Color(PURE_GREEN), Color(PURE_RED)])
assert m.get_colors()[0].hex == "#00f"
assert m.get_colors()[1].hex == "#0f0"
assert m.get_colors()[2].hex == "#f00"
assert m.color.to_hex() == "#FFFFFF"
m.set_color([PURE_BLUE, PURE_GREEN, PURE_RED])
assert m.get_colors()[0].to_hex() == "#0000FF"
assert m.get_colors()[1].to_hex() == "#00FF00"
assert m.get_colors()[2].to_hex() == "#FF0000"
assert m.get_fill_colors()[0].hex == "#00f"
assert m.get_fill_colors()[1].hex == "#0f0"
assert m.get_fill_colors()[2].hex == "#f00"
assert m.get_fill_colors()[0].to_hex() == "#0000FF"
assert m.get_fill_colors()[1].to_hex() == "#00FF00"
assert m.get_fill_colors()[2].to_hex() == "#FF0000"
assert m.get_stroke_colors()[0].hex == "#00f"
assert m.get_stroke_colors()[1].hex == "#0f0"
assert m.get_stroke_colors()[2].hex == "#f00"
assert m.get_stroke_colors()[0].to_hex() == "#0000FF"
assert m.get_stroke_colors()[1].to_hex() == "#00FF00"
assert m.get_stroke_colors()[2].to_hex() == "#FF0000"
def test_set_fill_handles_lists_of_strs(using_opengl_renderer):
m = OpenGLVMobject()
assert m.fill_color.hex == "#fff"
m.set_fill([BLACK, BLUE, GREEN])
assert m.get_fill_colors()[0] == Color(BLACK)
assert m.get_fill_colors()[1] == Color(BLUE)
assert m.get_fill_colors()[2] == Color(GREEN)
assert m.fill_color.to_hex() == "#FFFFFF"
m.set_fill([BLACK.to_hex(), BLUE.to_hex(), GREEN.to_hex()])
assert m.get_fill_colors()[0].to_hex() == BLACK.to_hex()
assert m.get_fill_colors()[1].to_hex() == BLUE.to_hex()
assert m.get_fill_colors()[2].to_hex() == GREEN.to_hex()
def test_set_fill_handles_lists_of_color_objects(using_opengl_renderer):
m = OpenGLVMobject()
assert m.fill_color.hex == "#fff"
m.set_fill([Color(PURE_BLUE), Color(PURE_GREEN), Color(PURE_RED)])
assert m.get_fill_colors()[0].hex == "#00f"
assert m.get_fill_colors()[1].hex == "#0f0"
assert m.get_fill_colors()[2].hex == "#f00"
assert m.fill_color.to_hex() == "#FFFFFF"
m.set_fill([PURE_BLUE, PURE_GREEN, PURE_RED])
assert m.get_fill_colors()[0].to_hex() == "#0000FF"
assert m.get_fill_colors()[1].to_hex() == "#00FF00"
assert m.get_fill_colors()[2].to_hex() == "#FF0000"
def test_set_stroke_handles_lists_of_strs(using_opengl_renderer):
m = OpenGLVMobject()
assert m.stroke_color.hex == "#fff"
m.set_stroke([BLACK, BLUE, GREEN])
assert m.get_stroke_colors()[0] == Color(BLACK)
assert m.get_stroke_colors()[1] == Color(BLUE)
assert m.get_stroke_colors()[2] == Color(GREEN)
assert m.stroke_color.to_hex() == "#FFFFFF"
m.set_stroke([BLACK.to_hex(), BLUE.to_hex(), GREEN.to_hex()])
assert m.get_stroke_colors()[0].to_hex() == BLACK.to_hex()
assert m.get_stroke_colors()[1].to_hex() == BLUE.to_hex()
assert m.get_stroke_colors()[2].to_hex() == GREEN.to_hex()
def test_set_stroke_handles_lists_of_color_objects(using_opengl_renderer):
m = OpenGLVMobject()
assert m.stroke_color.hex == "#fff"
m.set_stroke([Color(PURE_BLUE), Color(PURE_GREEN), Color(PURE_RED)])
assert m.get_stroke_colors()[0].hex == "#00f"
assert m.get_stroke_colors()[1].hex == "#0f0"
assert m.get_stroke_colors()[2].hex == "#f00"
assert m.stroke_color.to_hex() == "#FFFFFF"
m.set_stroke([PURE_BLUE, PURE_GREEN, PURE_RED])
assert m.get_stroke_colors()[0].to_hex() == "#0000FF"
assert m.get_stroke_colors()[1].to_hex() == "#00FF00"
assert m.get_stroke_colors()[2].to_hex() == "#FF0000"

View file

@ -1,14 +1,12 @@
from __future__ import annotations
from colour import Color
import manim.utils.color as C
from manim.mobject.opengl.opengl_vectorized_mobject import OpenGLVMobject
def test_stroke_props_in_ctor(using_opengl_renderer):
m = OpenGLVMobject(stroke_color=C.ORANGE, stroke_width=10)
assert m.stroke_color == Color(C.ORANGE)
assert m.stroke_color.to_hex() == C.ORANGE.to_hex()
assert m.stroke_width == 10
@ -17,4 +15,4 @@ def test_set_stroke(using_opengl_renderer):
m.set_stroke(color=C.ORANGE, width=2, opacity=0.8)
assert m.stroke_width == 2
assert m.stroke_opacity == 0.8
assert m.stroke_color == Color(C.ORANGE)
assert m.stroke_color.to_hex() == C.ORANGE.to_hex()

View file

@ -1,7 +1,5 @@
from __future__ import annotations
from colour import Color
from manim import *
from tests.helpers.path_utils import get_svg_resource
@ -9,21 +7,21 @@ from tests.helpers.path_utils import get_svg_resource
def test_set_fill_color(using_opengl_renderer):
expected_color = "#FF862F"
svg = SVGMobject(get_svg_resource("heart.svg"), fill_color=expected_color)
assert svg.fill_color == Color(expected_color)
assert svg.fill_color.to_hex() == expected_color
def test_set_stroke_color(using_opengl_renderer):
expected_color = "#FFFDDD"
svg = SVGMobject(get_svg_resource("heart.svg"), stroke_color=expected_color)
assert svg.stroke_color == Color(expected_color)
assert svg.stroke_color.to_hex() == expected_color
def test_set_color_sets_fill_and_stroke(using_opengl_renderer):
expected_color = "#EEE777"
svg = SVGMobject(get_svg_resource("heart.svg"), color=expected_color)
assert svg.color == Color(expected_color)
assert svg.fill_color == Color(expected_color)
assert svg.stroke_color == Color(expected_color)
assert svg.color.to_hex() == expected_color
assert svg.fill_color.to_hex() == expected_color
assert svg.stroke_color.to_hex() == expected_color
def test_set_fill_opacity(using_opengl_renderer):
@ -45,7 +43,7 @@ def test_fill_overrides_color(using_opengl_renderer):
color="#123123",
fill_color=expected_color,
)
assert svg.fill_color == Color(expected_color)
assert svg.fill_color.to_hex() == expected_color
def test_stroke_overrides_color(using_opengl_renderer):
@ -55,4 +53,4 @@ def test_stroke_overrides_color(using_opengl_renderer):
color="#334433",
stroke_color=expected_color,
)
assert svg.stroke_color == Color(expected_color)
assert svg.stroke_color.to_hex() == expected_color

View file

@ -1,5 +1,4 @@
import pytest
from colour import Color
from manim import RED, MarkupText, Text, VGroup, VMobject
@ -14,9 +13,11 @@ def test_Text2Color():
disable_ligatures=True,
)
assert len(txt.submobjects) == 29
assert all(char.fill_color == Color("#ffffff") for char in txt[:4]) # "this"
assert all(char.fill_color == Color(RED) for char in txt[-7:-1]) # "spaces"
assert txt[-1].fill_color == Color("#ffffff") # "!"
assert all(char.fill_color.to_hex() == "#FFFFFF" for char in txt[:4]) # "this"
assert all(
char.fill_color.to_hex() == RED.to_hex() for char in txt[-7:-1]
) # "spaces"
assert txt[-1].fill_color.to_hex() == "#FFFFFF" # "!"
def test_text_color_inheritance():
@ -27,8 +28,8 @@ def test_text_color_inheritance():
text = Text("test_color_inheritance", font="Sans")
markup_text = MarkupText("test_color_inheritance", font="Sans")
assert all(char.fill_color == Color(RED) for char in text)
assert all(char.fill_color == Color(RED) for char in markup_text)
assert all(char.fill_color.to_hex() == RED.to_hex() for char in text)
assert all(char.fill_color.to_hex() == RED.to_hex() for char in markup_text)
# reset the default color so that future tests aren't affected by this change.
VMobject.set_default()