Skip to content

Remove the old COLOR_MAP and replace with an Enum #342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/source/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ List of Modules

_config
constants
~utils.color
container


Expand Down
9 changes: 5 additions & 4 deletions manim/animation/indication.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from ..mobject.shape_matchers import SurroundingRectangle
from ..mobject.types.vectorized_mobject import VGroup
from ..mobject.geometry import Line
from ..utils import color as C
from ..utils.bezier import interpolate
from ..utils.config_ops import digest_config
from ..utils.rate_functions import there_and_back
Expand All @@ -25,7 +26,7 @@
class FocusOn(Transform):
CONFIG = {
"opacity": 0.2,
"color": GREY,
"color": C.GREY,
"run_time": 2,
"remover": True,
}
Expand Down Expand Up @@ -55,7 +56,7 @@ class Indicate(Transform):
CONFIG = {
"rate_func": there_and_back,
"scale_factor": 1.2,
"color": YELLOW,
"color": C.YELLOW,
}

def create_target(self):
Expand All @@ -74,7 +75,7 @@ class Flash(AnimationGroup):
"run_time": 1,
}

def __init__(self, point, color=YELLOW, **kwargs):
def __init__(self, point, color=C.YELLOW, **kwargs):
self.point = point
self.color = color
digest_config(self, kwargs)
Expand Down Expand Up @@ -104,7 +105,7 @@ class CircleIndicate(Indicate):
CONFIG = {
"rate_func": there_and_back,
"remover": True,
"circle_config": {"color": YELLOW,},
"circle_config": {"color": C.YELLOW,},
}

def __init__(self, mobject, **kwargs):
Expand Down
9 changes: 5 additions & 4 deletions manim/animation/specialized.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
from ..animation.composition import LaggedStart
from ..animation.transform import ApplyMethod
from ..animation.transform import Restore
from ..constants import WHITE
from ..constants import BLACK
from ..mobject.geometry import Circle
from ..mobject.svg.drawings import Car
from ..mobject.types.vectorized_mobject import VGroup
from ..utils import color as C
from ..utils.config_ops import digest_config
from ..utils.space_ops import get_norm

Expand Down Expand Up @@ -53,7 +52,7 @@ class Broadcast(LaggedStart):
"big_radius": 5,
"n_circles": 5,
"start_stroke_width": 8,
"color": WHITE,
"color": C.WHITE,
"remover": True,
"lag_ratio": 0.2,
"run_time": 3,
Expand All @@ -64,7 +63,9 @@ def __init__(self, focal_point, **kwargs):
digest_config(self, kwargs)
circles = VGroup()
for x in range(self.n_circles):
circle = Circle(radius=self.big_radius, stroke_color=BLACK, stroke_width=0,)
circle = Circle(
radius=self.big_radius, stroke_color=C.BLACK, stroke_width=0,
)
circle.add_updater(lambda c: c.move_to(focal_point))
circle.save_state()
circle.set_width(self.small_radius * 2)
Expand Down
3 changes: 2 additions & 1 deletion manim/camera/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from ..mobject.mobject import Mobject
from ..mobject.types.point_cloud_mobject import PMobject
from ..mobject.types.vectorized_mobject import VMobject
from ..utils import color as C
from ..utils.color import color_to_int_rgba
from ..utils.config_ops import digest_config
from ..utils.images import get_full_raster_image_path
Expand Down Expand Up @@ -52,7 +53,7 @@ class Camera(object):
"frame_height": config["frame_height"],
"frame_width": config["frame_width"],
"frame_center": ORIGIN,
"background_color": BLACK,
"background_color": C.BLACK,
"background_opacity": 1,
# Points in vectorized mobjects with norm greater
# than this value will be rescaled.
Expand Down
5 changes: 3 additions & 2 deletions manim/camera/moving_camera.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from ..camera.camera import Camera
from ..config import config
from ..constants import ORIGIN, WHITE
from ..constants import ORIGIN
from ..mobject.frame import ScreenRectangle
from ..mobject.types.vectorized_mobject import VGroup
from ..utils import color as C
from ..utils.config_ops import digest_config


Expand All @@ -25,7 +26,7 @@ class MovingCamera(Camera):

CONFIG = {
"fixed_dimension": 0, # width
"default_frame_stroke_color": WHITE,
"default_frame_stroke_color": C.WHITE,
"default_frame_stroke_width": 0,
}

Expand Down
77 changes: 3 additions & 74 deletions manim/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,80 +108,6 @@ class MyText(Text):

# ffmpeg stuff
FFMPEG_BIN = "ffmpeg"

# gif stuff
GIF_FILE_EXTENSION = ".gif"

# Colors
COLOR_MAP = {
"DARK_BLUE": "#236B8E",
"DARK_BROWN": "#8B4513",
"LIGHT_BROWN": "#CD853F",
"BLUE_E": "#1C758A",
"BLUE_D": "#29ABCA",
"BLUE_C": "#58C4DD",
"BLUE_B": "#9CDCEB",
"BLUE_A": "#C7E9F1",
"TEAL_E": "#49A88F",
"TEAL_D": "#55C1A7",
"TEAL_C": "#5CD0B3",
"TEAL_B": "#76DDC0",
"TEAL_A": "#ACEAD7",
"GREEN_E": "#699C52",
"GREEN_D": "#77B05D",
"GREEN_C": "#83C167",
"GREEN_B": "#A6CF8C",
"GREEN_A": "#C9E2AE",
"YELLOW_E": "#E8C11C",
"YELLOW_D": "#F4D345",
"YELLOW_C": "#FFFF00",
"YELLOW_B": "#FFEA94",
"YELLOW_A": "#FFF1B6",
"GOLD_E": "#C78D46",
"GOLD_D": "#E1A158",
"GOLD_C": "#F0AC5F",
"GOLD_B": "#F9B775",
"GOLD_A": "#F7C797",
"RED_E": "#CF5044",
"RED_D": "#E65A4C",
"RED_C": "#FC6255",
"RED_B": "#FF8080",
"RED_A": "#F7A1A3",
"MAROON_E": "#94424F",
"MAROON_D": "#A24D61",
"MAROON_C": "#C55F73",
"MAROON_B": "#EC92AB",
"MAROON_A": "#ECABC1",
"PURPLE_E": "#644172",
"PURPLE_D": "#715582",
"PURPLE_C": "#9A72AC",
"PURPLE_B": "#B189C6",
"PURPLE_A": "#CAA3E8",
"WHITE": "#FFFFFF",
"BLACK": "#000000",
"LIGHT_GRAY": "#BBBBBB",
"LIGHT_GREY": "#BBBBBB",
"GRAY": "#888888",
"GREY": "#888888",
"DARK_GREY": "#444444",
"DARK_GRAY": "#444444",
"DARKER_GREY": "#222222",
"DARKER_GRAY": "#222222",
"GREY_BROWN": "#736357",
"PINK": "#D147BD",
"LIGHT_PINK": "#DC75CD",
"GREEN_SCREEN": "#00FF00",
"ORANGE": "#FF862F",
}
COLOR_MAP.update(
{
name.replace("_C", ""): COLOR_MAP[name]
for name in COLOR_MAP
if name.endswith("_C")
}
)
PALETTE = list(COLOR_MAP.values())
locals().update(COLOR_MAP)
FFMPEG_VERBOSITY_MAP = {
"DEBUG": "error",
"INFO": "error",
Expand All @@ -190,3 +116,6 @@ class MyText(Text):
"CRITICAL": "fatal",
}
VERBOSITY_CHOICES = FFMPEG_VERBOSITY_MAP.keys()

# gif stuff
GIF_FILE_EXTENSION = ".gif"
11 changes: 8 additions & 3 deletions manim/mobject/changing.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
from ..constants import *
from ..mobject.types.vectorized_mobject import VMobject
from ..mobject.types.vectorized_mobject import VGroup
from ..utils import color as C
from ..utils.rate_functions import smooth
from ..utils.space_ops import get_norm


class AnimatedBoundary(VGroup):
CONFIG = {
"colors": [BLUE_D, BLUE_B, BLUE_E, GREY_BROWN],
"colors": [
C.BLUE_D,
C.BLUE_B,
C.BLUE_E,
C.GREY_BROWN,
],
"max_stroke_width": 3,
"cycle_rate": 0.5,
"back_and_forth": True,
Expand Down Expand Up @@ -64,7 +69,7 @@ def full_family_become_partial(self, mob1, mob2, a, b):
class TracedPath(VMobject):
CONFIG = {
"stroke_width": 2,
"stroke_color": WHITE,
"stroke_color": C.WHITE,
"min_distance_to_new_point": 0.1,
}

Expand Down
17 changes: 9 additions & 8 deletions manim/mobject/coordinate_systems.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from ..mobject.number_line import NumberLine
from ..mobject.svg.tex_mobject import TexMobject
from ..mobject.types.vectorized_mobject import VGroup
from ..utils import color as C
from ..utils.config_ops import digest_config
from ..utils.config_ops import merge_dicts_recursively
from ..utils.simple_functions import binary_search
Expand Down Expand Up @@ -122,7 +123,7 @@ def input_to_graph_point(self, x, graph):
class Axes(VGroup, CoordinateSystem):
CONFIG = {
"axis_config": {
"color": LIGHT_GREY,
"color": C.LIGHT_GREY,
"include_tip": True,
"exclude_zero_from_default_numbers": True,
},
Expand Down Expand Up @@ -234,7 +235,7 @@ def make_func(axis):
class NumberPlane(Axes):
CONFIG = {
"axis_config": {
"stroke_color": WHITE,
"stroke_color": C.WHITE,
"stroke_width": 2,
"include_ticks": False,
"include_tip": False,
Expand All @@ -244,7 +245,7 @@ class NumberPlane(Axes):
},
"y_axis_config": {"label_direction": DR,},
"background_line_style": {
"stroke_color": BLUE_D,
"stroke_color": C.BLUE_D,
"stroke_width": 2,
"stroke_opacity": 1,
},
Expand Down Expand Up @@ -280,7 +281,7 @@ def init_background_lines(self):

def get_lines(self):
"""Generate all the lines, faded and not faded. Two sets of lines are generated: one parallel to the X-axis, and parallel to the Y-axis.

Returns
-------
Tuple[:class:`~.VGroup`, :class:`~.VGroup`]
Expand Down Expand Up @@ -313,17 +314,17 @@ def get_lines_parallel_to_axis(

axis_perpendicular_to : :class:`~.Line`
The axis with which the lines will be perpendicular.

ratio_faded_lines : :class:`float`
The number of faded lines between each non-faded line.
The number of faded lines between each non-faded line.

freq : :class:`float`
Frequency of non-faded lines (number of non-faded lines per graph unit).

Returns
-------
Tuple[:class:`~.VGroup`, :class:`~.VGroup`]
The first (i.e the non-faded lines parallel to `axis_parallel_to`) and second (i.e the faded lines parallel to `axis_parallel_to`) sets of lines, respectively.
The first (i.e the non-faded lines parallel to `axis_parallel_to`) and second (i.e the faded lines parallel to `axis_parallel_to`) sets of lines, respectively.
"""
line = Line(axis_parallel_to.get_start(), axis_parallel_to.get_end())
dense_freq = ratio_faded_lines
Expand Down Expand Up @@ -373,7 +374,7 @@ def prepare_for_nonlinear_transform(self, num_inserted_curves=50):

class ComplexPlane(NumberPlane):
CONFIG = {
"color": BLUE,
"color": C.BLUE,
"line_frequency": 1,
}

Expand Down
4 changes: 2 additions & 2 deletions manim/mobject/frame.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from ..constants import *
from ..config import config
from ..mobject.geometry import Rectangle
from ..utils.config_ops import digest_config
from ..utils import color as C


class ScreenRectangle(Rectangle):
Expand All @@ -21,7 +21,7 @@ class FullScreenRectangle(ScreenRectangle):
class FullScreenFadeRectangle(FullScreenRectangle):
CONFIG = {
"stroke_width": 0,
"fill_color": BLACK,
"fill_color": C.BLACK,
"fill_opacity": 0.7,
}

Expand Down
3 changes: 2 additions & 1 deletion manim/mobject/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from ..config import config
from ..mobject.types.vectorized_mobject import VMobject
from ..utils.config_ops import digest_config
from ..utils import color as C
import math


Expand Down Expand Up @@ -76,7 +77,7 @@ def generate_points(self):

class FunctionGraph(ParametricFunction):
CONFIG = {
"color": YELLOW,
"color": C.YELLOW,
"x_min": -config["frame_x_radius"],
"x_max": config["frame_x_radius"],
}
Expand Down
Loading