Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
bd4d123
first draft of color class + starting library conversion
MrDiver Nov 13, 2022
01e28fd
Merge branch 'main' into color_fix
MrDiver Nov 13, 2022
a0e85af
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 13, 2022
8af3f81
Merge branch 'main' into color_fix
MrDiver Nov 19, 2022
332d327
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 19, 2022
da0806a
changed everything to Manim color todo: figure out circular dependenc…
MrDiver Nov 19, 2022
73ffb51
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 19, 2022
157c504
first working draft of new color version
MrDiver Dec 10, 2022
a7e4a3e
Merge branch 'main' into color_fix
MrDiver Dec 10, 2022
d21583d
resolving conflicts
MrDiver Dec 11, 2022
074345e
resolving conflicts
MrDiver Dec 11, 2022
128b8ab
resolving conflicts
MrDiver Dec 11, 2022
31bcdac
resolving conflicts
MrDiver Dec 11, 2022
27c0ddb
resolving conflicts
MrDiver Dec 11, 2022
195512a
changed default internal value of ManimColor to np.ndarray[float]
MrDiver Dec 16, 2022
9823616
starting to fix tests
MrDiver Dec 16, 2022
e638643
fixed more tests and changed precision of manim color
MrDiver Dec 17, 2022
7867aa3
removed premature color conversion
MrDiver Dec 17, 2022
a12507a
fixed some more tests
MrDiver Dec 17, 2022
15c4998
final test changes
MrDiver Dec 17, 2022
76d7cda
fix doctests
MrDiver Dec 17, 2022
a27aff4
fix for 3.8
MrDiver Dec 17, 2022
1580c82
fixing ManimColor string representation
MrDiver Dec 17, 2022
b2cc282
removing some unneccesary conversions
MrDiver Dec 17, 2022
2baeff5
moved community constants to manim_colors.py and added more color sta…
MrDiver Dec 22, 2022
86c5d07
Merge branch 'main' into color_fix
MrDiver Dec 22, 2022
d1bc9fc
Merge branch 'experimental' into color_fix
MrDiver Jan 3, 2023
bd32291
broke some too long lines
behackl Mar 29, 2023
9dd9ba2
added fallback: check whether passed object has get_hex method
behackl Mar 29, 2023
d9c1d6f
actually fix _internal_from_string
behackl Mar 29, 2023
6499b86
added hsv support
behackl Mar 29, 2023
695373b
Merge remote-tracking branch 'origin/main' into color_fix
behackl Mar 29, 2023
bbef400
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 29, 2023
d32f0d5
remove dependency on colour
behackl Mar 29, 2023
f0297e6
fixed DARK_EARTH being assigned twice
behackl Mar 29, 2023
3eeeaf2
fixed double assignment
behackl Mar 29, 2023
b265091
remove more duplicated colour names
behackl Mar 29, 2023
f7db270
raise NotImplementedError for ManimColor.gradient
behackl Mar 29, 2023
2befc10
removed unused import
behackl Mar 29, 2023
d18a8dc
Merge branch 'color_fix' of github.com:MrDiver/manim into color_fix
behackl Mar 29, 2023
7a99a46
remove superfluous ManimColor import
behackl May 1, 2023
5bb6369
fix circular import, remove dependency of space_ops on config
behackl May 1, 2023
d4ffe5c
one more Color -> ParseableManimColor
behackl May 1, 2023
9085d79
removed one *-import
behackl May 1, 2023
03cdd78
somewhat unrelated fixed type hint
behackl May 1, 2023
5b990ca
-1 *-import
behackl May 1, 2023
c9f3311
fixed change of logic in CoordinateSystem.get_graph_label
behackl May 1, 2023
b144852
removed debug print; fixed type hint in mobject.py
behackl May 1, 2023
ed9de63
some fixes and improvements to text_mobject.py
behackl May 1, 2023
4099acd
update three_dimensions
behackl May 1, 2023
bd040e6
fixes for rendered documentation of utils.color.*
behackl May 1, 2023
77a2950
substantial improvements to documentation, including new Sphinx direc…
behackl May 1, 2023
9d97821
Rewrite of the sphinx directive to use docutils nodes and 2 column de…
MrDiver May 2, 2023
fe6d1c9
I just had to do it
MrDiver May 2, 2023
d8dfdb2
Improve the color table
naveen521kk May 2, 2023
9880f59
minor cleanup
behackl May 2, 2023
771113e
fixed ColorOverview example
behackl May 2, 2023
56ba61a
documentation improvements
behackl May 2, 2023
1e6be03
Merge remote-tracking branch 'origin/main' into color_fix
behackl May 2, 2023
3c1ca10
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 2, 2023
322249a
merge fix
MrDiver Jul 31, 2023
3282c75
Update manim/mobject/mobject.py
MrDiver Jul 31, 2023
884846e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 31, 2023
e1c8419
fix flake8 errors
behackl Jul 31, 2023
025cd3a
Removed test in test_text_mobject
MrDiver Aug 3, 2023
7b599f2
Improved Documentation of core.py and added private members in sphinx…
MrDiver Aug 4, 2023
1c6899f
Merge branch 'main' of github.com:ManimCommunity/manim into color_fix
MrDiver Aug 4, 2023
4388cce
Change color types of labeled.py
MrDiver Aug 4, 2023
f41bef3
removed some unused imports
behackl Aug 8, 2023
c3e7b99
turned docstring into comment
behackl Aug 8, 2023
112470d
_colors -> _all_manim_colors; move to manim_color module
behackl Aug 8, 2023
38d3c3f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 8, 2023
3576be6
fixed typing
behackl Aug 8, 2023
7da5946
rewrite import
behackl Aug 8, 2023
6651ab9
Merge branch 'main' into color_fix
MrDiver Aug 8, 2023
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
3 changes: 3 additions & 0 deletions .mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions docs/source/_templates/autosummary/class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Qualified name: ``{{ fullname | escape }}``
.. autoclass:: {{ objname }}
:show-inheritance:
:members:
:private-members:


{% block methods %}
{%- if methods %}
Expand Down
1 change: 1 addition & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"sphinx.ext.viewcode",
"sphinxext.opengraph",
"manim.utils.docbuild.manim_directive",
"manim.utils.docbuild.autocolor_directive",
"sphinx.ext.graphviz",
"sphinx.ext.inheritance_diagram",
"sphinxcontrib.programoutput",
Expand Down
4 changes: 2 additions & 2 deletions manim/_config/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
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

Expand Down Expand Up @@ -1096,7 +1096,7 @@ def format(self, val: str) -> None:

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).",
)

Expand Down
13 changes: 9 additions & 4 deletions manim/animation/changing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@

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


Expand Down Expand Up @@ -140,7 +145,7 @@ def __init__(
self,
traced_point_func: Callable,
stroke_width: float = 2,
stroke_color: Color = WHITE,
stroke_color: ParsableManimColor | None = WHITE,
dissipating_time: float | None = None,
**kwargs,
):
Expand Down
4 changes: 2 additions & 2 deletions manim/animation/creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ def construct(self):
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
Expand Down Expand Up @@ -259,7 +259,7 @@ def get_outline(self) -> Mobject:
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:
Expand Down
5 changes: 2 additions & 3 deletions manim/animation/indication.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def construct(self):
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
Expand All @@ -58,7 +57,7 @@ def construct(self):
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
Expand Down Expand Up @@ -609,7 +608,7 @@ def __init__(
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
Expand Down
15 changes: 11 additions & 4 deletions manim/camera/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
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
Expand Down Expand Up @@ -75,6 +75,8 @@ def __init__(
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
Expand Down Expand Up @@ -106,9 +108,14 @@ def __init__(
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
Expand Down
9 changes: 0 additions & 9 deletions manim/communitycolors.py

This file was deleted.

5 changes: 2 additions & 3 deletions manim/mobject/geometry/arc.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def construct(self):
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
Expand Down Expand Up @@ -492,7 +491,7 @@ def construct(self):
def __init__(
self,
radius: float | None = None,
color: Color | str = RED,
color: ParsableManimColor = RED,
**kwargs,
):
super().__init__(
Expand Down Expand Up @@ -658,7 +657,7 @@ def __init__(
radius: float = DEFAULT_DOT_RADIUS,
stroke_width: float = 0,
fill_opacity: float = 1.0,
color: Color | str = WHITE,
color: ParsableManimColor = WHITE,
**kwargs,
):
super().__init__(
Expand Down
16 changes: 9 additions & 7 deletions manim/mobject/geometry/labeled.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
)
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):
Expand All @@ -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.
Expand Down Expand Up @@ -65,13 +65,15 @@ def __init__(
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

Expand Down Expand Up @@ -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.
Expand Down
6 changes: 2 additions & 4 deletions manim/mobject/geometry/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from typing import Any, Sequence

import numpy as np
from colour import Color

from manim import config
from manim.constants import *
Expand All @@ -28,7 +27,6 @@
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


Expand Down Expand Up @@ -647,7 +645,7 @@ def coordinate_label(
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.
Expand Down Expand Up @@ -879,7 +877,7 @@ def __init__(
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,
):
Expand Down
3 changes: 1 addition & 2 deletions manim/mobject/geometry/polygram.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from typing import Iterable, Sequence

import numpy as np
from colour import Color

from manim.constants import *
from manim.mobject.geometry.arc import ArcBetweenPoints
Expand Down Expand Up @@ -597,7 +596,7 @@ def construct(self):

def __init__(
self,
color: Color = WHITE,
color: ParsableManimColor = WHITE,
height: float = 2.0,
width: float = 4.0,
grid_xstep: float | None = None,
Expand Down
8 changes: 4 additions & 4 deletions manim/mobject/geometry/shape_matchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
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):
Expand Down Expand Up @@ -79,7 +79,7 @@ def construct(self):
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,
Expand Down Expand Up @@ -121,7 +121,7 @@ def set_style(self, fill_opacity, **kwargs):
return self

def get_fill_color(self):
return Color(self.color)
return self.color


class Cross(VGroup):
Expand Down Expand Up @@ -152,7 +152,7 @@ def construct(self):
def __init__(
self,
mobject: Mobject | None = None,
stroke_color: Color = RED,
stroke_color: ParsableManimColor = RED,
stroke_width: float = 6,
scale_factor: float = 1,
**kwargs,
Expand Down
Loading