Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/github_actions/FedericoCarboni/se…
Browse files Browse the repository at this point in the history
…tup-ffmpeg-3
  • Loading branch information
JasonGrace2282 committed Apr 11, 2024
2 parents 5ad0c58 + 294313d commit 2d88ea6
Show file tree
Hide file tree
Showing 35 changed files with 428 additions and 381 deletions.
5 changes: 1 addition & 4 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Exclude the grpc generated code
exclude = ./manim/grpc/gen/*, __pycache__,.git,
per-file-ignores = __init__.py:F401
max-complexity = 15
max-complexity = 29
max-line-length = 88
statistics = True
# Prevents some flake8-rst-docstrings errors
Expand All @@ -27,9 +27,6 @@ extend-ignore = E203, W503, D202, D212, D213, D404
# Plug-in: flake8-simplify
SIM105, SIM106, SIM119,

# Plug-in: flake8-comprehensions
C901

# Plug-in: flake8-pytest-style
PT001, PT004, PT006, PT011, PT018, PT022, PT023,

Expand Down
2 changes: 1 addition & 1 deletion LICENSE.community
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021, the Manim Community Developers
Copyright (c) 2024, the Manim Community Developers

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion docs/source/contributing/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ For first-time contributors
managing virtual environments.

If you choose to use Poetry as well, follow `Poetry's installation
guidelines <https://python-poetry.org/docs/master/#installation>`__
guidelines <https://python-poetry.org/docs/master/#installing-with-pipx>`__
to install it on your system, then run ``poetry install`` from
your cloned repository. Poetry will then install Manim, as well
as create and enter a virtual environment. You can always re-enter
Expand Down
4 changes: 2 additions & 2 deletions docs/source/contributing/docs/typings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ Typing guidelines
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from manim.typing import Vector3
# type stuff with Vector3
from manim.typing import Vector3D
# type stuff with Vector3D
Missing Sections for typehints are:
-----------------------------------
Expand Down
4 changes: 2 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ in the right place!
You can also find information on Manim's docker images and (online)
notebook environments there.
- Want to try the library before installing it? Take a look at our
interactive online playground at https://try.manim.community in form
interactive online playground at https://try.manim.community in the form
of a Jupyter notebook.
- In our :doc:`Tutorials <tutorials/index>` section you will find a
collection of resources that will teach you how to use Manim. In particular,
Expand Down Expand Up @@ -71,7 +71,7 @@ Here are some short summaries for all of the sections in this documentation:
can be found in the :doc:`FAQ </faq/index>` section.
- The :doc:`Reference Manual </reference>` contains a comprehensive list of all of Manim's
(documented) modules, classes, and functions. If you are somewhat familiar with Manim's
module structure feel free to browse the manual directly. If you are searching for
module structure, feel free to browse the manual directly. If you are searching for
something specific, feel free to use the documentation's search feature in the sidebar.
Many classes and methods come with their own illustrated examples too!
- The :doc:`Plugins </plugins>` page documents how to install, write, and distribute
Expand Down
2 changes: 1 addition & 1 deletion docs/source/installation/jupyter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ then execute it.
texlive-latex-recommended texlive-science \
tipa libpango1.0-dev
!pip install manim
!pip install IPython --upgrade
!pip install IPython==8.21.0
You should start to see Colab installing all the dependencies specified
in these commands. After the execution has completed, you will be prompted
Expand Down
32 changes: 5 additions & 27 deletions docs/source/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,40 +99,18 @@ directory structure, build system, and naming are completely up to your
discretion as an author. The aforementioned template plugin is only a model
using Poetry since this is the build system Manim uses. The plugin's `entry
point <https://packaging.python.org/specifications/entry-points/>`_ can be
specified in poetry as:
specified in Poetry as:

.. code-block:: toml
[tool.poetry.plugins."manim.plugins"]
"name" = "object_reference"
Here ``name`` is the name of the module of the plugin.
.. versionremoved:: 0.19.0

Here ``object_reference`` can point to either a function in a module or a module
itself. For example,

.. code-block:: toml
[tool.poetry.plugins."manim.plugins"]
"manim_plugintemplate" = "manim_plugintemplate"
Here a module is used as ``object_reference``, and when this plugin is enabled,
Manim will look for ``__all__`` keyword defined in ``manim_plugintemplate`` and
everything as a global variable one by one.

If ``object_reference`` is a function, Manim calls the function and expects the
function to return a list of modules or functions that need to be defined globally.

For example,

.. code-block:: toml
[tool.poetry.plugins."manim.plugins"]
"manim_plugintemplate" = "manim_awesomeplugin.imports:setup_things"
Here, Manim will call the function ``setup_things`` defined in
``manim_awesomeplugin.imports`` and calls that. It returns a list of function or
modules which will be imported globally.
Plugins should be imported explicitly to be usable in user code. The plugin
system will probably be refactored in the future to provide a more structured
interface.

A note on Renderer Compatibility
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 0 additions & 2 deletions manim/__main__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from __future__ import annotations

import sys

import click
import cloup

Expand Down
23 changes: 6 additions & 17 deletions manim/animation/indication.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def construct(self):
"Flash",
"ShowPassingFlash",
"ShowPassingFlashWithThinningStrokeWidth",
"ShowCreationThenFadeOut",
"ApplyWave",
"Circumscribe",
"Wiggle",
Expand Down Expand Up @@ -148,7 +147,7 @@ def construct(self):

def __init__(
self,
mobject: "Mobject",
mobject: Mobject,
scale_factor: float = 1.2,
color: str = YELLOW,
rate_func: Callable[[float, Optional[float]], np.ndarray] = there_and_back,
Expand All @@ -158,7 +157,7 @@ def __init__(
self.scale_factor = scale_factor
super().__init__(mobject, rate_func=rate_func, **kwargs)

def create_target(self) -> "Mobject":
def create_target(self) -> Mobject:
target = self.mobject.copy()
target.scale(self.scale_factor)
target.set_color(self.color)
Expand Down Expand Up @@ -342,16 +341,6 @@ def __init__(self, vmobject, n_segments=10, time_width=0.1, remover=True, **kwar
)


@deprecated(
since="v0.15.0",
until="v0.16.0",
message="Use Create then FadeOut to achieve this effect.",
)
class ShowCreationThenFadeOut(Succession):
def __init__(self, mobject: "Mobject", remover: bool = True, **kwargs) -> None:
super().__init__(Create(mobject), FadeOut(mobject), remover=remover, **kwargs)


class ApplyWave(Homotopy):
"""Send a wave through the Mobject distorting it temporarily.
Expand Down Expand Up @@ -397,7 +386,7 @@ def construct(self):

def __init__(
self,
mobject: "Mobject",
mobject: Mobject,
direction: np.ndarray = UP,
amplitude: float = 0.2,
wave_func: Callable[[float], float] = smooth,
Expand Down Expand Up @@ -516,7 +505,7 @@ def construct(self):

def __init__(
self,
mobject: "Mobject",
mobject: Mobject,
scale_value: float = 1.1,
rotation_angle: float = 0.01 * TAU,
n_wiggles: int = 6,
Expand Down Expand Up @@ -544,8 +533,8 @@ def get_rotate_about_point(self) -> np.ndarray:

def interpolate_submobject(
self,
submobject: "Mobject",
starting_submobject: "Mobject",
submobject: Mobject,
starting_submobject: Mobject,
alpha: float,
) -> None:
submobject.points[:, :] = starting_submobject.points
Expand Down
7 changes: 5 additions & 2 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 TYPE_CHECKING

import numpy as np
from typing_extensions import Self

from manim import config
from manim.constants import *
Expand All @@ -31,6 +30,8 @@
from manim.utils.space_ops import angle_of_vector, line_intersection, normalize

if TYPE_CHECKING:
from typing_extensions import Self

from manim.typing import Point2D, Point3D, Vector3D
from manim.utils.color import ParsableManimColor

Expand Down Expand Up @@ -659,7 +660,9 @@ def construct(self):
self.add(plane, vector_1, vector_2)
"""

def __init__(self, direction: Vector3D = RIGHT, buff: float = 0, **kwargs) -> None:
def __init__(
self, direction: Point2D | Point3D = RIGHT, buff: float = 0, **kwargs
) -> None:
self.buff = buff
if len(direction) == 2:
direction = np.hstack([direction, 0])
Expand Down
92 changes: 80 additions & 12 deletions manim/mobject/mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ def has_time_based_updater(self) -> bool:
Returns
-------
class:`bool`
:class:`bool`
``True`` if at least one updater uses the ``dt`` parameter, ``False``
otherwise.
Expand Down Expand Up @@ -1905,7 +1905,17 @@ def fade(self, darkness: float = 0.5, family: bool = True) -> Self:
return self

def get_color(self) -> ManimColor:
"""Returns the color of the :class:`~.Mobject`"""
"""Returns the color of the :class:`~.Mobject`
Examples
--------
::
>>> from manim import Square, RED
>>> Square(color=RED).get_color() == RED
True
"""
return self.color

##
Expand Down Expand Up @@ -2700,13 +2710,13 @@ def push_self_into_submobjects(self) -> Self:

def add_n_more_submobjects(self, n: int) -> Self | None:
if n == 0:
return
return None

curr = len(self.submobjects)
if curr == 0:
# If empty, simply add n point mobjects
self.submobjects = [self.get_point_mobject() for k in range(n)]
return
return None

target = curr + n
# TODO, factor this out to utils so as to reuse
Expand Down Expand Up @@ -2761,7 +2771,6 @@ def interpolate_color(self, mobject1: Mobject, mobject2: Mobject, alpha: float):
def become(
self,
mobject: Mobject,
copy_submobjects: bool = True,
match_height: bool = False,
match_width: bool = False,
match_depth: bool = False,
Expand All @@ -2774,20 +2783,25 @@ def become(
.. note::
If both match_height and match_width are ``True`` then the transformed :class:`~.Mobject`
will match the height first and then the width
will match the height first and then the width.
Parameters
----------
match_height
If ``True``, then the transformed :class:`~.Mobject` will match the height of the original
Whether or not to preserve the height of the original
:class:`~.Mobject`.
match_width
If ``True``, then the transformed :class:`~.Mobject` will match the width of the original
Whether or not to preserve the width of the original
:class:`~.Mobject`.
match_depth
If ``True``, then the transformed :class:`~.Mobject` will match the depth of the original
Whether or not to preserve the depth of the original
:class:`~.Mobject`.
match_center
If ``True``, then the transformed :class:`~.Mobject` will match the center of the original
Whether or not to preserve the center of the original
:class:`~.Mobject`.
stretch
If ``True``, then the transformed :class:`~.Mobject` will stretch to fit the proportions of the original
Whether or not to stretch the target mobject to match the
the proportions of the original :class:`~.Mobject`.
Examples
--------
Expand All @@ -2801,8 +2815,62 @@ def construct(self):
self.wait(0.5)
circ.become(square)
self.wait(0.5)
"""
The following examples illustrate how mobject measurements
change when using the ``match_...`` and ``stretch`` arguments.
We start with a rectangle that is 2 units high and 4 units wide,
which we want to turn into a circle of radius 3::
>>> from manim import Rectangle, Circle
>>> import numpy as np
>>> rect = Rectangle(height=2, width=4)
>>> circ = Circle(radius=3)
With ``stretch=True``, the target circle is deformed to match
the proportions of the rectangle, which results in the target
mobject being an ellipse with height 2 and width 4. We can
check that the resulting points satisfy the ellipse equation
:math:`x^2/a^2 + y^2/b^2 = 1` with :math:`a = 4/2` and :math:`b = 2/2`
being the semi-axes::
>>> result = rect.copy().become(circ, stretch=True)
>>> result.height, result.width
(2.0, 4.0)
>>> ellipse_eq = np.sum(result.get_anchors()**2 * [1/4, 1, 0], axis=1)
>>> np.allclose(ellipse_eq, 1)
True
With ``match_height=True`` and ``match_width=True`` the circle is
scaled such that the height or the width of the rectangle will
be preserved, respectively.
The points of the resulting mobject satisfy the circle equation
:math:`x^2 + y^2 = r^2` for the corresponding radius :math:`r`::
>>> result = rect.copy().become(circ, match_height=True)
>>> result.height, result.width
(2.0, 2.0)
>>> circle_eq = np.sum(result.get_anchors()**2, axis=1)
>>> np.allclose(circle_eq, 1)
True
>>> result = rect.copy().become(circ, match_width=True)
>>> result.height, result.width
(4.0, 4.0)
>>> circle_eq = np.sum(result.get_anchors()**2, axis=1)
>>> np.allclose(circle_eq, 2**2)
True
With ``match_center=True``, the resulting mobject is moved such that
its center is the same as the center of the original mobject::
>>> rect = rect.shift(np.array([0, 1, 0]))
>>> np.allclose(rect.get_center(), circ.get_center())
False
>>> result = rect.copy().become(circ, match_center=True)
>>> np.allclose(rect.get_center(), result.get_center())
True
"""
mobject = mobject.copy()
if stretch:
mobject.stretch_to_fit_height(self.height)
mobject.stretch_to_fit_width(self.width)
Expand Down
1 change: 0 additions & 1 deletion manim/mobject/opengl/opengl_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
)

DEFAULT_DOT_RADIUS = 0.08
DEFAULT_SMALL_DOT_RADIUS = 0.04
DEFAULT_DASH_LENGTH = 0.05
DEFAULT_ARROW_TIP_LENGTH = 0.35
DEFAULT_ARROW_TIP_WIDTH = 0.35
Expand Down
Loading

0 comments on commit 2d88ea6

Please sign in to comment.