From 97c0f4857b322934c5752b8450b85ffd2626c50c Mon Sep 17 00:00:00 2001 From: Bill Xi <86190295+TurkeyBilly@users.noreply.github.com> Date: Tue, 15 Feb 2022 09:35:10 +0800 Subject: [PATCH 01/11] Update numbers.py Added config passing for text --- manimlib/mobject/numbers.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/manimlib/mobject/numbers.py b/manimlib/mobject/numbers.py index 7a8d05ba..b098f87c 100644 --- a/manimlib/mobject/numbers.py +++ b/manimlib/mobject/numbers.py @@ -20,6 +20,7 @@ class DecimalNumber(VMobject): "include_background_rectangle": False, "edge_to_fix": LEFT, "font_size": 48, + "text_config": {} # Do not pass in font_size here } def __init__(self, number=0, **kwargs): @@ -30,13 +31,13 @@ class DecimalNumber(VMobject): def set_submobjects_from_number(self, number): self.number = number self.set_submobjects([]) - + string_to_mob_ = lambda s: self.string_to_mob(s, **self.text_config) num_string = self.get_num_string(number) - self.add(*map(self.string_to_mob, num_string)) + self.add(*map(string_to_mob_, num_string)) # Add non-numerical bits if self.show_ellipsis: - dots = self.string_to_mob("...") + dots = string_to_mob_("...") dots.arrange(RIGHT, buff=2 * dots[0].get_width()) self.add(dots) if self.unit is not None: @@ -85,10 +86,15 @@ class DecimalNumber(VMobject): def get_font_size(self): return self.data["font_size"][0] - def string_to_mob(self, string, mob_class=Text): - if string not in string_to_mob_map: - string_to_mob_map[string] = mob_class(string, font_size=1) - mob = string_to_mob_map[string].copy() + def string_to_mob(self, string, mob_class=Text, **kwargs): + if not kwargs: + if string not in string_to_mob_map: + string_to_mob_map[string] = mob_class(string, font_size=1, **kwargs) + mob = string_to_mob_map[string].copy() + else: + if (string, str(kwargs)) not in string_to_mob_map: + string_to_mob_map[(string, str(kwargs))] = mob_class(string, font_size=1, **kwargs) + mob = string_to_mob_map[(string, str(kwargs))].copy() mob.scale(self.get_font_size()) return mob From 9d04e287d7590068feabc9179b25325cb72b0dc5 Mon Sep 17 00:00:00 2001 From: Bill Xi <86190295+TurkeyBilly@users.noreply.github.com> Date: Tue, 15 Feb 2022 10:20:06 +0800 Subject: [PATCH 02/11] Removed init_colors --- manimlib/mobject/numbers.py | 1 - 1 file changed, 1 deletion(-) diff --git a/manimlib/mobject/numbers.py b/manimlib/mobject/numbers.py index b098f87c..84bfa3e4 100644 --- a/manimlib/mobject/numbers.py +++ b/manimlib/mobject/numbers.py @@ -26,7 +26,6 @@ class DecimalNumber(VMobject): def __init__(self, number=0, **kwargs): super().__init__(**kwargs) self.set_submobjects_from_number(number) - self.init_colors() def set_submobjects_from_number(self, number): self.number = number From aef02bfcf99c5bc84271463f2c589b21e7fd6d7b Mon Sep 17 00:00:00 2001 From: Bill Xi <86190295+TurkeyBilly@users.noreply.github.com> Date: Tue, 15 Feb 2022 11:45:17 +0800 Subject: [PATCH 03/11] changed hashing --- manimlib/mobject/numbers.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/manimlib/mobject/numbers.py b/manimlib/mobject/numbers.py index 84bfa3e4..7481e0d7 100644 --- a/manimlib/mobject/numbers.py +++ b/manimlib/mobject/numbers.py @@ -86,14 +86,20 @@ class DecimalNumber(VMobject): return self.data["font_size"][0] def string_to_mob(self, string, mob_class=Text, **kwargs): - if not kwargs: - if string not in string_to_mob_map: - string_to_mob_map[string] = mob_class(string, font_size=1, **kwargs) - mob = string_to_mob_map[string].copy() - else: - if (string, str(kwargs)) not in string_to_mob_map: - string_to_mob_map[(string, str(kwargs))] = mob_class(string, font_size=1, **kwargs) - mob = string_to_mob_map[(string, str(kwargs))].copy() + def make_hash(o): + if isinstance(o, (set, tuple, list)): + return tuple([make_hash(e) for e in o]) + elif not isinstance(o, dict): + return hash(o) + from copy import deepcopy as _deepcopy + new_o = _deepcopy(o) + for k, v in new_o.items(): + new_o[k] = make_hash(v) + return hash(tuple(frozenset(sorted(new_o.items())))) + + if (string, make_hash(kwargs)) not in string_to_mob_map: + string_to_mob_map[(string, make_hash(kwargs))] = mob_class(string, font_size=1, **kwargs) + mob = string_to_mob_map[(string, make_hash(kwargs))].copy() mob.scale(self.get_font_size()) return mob From 0bb9216c14cdfa0fc6c548199aeefa51879a8bab Mon Sep 17 00:00:00 2001 From: Bill Xi <86190295+TurkeyBilly@users.noreply.github.com> Date: Tue, 15 Feb 2022 21:50:14 +0800 Subject: [PATCH 04/11] Update hash_obj method --- manimlib/mobject/numbers.py | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/manimlib/mobject/numbers.py b/manimlib/mobject/numbers.py index 7481e0d7..a56353ae 100644 --- a/manimlib/mobject/numbers.py +++ b/manimlib/mobject/numbers.py @@ -2,6 +2,7 @@ from manimlib.constants import * from manimlib.mobject.svg.tex_mobject import SingleStringTex from manimlib.mobject.svg.text_mobject import Text from manimlib.mobject.types.vectorized_mobject import VMobject +from manimlib.utils.iterables import hash_obj string_to_mob_map = {} @@ -86,20 +87,9 @@ class DecimalNumber(VMobject): return self.data["font_size"][0] def string_to_mob(self, string, mob_class=Text, **kwargs): - def make_hash(o): - if isinstance(o, (set, tuple, list)): - return tuple([make_hash(e) for e in o]) - elif not isinstance(o, dict): - return hash(o) - from copy import deepcopy as _deepcopy - new_o = _deepcopy(o) - for k, v in new_o.items(): - new_o[k] = make_hash(v) - return hash(tuple(frozenset(sorted(new_o.items())))) - - if (string, make_hash(kwargs)) not in string_to_mob_map: - string_to_mob_map[(string, make_hash(kwargs))] = mob_class(string, font_size=1, **kwargs) - mob = string_to_mob_map[(string, make_hash(kwargs))].copy() + if (string, hash_obj(kwargs)) not in string_to_mob_map: + string_to_mob_map[(string, hash_obj(kwargs))] = mob_class(string, font_size=1, **kwargs) + mob = string_to_mob_map[(string, hash_obj(kwargs))].copy() mob.scale(self.get_font_size()) return mob From 46e356e791035c8484d8067b6f7994ecb425d7b3 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Tue, 15 Feb 2022 10:10:57 -0800 Subject: [PATCH 05/11] Change keyboard shortcut to drop into an embedding to be ctrl+shift+e --- manimlib/scene/scene.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manimlib/scene/scene.py b/manimlib/scene/scene.py index 4cccc142..ef72f711 100644 --- a/manimlib/scene/scene.py +++ b/manimlib/scene/scene.py @@ -631,7 +631,7 @@ class Scene(object): self.quit_interaction = True elif char == " " or symbol == 65363: # Space or right arrow self.hold_on_wait = False - elif char == "e": + elif char == "e" and modifiers == 3: # ctrl + shift + e self.embed(close_scene_on_exit=False) def on_resize(self, width: int, height: int): From a33eac7aa81b3f0852845b7cd065db89673fbd1f Mon Sep 17 00:00:00 2001 From: TonyCrane Date: Wed, 16 Feb 2022 11:17:37 +0800 Subject: [PATCH 06/11] docs: update changelog for #1742 #1744 #1745 #1746 --- docs/source/development/changelog.rst | 42 ++++++++++++++------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/docs/source/development/changelog.rst b/docs/source/development/changelog.rst index 5026b501..3c6efa01 100644 --- a/docs/source/development/changelog.rst +++ b/docs/source/development/changelog.rst @@ -6,38 +6,40 @@ Unreleased Fixed bugs ^^^^^^^^^^ -- `#1740 `__: Bug fix for the case of calling ``Write`` on a null object +- Bug fix for the case of calling ``Write`` on a null object (`#1740 `__) New Features ^^^^^^^^^^^^ -- `#1725 `__: Added ``TransformMatchingMTex`` -- `#1727 `__: Added ``ImplicitFunction`` -- `#1731 `__: Added ``Polyline`` -- `#1739 `__: Allowed ``Mobject.set_points`` to take in an empty list, and added ``Mobject.add_point`` -- `#1739 `__: Added ``Scene.refresh_locked_data`` -- `#1739 `__: Added presenter mode to scenes with ``-p`` option -- `#1739 `__: Allowed for an embed by hitting ``e`` during interaction -- `#1739 `__: Added ``Mobject.set_min_width/height/depth`` -- `#1739 `__: Allowed ``Mobject.match_coord/x/y/z`` to take in a point +- Added ``TransformMatchingMTex`` (`#1725 `__) +- Added ``ImplicitFunction`` (`#1727 `__) +- Added ``Polyline`` (`#1731 `__) +- Allowed ``Mobject.set_points`` to take in an empty list, and added ``Mobject.add_point`` (`#1739 `__) +- Added ``Scene.refresh_locked_data`` (`#1739 `__) +- Added presenter mode to scenes with ``-p`` option (`#1739 `__ and `#1742 `__) +- Allowed for an embed by hitting ``ctrl+shift+e`` during interaction (`#1739 `__ and `#1746 `__) +- Added ``Mobject.set_min_width/height/depth`` (`#1739 `__) +- Allowed ``Mobject.match_coord/x/y/z`` to take in a point (`#1739 `__) +- Added ``text_config`` to ``DecimalNumber`` (`#1744 `__) Refactor ^^^^^^^^ -- `#1725 `__: Refactored ``MTex`` -- `#1731 `__: Refactored ``SVGMobject`` with svgelements -- `#1739 `__: Made sure ``ParametricCurve`` has at least one point -- `#1739 `__: Set default to no tips on ``Axes`` -- `#1739 `__: Stopped displaying when writing tex string is happening +- Refactored ``MTex`` (`#1725 `__) +- Refactored ``SVGMobject`` with svgelements (`#1731 `__) +- Made sure ``ParametricCurve`` has at least one point (`#1739 `__) +- Set default to no tips on ``Axes`` (`#1739 `__) +- Stopped displaying when writing tex string is happening (`#1739 `__) +- Reorganize inheriting order and refactor SVGMobject (`#1745 `__) Dependencies ^^^^^^^^^^^^ -- `#1727 `__: Added dependency on ``isosurfaces`` -- `#1728 `__: Removed dependency on ``argparse`` since it's a built-in module -- `#1728 `__: Removed dependency on ``pyreadline`` -- `#1731 `__: Removed dependency on ``cssselect2`` -- `#1731 `__: Added dependency on ``svgelements`` +- Added dependency on ``isosurfaces`` (`#1727 `__) +- Removed dependency on ``argparse`` since it's a built-in module (`#1728 `__) +- Removed dependency on ``pyreadline`` (`#1728 `__) +- Removed dependency on ``cssselect2`` (`#1731 `__) +- Added dependency on ``svgelements`` (`#1731 `__) v1.4.1 From 6be6bd3075afeec7cab61c194892dc0cfcb26447 Mon Sep 17 00:00:00 2001 From: TonyCrane Date: Wed, 16 Feb 2022 11:20:08 +0800 Subject: [PATCH 07/11] docs: change the style of changelog --- docs/source/development/changelog.rst | 204 +++++++++++++------------- 1 file changed, 102 insertions(+), 102 deletions(-) diff --git a/docs/source/development/changelog.rst b/docs/source/development/changelog.rst index 3c6efa01..6298f64b 100644 --- a/docs/source/development/changelog.rst +++ b/docs/source/development/changelog.rst @@ -47,41 +47,41 @@ v1.4.1 Fixed bugs ^^^^^^^^^^ -- `#1724 `__: Temporarily fixed boolean operations' bug -- `d2e0811 `__: Import ``Iterable`` from ``collections.abc`` instead of ``collections`` which is deprecated since python 3.9 +- Temporarily fixed boolean operations' bug (`#1724 `__) +- Import ``Iterable`` from ``collections.abc`` instead of ``collections`` which is deprecated since python 3.9 (`d2e0811 `__) v1.4.0 ------ Fixed bugs ^^^^^^^^^^ -- `f1996f8 `__: Temporarily fixed ``Lightbulb`` -- `#1712 `__: Fixed some bugs of ``SVGMobject`` -- `#1717 `__: Fixed some bugs of SVG path string parser -- `#1720 `__: Fixed some bugs of ``MTex`` +- Temporarily fixed ``Lightbulb`` (`f1996f8 `__) +- Fixed some bugs of ``SVGMobject`` (`#1712 `__) +- Fixed some bugs of SVG path string parser (`#1717 `__) +- Fixed some bugs of ``MTex`` (`#1720 `__) New Features ^^^^^^^^^^^^ -- `#1694 `__: Added option to add ticks on x-axis in ``BarChart`` -- `#1704 `__: Added ``lable_buff`` config parameter for ``Brace`` -- `#1712 `__: Added support for ``rotate skewX skewY`` transform in SVG -- `#1717 `__: Added style support to ``SVGMobject`` -- `#1719 `__: Added parser to