Skip to content

Commit b3b0572

Browse files
committed
Merge remote-tracking branch 'origin/master' into moderngl-interaction
2 parents f607746 + 783bdde commit b3b0572

File tree

22 files changed

+566
-432
lines changed

22 files changed

+566
-432
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
<!--
2-
Thank you for contributing to manim!
3-
4-
Please ensure that your pull request works with the latest
5-
version of manim from this repository.
2+
Thanks for your contribution to ManimCommunity!
3+
4+
Before filling in the details, ensure:
5+
- Your local changes are up-to-date with ManimCommunity/manim
6+
7+
- The title of your PR gives a descriptive summary to end-users. Some examples:
8+
- Fixed last animations not running to completion
9+
- Added gradient support and documentation for SVG files
10+
Examples of what *NOT* to do:
11+
- "fixed that styling issue" - not descriptive enough
12+
- "fixed issue #XYZ" - end-user needs to do further research
613
-->
714

815
## Motivation
@@ -16,14 +23,6 @@ For PRs introducing new features, please provide code snippets
1623
using the newly introduced functionality and ideally even the
1724
expected rendered output. -->
1825

19-
## Oneline Summary of Changes
20-
<!-- Please update the lines below with a oneline summary
21-
for your changes. It will be included in the list of upcoming changes at
22-
https://github.com/ManimCommunity/manim/wiki/Changelog-for-next-release -->
23-
```
24-
- Added new feature ... / Fixed bug ... / ... (:pr:`PR NUMBER HERE`)
25-
```
26-
2726
## Testing Status
2827
<!-- Optional (but recommended): your computer specs and
2928
what tests you ran with their results, if any. This section
@@ -35,7 +34,7 @@ that might be useful for reviewers.. -->
3534

3635
## Acknowledgements
3736
- [ ] I have read the [Contributing Guidelines](https://docs.manim.community/en/latest/contributing.html)
38-
37+
- [ ] I have chosen a descriptive PR title (see top of PR template for examples)
3938
<!-- Once again, thanks for helping out by contributing to manim! -->
4039

4140

@@ -44,4 +43,4 @@ that might be useful for reviewers.. -->
4443
- [ ] Newly added functions/classes are either private or have a docstring
4544
- [ ] Newly added functions/classes have [tests](https://github.com/ManimCommunity/manim/wiki/Testing) added and (optional) examples in the docs
4645
- [ ] Newly added documentation builds, looks correctly formatted, and adds no additional build warnings
47-
- [ ] The oneline summary has been included [in the wiki](https://github.com/ManimCommunity/manim/wiki/Changelog-for-next-release)
46+
- [ ] The PR title is descriptive enough

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
run: |
5151
sudo apt update
5252
sudo apt install -y ffmpeg
53-
sudo apt-get -y install texlive texlive-latex-extra texlive-fonts-extra texlive-latex-recommended texlive-science texlive-fonts-extra tipa freeglut3-dev python-opengl
53+
sudo apt-get -y install texlive texlive-latex-extra texlive-fonts-extra texlive-latex-recommended texlive-science texlive-fonts-extra tipa python-opengl libpango1.0-dev
5454
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
5555
5656
- name: Install system dependencies (MacOS)

docs/source/changelog.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ Upcoming release
1414

1515
:Date: TBD
1616

17-
Changes for the upcoming release are tracked `in our GitHub wiki <https://github.com/ManimCommunity/manim/wiki/Changelog-for-next-release>`_.
18-
1917

2018
******
2119
v0.4.0

docs/source/reference.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ Mobjects
3737
~mobject.vector_field
3838
~mobject.svg.brace
3939
~mobject.svg.code_mobject
40+
~mobject.svg.style_utils
41+
~mobject.svg.svg_path
4042
~mobject.svg.svg_mobject
4143
~mobject.svg.tex_mobject
4244
~mobject.svg.text_mobject

manim/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@
5050
from .mobject.probability import *
5151
from .mobject.shape_matchers import *
5252
from .mobject.svg.brace import *
53+
from .mobject.svg.code_mobject import *
54+
from .mobject.svg.style_utils import *
5355
from .mobject.svg.svg_mobject import *
56+
from .mobject.svg.svg_path import *
5457
from .mobject.svg.tex_mobject import *
5558
from .mobject.svg.text_mobject import *
56-
from .mobject.svg.code_mobject import *
5759
from .mobject.three_d_utils import *
5860
from .mobject.three_dimensions import *
5961
from .mobject.types.image_mobject import *

manim/_config/main_utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ def parse_args(args: list) -> argparse.Namespace:
111111
elif subcmd == "plugins":
112112
return _parse_args_plugins(args)
113113
elif args[1] == "--version":
114-
print(f"Manim Community v{ __version__ }")
115114
sys.exit()
116115
# elif subcmd == some_other_future_subcmd:
117116
# return _parse_args_some_other_subcmd(args)

manim/mobject/coordinate_systems.py

Lines changed: 75 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from ..mobject.number_line import NumberLine
1515
from ..mobject.svg.tex_mobject import MathTex
1616
from ..mobject.types.vectorized_mobject import VGroup
17-
from ..utils.config_ops import merge_dicts_recursively
17+
from ..utils.config_ops import merge_dicts_recursively, update_dict_recursively
1818
from ..utils.simple_functions import binary_search
1919
from ..utils.space_ops import angle_of_vector
2020
from ..utils.color import LIGHT_GREY, WHITE, BLUE_D, BLUE
@@ -28,16 +28,12 @@ class CoordinateSystem:
2828
Abstract class for Axes and NumberPlane
2929
"""
3030

31-
def __init__(self, dim=2):
31+
def __init__(self, x_min=None, x_max=None, y_min=None, y_max=None, dim=2):
3232
self.dimension = dim
33-
if not hasattr(self, "x_min"):
34-
self.x_min = -config["frame_x_radius"]
35-
if not hasattr(self, "x_max"):
36-
self.x_max = config["frame_x_radius"]
37-
if not hasattr(self, "y_min"):
38-
self.y_min = -config["frame_y_radius"]
39-
if not hasattr(self, "y_max"):
40-
self.y_max = config["frame_y_radius"]
33+
self.x_min = -config["frame_x_radius"] if x_min is None else x_min
34+
self.x_max = config["frame_x_radius"] if x_max is None else x_max
35+
self.y_min = -config["frame_y_radius"] if y_min is None else y_min
36+
self.y_max = config["frame_y_radius"] if y_max is None else y_max
4137

4238
def coords_to_point(self, *coords):
4339
raise NotImplementedError()
@@ -132,43 +128,56 @@ def input_to_graph_point(self, x, graph):
132128
class Axes(VGroup, CoordinateSystem):
133129
def __init__(
134130
self,
131+
x_min=None,
132+
x_max=None,
133+
y_min=None,
134+
y_max=None,
135135
axis_config=None,
136136
x_axis_config=None,
137-
y_axis_config={"label_direction": LEFT},
137+
y_axis_config=None,
138138
center_point=ORIGIN,
139139
**kwargs
140140
):
141-
if axis_config is None:
142-
axis_config = {
143-
"color": LIGHT_GREY,
144-
"include_tip": True,
145-
"exclude_zero_from_default_numbers": True,
146-
}
147-
self.axis_config = axis_config
148-
if x_axis_config is None:
149-
x_axis_config = {}
150-
self.x_axis_config = x_axis_config
151-
self.y_axis_config = y_axis_config
152-
self.center_point = center_point
153-
CoordinateSystem.__init__(self)
141+
CoordinateSystem.__init__(
142+
self, x_min=x_min, x_max=x_max, y_min=y_min, y_max=y_max
143+
)
154144
VGroup.__init__(self, **kwargs)
155-
self.x_axis = self.create_axis(self.x_min, self.x_max, self.x_axis_config)
156-
self.y_axis = self.create_axis(self.y_min, self.y_max, self.y_axis_config)
157-
self.y_axis.rotate(90 * DEGREES, about_point=ORIGIN)
145+
146+
self.axis_config = {
147+
"color": LIGHT_GREY,
148+
"include_tip": True,
149+
"exclude_zero_from_default_numbers": True,
150+
}
151+
self.x_axis_config = {"x_min": self.x_min, "x_max": self.x_max}
152+
self.y_axis_config = {
153+
"x_min": self.y_min,
154+
"x_max": self.y_max,
155+
"label_direction": LEFT,
156+
"rotation": 90 * DEGREES,
157+
}
158+
159+
self.update_default_configs(
160+
(self.axis_config, self.x_axis_config, self.y_axis_config),
161+
(axis_config, x_axis_config, y_axis_config),
162+
)
163+
self.center_point = center_point
164+
self.x_axis = self.create_axis(self.x_axis_config)
165+
self.y_axis = self.create_axis(self.y_axis_config)
158166
# Add as a separate group in case various other
159167
# mobjects are added to self, as for example in
160168
# NumberPlane below
161169
self.axes = VGroup(self.x_axis, self.y_axis, dim=self.dim)
162170
self.add(*self.axes)
163171
self.shift(self.center_point)
164172

165-
def create_axis(self, min_val, max_val, axis_config):
166-
new_config = merge_dicts_recursively(
167-
self.axis_config,
168-
{"x_min": min_val, "x_max": max_val},
169-
axis_config,
170-
)
171-
return NumberLine(**new_config)
173+
@staticmethod
174+
def update_default_configs(default_configs, passed_configs):
175+
for default_config, passed_config in zip(default_configs, passed_configs):
176+
if passed_config is not None:
177+
update_dict_recursively(default_config, passed_config)
178+
179+
def create_axis(self, axis_config):
180+
return NumberLine(**merge_dicts_recursively(self.axis_config, axis_config))
172181

173182
def coords_to_point(self, *coords):
174183
origin = self.x_axis.number_to_point(0)
@@ -208,37 +217,33 @@ def add_coordinates(self, x_vals=None, y_vals=None):
208217
class ThreeDAxes(Axes):
209218
def __init__(
210219
self,
211-
z_axis_config=None,
212-
z_min=-3.5,
213-
z_max=3.5,
214220
x_min=-5.5,
215221
x_max=5.5,
216222
y_min=-5.5,
217223
y_max=5.5,
224+
z_min=-3.5,
225+
z_max=3.5,
226+
z_axis_config=None,
218227
z_normal=DOWN,
219228
num_axis_pieces=20,
220229
light_source=9 * DOWN + 7 * LEFT + 10 * OUT,
221230
**kwargs
222231
):
223-
if z_axis_config is None:
224-
z_axis_config = {}
225-
self.z_axis_config = z_axis_config
232+
Axes.__init__(
233+
self, x_min=x_min, x_max=x_max, y_min=y_min, y_max=y_max, **kwargs
234+
)
226235
self.z_min = z_min
227236
self.z_max = z_max
237+
self.z_axis_config = {"x_min": self.z_min, "x_max": self.z_max}
238+
self.update_default_configs((self.z_axis_config,), (z_axis_config,))
228239
self.z_normal = z_normal
229240
self.num_axis_pieces = num_axis_pieces
230241
self.light_source = light_source
231-
self.x_min = x_min
232-
self.x_max = x_max
233-
self.y_min = y_min
234-
self.y_max = y_max
235-
Axes.__init__(self, **kwargs)
236242
self.dimension = 3
237-
z_axis = self.z_axis = self.create_axis(
238-
self.z_min, self.z_max, self.z_axis_config
239-
)
240-
z_axis.rotate(-np.pi / 2, UP, about_point=ORIGIN)
241-
z_axis.rotate(angle_of_vector(self.z_normal), OUT, about_point=ORIGIN)
243+
z_axis = self.z_axis = self.create_axis(self.z_axis_config)
244+
z_axis.shift(self.center_point)
245+
z_axis.rotate_about_zero(-np.pi / 2, UP)
246+
z_axis.rotate_about_zero(angle_of_vector(self.z_normal))
242247
self.axes.add(z_axis)
243248
self.add(z_axis)
244249

@@ -280,28 +285,26 @@ def __init__(
280285
make_smooth_after_applying_functions=True,
281286
**kwargs
282287
):
283-
if axis_config is None:
284-
axis_config = {
285-
"stroke_color": WHITE,
286-
"stroke_width": 2,
287-
"include_ticks": False,
288-
"include_tip": False,
289-
"line_to_number_buff": SMALL_BUFF,
290-
"label_direction": DR,
291-
"number_scale_val": 0.5,
292-
}
293-
self.axis_config = axis_config
294-
if y_axis_config is None:
295-
y_axis_config = {"label_direction": DR}
296-
self.y_axis_config = y_axis_config
297-
298-
if background_line_style is None:
299-
background_line_style = {
300-
"stroke_color": BLUE_D,
301-
"stroke_width": 2,
302-
"stroke_opacity": 1,
303-
}
304-
self.background_line_style = background_line_style
288+
self.axis_config = {
289+
"stroke_color": WHITE,
290+
"stroke_width": 2,
291+
"include_ticks": False,
292+
"include_tip": False,
293+
"line_to_number_buff": SMALL_BUFF,
294+
"label_direction": DR,
295+
"number_scale_val": 0.5,
296+
}
297+
self.y_axis_config = {"label_direction": DR}
298+
self.background_line_style = {
299+
"stroke_color": BLUE_D,
300+
"stroke_width": 2,
301+
"stroke_opacity": 1,
302+
}
303+
304+
self.update_default_configs(
305+
(self.axis_config, self.y_axis_config, self.background_line_style),
306+
(axis_config, y_axis_config, background_line_style),
307+
)
305308

306309
# Defaults to a faded version of line_config
307310
self.faded_line_style = faded_line_style

manim/mobject/geometry.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def construct(self):
7676
from ..utils.space_ops import normalize
7777
from ..utils.space_ops import rotate_vector
7878
from ..utils.color import *
79+
from .. import logger
7980

8081
DEFAULT_DOT_RADIUS = 0.08
8182
DEFAULT_SMALL_DOT_RADIUS = 0.04
@@ -443,11 +444,13 @@ def __init__(
443444

444445

445446
class SmallDot(Dot):
446-
"""
447-
A dot with small radius
448-
"""
447+
"""Deprecated - A dot with small radius"""
449448

450449
def __init__(self, radius=DEFAULT_SMALL_DOT_RADIUS, **kwargs):
450+
logger.warning(
451+
"SmallDot has been deprecated and will be removed in a future release. "
452+
"Use Dot instead."
453+
)
451454
Dot.__init__(self, radius=radius, **kwargs)
452455

453456

manim/mobject/number_line.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def __init__(
2424
color=LIGHT_GREY,
2525
unit_size=1,
2626
width=None,
27+
rotation=0,
2728
include_ticks=True,
2829
tick_size=0.1,
2930
tick_frequency=1,
@@ -53,6 +54,7 @@ def __init__(
5354
self.unit_size = unit_size
5455
self.include_ticks = include_ticks
5556
self.tick_size = tick_size
57+
self.rotation = rotation
5658
self.tick_frequency = tick_frequency
5759
self.leftmost_tick = leftmost_tick
5860
self.numbers_with_elongated_ticks = numbers_with_elongated_ticks
@@ -92,9 +94,16 @@ def __init__(
9294
self.add_tip()
9395
if self.include_ticks:
9496
self.add_tick_marks()
97+
self.rotate_about_zero(self.rotation)
9598
if self.include_numbers:
9699
self.add_numbers()
97100

101+
def rotate_about_zero(self, angle, axis=OUT, **kwargs):
102+
return self.rotate_about_number(0, angle, axis, **kwargs)
103+
104+
def rotate_about_number(self, number, angle, axis=OUT, **kwargs):
105+
return self.rotate(angle, axis, about_point=self.n2p(number), **kwargs)
106+
98107
def init_leftmost_tick(self):
99108
if self.leftmost_tick is None:
100109
self.leftmost_tick = op.mul(
@@ -186,7 +195,12 @@ def default_numbers_to_display(self):
186195
return numbers
187196

188197
def get_number_mobject(
189-
self, number, number_config=None, scale_val=None, direction=None, buff=None
198+
self,
199+
number,
200+
number_config=None,
201+
scale_val=None,
202+
direction=None,
203+
buff=None,
190204
):
191205
number_config = merge_dicts_recursively(
192206
self.decimal_number_config,

0 commit comments

Comments
 (0)