datacut 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- datacut/__init__.py +121 -0
- datacut/__main__.py +122 -0
- datacut/animation/__init__.py +0 -0
- datacut/animation/animation.py +336 -0
- datacut/animation/composition.py +258 -0
- datacut/animation/creation.py +315 -0
- datacut/animation/fading.py +328 -0
- datacut/animation/growing.py +90 -0
- datacut/animation/indication.py +608 -0
- datacut/animation/movement.py +165 -0
- datacut/animation/numbers.py +92 -0
- datacut/animation/physics.py +453 -0
- datacut/animation/rotation.py +95 -0
- datacut/animation/specialized.py +956 -0
- datacut/animation/transform.py +505 -0
- datacut/animation/transform_matching_parts.py +343 -0
- datacut/animation/update.py +95 -0
- datacut/camera/__init__.py +0 -0
- datacut/camera/camera.py +795 -0
- datacut/camera/camera_frame.py +320 -0
- datacut/camera/cinematography.py +1166 -0
- datacut/config.py +479 -0
- datacut/constants.py +160 -0
- datacut/css/__init__.py +189 -0
- datacut/css/easing.py +328 -0
- datacut/css/engine.py +1727 -0
- datacut/css/gradients.py +678 -0
- datacut/css/motion.py +1615 -0
- datacut/css/parser.py +741 -0
- datacut/css/presets.py +143 -0
- datacut/css/shader_fill.py +703 -0
- datacut/css/values.py +650 -0
- datacut/default_config.yml +224 -0
- datacut/event_handler/__init__.py +6 -0
- datacut/event_handler/event_dispatcher.py +161 -0
- datacut/event_handler/event_listner.py +31 -0
- datacut/event_handler/event_type.py +11 -0
- datacut/event_handler/picking.py +111 -0
- datacut/event_keys.py +53 -0
- datacut/extract_scene.py +200 -0
- datacut/layout/__init__.py +39 -0
- datacut/layout/components.py +425 -0
- datacut/layout/containers.py +1520 -0
- datacut/logger.py +13 -0
- datacut/mobject/__init__.py +0 -0
- datacut/mobject/boolean_ops.py +168 -0
- datacut/mobject/changing.py +209 -0
- datacut/mobject/coordinate_systems.py +1056 -0
- datacut/mobject/fractals.py +348 -0
- datacut/mobject/frame.py +80 -0
- datacut/mobject/functions.py +147 -0
- datacut/mobject/geometry.py +1834 -0
- datacut/mobject/gltf.py +243 -0
- datacut/mobject/interactive.py +906 -0
- datacut/mobject/lights.py +366 -0
- datacut/mobject/materials.py +207 -0
- datacut/mobject/matrix.py +570 -0
- datacut/mobject/mesh3d.py +2288 -0
- datacut/mobject/mobject.py +2885 -0
- datacut/mobject/mobject_update_utils.py +123 -0
- datacut/mobject/model.py +543 -0
- datacut/mobject/number_line.py +517 -0
- datacut/mobject/numbers.py +441 -0
- datacut/mobject/probability.py +536 -0
- datacut/mobject/shape_matchers.py +161 -0
- datacut/mobject/subtitles.py +260 -0
- datacut/mobject/svg/__init__.py +0 -0
- datacut/mobject/svg/brace.py +356 -0
- datacut/mobject/svg/drawings.py +1041 -0
- datacut/mobject/svg/old_tex_mobject.py +335 -0
- datacut/mobject/svg/path_cache.py +155 -0
- datacut/mobject/svg/special_tex.py +216 -0
- datacut/mobject/svg/string_mobject.py +622 -0
- datacut/mobject/svg/svg_mobject.py +657 -0
- datacut/mobject/svg/svg_parse.py +437 -0
- datacut/mobject/svg/tex_mobject.py +499 -0
- datacut/mobject/svg/text_mobject.py +702 -0
- datacut/mobject/svg/typst_mobject.py +864 -0
- datacut/mobject/three_dimensions.py +686 -0
- datacut/mobject/types/__init__.py +0 -0
- datacut/mobject/types/dot_cloud.py +220 -0
- datacut/mobject/types/image_mobject.py +130 -0
- datacut/mobject/types/point_cloud_mobject.py +138 -0
- datacut/mobject/types/shader_mobject.py +268 -0
- datacut/mobject/types/surface.py +848 -0
- datacut/mobject/types/vectorized_mobject.py +1749 -0
- datacut/mobject/types/video_mobject.py +3902 -0
- datacut/mobject/value_tracker.py +110 -0
- datacut/mobject/vector_field.py +585 -0
- datacut/module_loader.py +176 -0
- datacut/reactive/__init__.py +25 -0
- datacut/reactive/signals.py +610 -0
- datacut/renderer/__init__.py +4 -0
- datacut/renderer/drawing.py +1066 -0
- datacut/renderer/gpu.py +800 -0
- datacut/renderer/material.py +88 -0
- datacut/renderer/pipeline.py +179 -0
- datacut/renderer/post_process.py +577 -0
- datacut/renderer/renderer.py +1285 -0
- datacut/renderer/shader_source.py +146 -0
- datacut/renderer/shared_buffer.py +185 -0
- datacut/renderer/texture.py +217 -0
- datacut/renderer/uniform_block.py +118 -0
- datacut/scene/__init__.py +0 -0
- datacut/scene/incremental.py +233 -0
- datacut/scene/interactive_scene.py +758 -0
- datacut/scene/performance.py +226 -0
- datacut/scene/presentation_scene.py +783 -0
- datacut/scene/recording.py +541 -0
- datacut/scene/safe_zones.py +323 -0
- datacut/scene/scene.py +2849 -0
- datacut/scene/scene_embed.py +277 -0
- datacut/scene/scene_file_writer.py +1014 -0
- datacut/scene/scene_task.py +183 -0
- datacut/scene/sfx.py +164 -0
- datacut/scene/sound.py +702 -0
- datacut/scene/sound_clip.py +580 -0
- datacut/scene/timeline.py +1689 -0
- datacut/scene/transcript.py +503 -0
- datacut/shaders/fill.wgsl +107 -0
- datacut/shaders/fill_depth.wgsl +198 -0
- datacut/shaders/image.wgsl +25 -0
- datacut/shaders/inserts/NOTE.md +16 -0
- datacut/shaders/inserts/clip_test.wgsl +14 -0
- datacut/shaders/inserts/complex_functions.wgsl +20 -0
- datacut/shaders/inserts/fill_color.wgsl +10 -0
- datacut/shaders/inserts/finalize_color.wgsl +44 -0
- datacut/shaders/inserts/frame_uniforms.wgsl +37 -0
- datacut/shaders/inserts/frame_units.wgsl +18 -0
- datacut/shaders/inserts/image_quad.wgsl +28 -0
- datacut/shaders/inserts/mobject_uniforms.wgsl +11 -0
- datacut/shaders/inserts/project_point.wgsl +44 -0
- datacut/shaders/inserts/quad_corners.wgsl +12 -0
- datacut/shaders/inserts/read_data.wgsl +33 -0
- datacut/shaders/inserts/surface_mesh.wgsl +106 -0
- datacut/shaders/mandelbrot_fractal.wgsl +100 -0
- datacut/shaders/mesh.wgsl +474 -0
- datacut/shaders/newton_fractal.wgsl +200 -0
- datacut/shaders/present.wgsl +62 -0
- datacut/shaders/stroke.wgsl +1141 -0
- datacut/shaders/stroke_depth.wgsl +1136 -0
- datacut/shaders/surface.wgsl +40 -0
- datacut/shaders/textured_surface.wgsl +59 -0
- datacut/shaders/true_dot.wgsl +78 -0
- datacut/shaders/video.wgsl +42 -0
- datacut/tex_templates.yml +736 -0
- datacut/transcribe.py +32 -0
- datacut/typing.py +412 -0
- datacut/utils/__init__.py +0 -0
- datacut/utils/bezier.py +467 -0
- datacut/utils/browser_audio.py +423 -0
- datacut/utils/browser_code_transform.py +1293 -0
- datacut/utils/browser_completions.py +2255 -0
- datacut/utils/browser_fonts.py +143 -0
- datacut/utils/browser_pathops.py +47 -0
- datacut/utils/browser_scheduler.py +18 -0
- datacut/utils/browser_typst.py +82 -0
- datacut/utils/cache.py +34 -0
- datacut/utils/cinematic_vfx.py +779 -0
- datacut/utils/color.py +203 -0
- datacut/utils/debug.py +46 -0
- datacut/utils/dict_ops.py +22 -0
- datacut/utils/directories.py +55 -0
- datacut/utils/editor_signatures.py +1806 -0
- datacut/utils/editor_thumbnails.py +769 -0
- datacut/utils/family_ops.py +48 -0
- datacut/utils/file_ops.py +65 -0
- datacut/utils/images.py +52 -0
- datacut/utils/iterables.py +216 -0
- datacut/utils/native.py +280 -0
- datacut/utils/paths.py +83 -0
- datacut/utils/rate_functions.py +154 -0
- datacut/utils/render_geometry.py +186 -0
- datacut/utils/simple_functions.py +99 -0
- datacut/utils/sounds.py +43 -0
- datacut/utils/space_ops.py +460 -0
- datacut/utils/structured_array.py +256 -0
- datacut/utils/svg_export.py +102 -0
- datacut/utils/tex.py +139 -0
- datacut/utils/tex_file_writing.py +164 -0
- datacut/utils/tex_to_symbol_count.py +186 -0
- datacut/utils/typst_file_writing.py +205 -0
- datacut/utils/vfx_presets.py +4543 -0
- datacut/utils/visual_css.py +737 -0
- datacut/utils/visual_editor.py +4292 -0
- datacut/utils/window_audio.py +760 -0
- datacut/window.py +910 -0
- datacut-0.1.0.dist-info/METADATA +226 -0
- datacut-0.1.0.dist-info/RECORD +193 -0
- datacut-0.1.0.dist-info/WHEEL +5 -0
- datacut-0.1.0.dist-info/entry_points.txt +2 -0
- datacut-0.1.0.dist-info/licenses/LICENSE.md +21 -0
- datacut-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
# What the Visual Editor files this module's classes under
|
|
4
|
+
__editor_category__ = 'Transform'
|
|
5
|
+
|
|
6
|
+
import inspect
|
|
7
|
+
|
|
8
|
+
import numpy as np
|
|
9
|
+
|
|
10
|
+
from datacut.animation.animation import Animation
|
|
11
|
+
from datacut.constants import DEG
|
|
12
|
+
from datacut.constants import OUT
|
|
13
|
+
from datacut.mobject.mobject import Group
|
|
14
|
+
from datacut.mobject.mobject import Mobject
|
|
15
|
+
from datacut.utils.paths import path_along_arc
|
|
16
|
+
from datacut.utils.paths import straight_path
|
|
17
|
+
|
|
18
|
+
from typing import TYPE_CHECKING
|
|
19
|
+
|
|
20
|
+
if TYPE_CHECKING:
|
|
21
|
+
from datacut.typing import Annotated, Example, Range
|
|
22
|
+
from datacut.typing import Angle, Duration, Vect3
|
|
23
|
+
from typing import Callable
|
|
24
|
+
import numpy.typing as npt
|
|
25
|
+
from datacut.scene.scene import Scene
|
|
26
|
+
from datacut.typing import ManimColor
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class Transform(Animation):
|
|
30
|
+
replace_mobject_with_target_in_scene: bool = False
|
|
31
|
+
|
|
32
|
+
def __init__(
|
|
33
|
+
self,
|
|
34
|
+
mobject: Mobject,
|
|
35
|
+
target_mobject: Mobject | None = None,
|
|
36
|
+
path_arc: Angle | Tuple[float, float] = 0.0,
|
|
37
|
+
path_arc_axis: Vect3 = OUT,
|
|
38
|
+
path_func: Callable | None = None,
|
|
39
|
+
**kwargs
|
|
40
|
+
):
|
|
41
|
+
self.target_mobject = target_mobject
|
|
42
|
+
self.path_arc = path_arc
|
|
43
|
+
self.path_arc_axis = path_arc_axis
|
|
44
|
+
self.path_func = path_func
|
|
45
|
+
super().__init__(mobject, **kwargs)
|
|
46
|
+
self.init_path_func()
|
|
47
|
+
|
|
48
|
+
def init_path_func(self) -> None:
|
|
49
|
+
if self.path_func is not None:
|
|
50
|
+
return
|
|
51
|
+
elif isinstance(self.path_arc, float) and self.path_arc == 0:
|
|
52
|
+
self.path_func = straight_path
|
|
53
|
+
else:
|
|
54
|
+
self.path_func = path_along_arc(
|
|
55
|
+
self.path_arc,
|
|
56
|
+
self.path_arc_axis,
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
def begin(self) -> None:
|
|
60
|
+
self.target_mobject = self.create_target()
|
|
61
|
+
self.check_target_mobject_validity()
|
|
62
|
+
|
|
63
|
+
if self.mobject.is_aligned_with(self.target_mobject):
|
|
64
|
+
# Nothing to align, so nothing is done to the target and it can stand as it is
|
|
65
|
+
self.target_copy = self.target_mobject
|
|
66
|
+
else:
|
|
67
|
+
# Use a copy of target_mobject for the align_data_and_family
|
|
68
|
+
# call so that the actual target_mobject stays
|
|
69
|
+
# preserved, since calling align_data will potentially
|
|
70
|
+
# change the structure of both arguments
|
|
71
|
+
self.target_copy = self.target_mobject.copy()
|
|
72
|
+
self.mobject.align_data_and_family(self.target_copy)
|
|
73
|
+
super().begin()
|
|
74
|
+
|
|
75
|
+
def create_target(self) -> Mobject:
|
|
76
|
+
# Has no meaningful effect here, but may be useful
|
|
77
|
+
# in subclasses
|
|
78
|
+
return self.target_mobject
|
|
79
|
+
|
|
80
|
+
def check_target_mobject_validity(self) -> None:
|
|
81
|
+
if self.target_mobject is None:
|
|
82
|
+
raise Exception(
|
|
83
|
+
f"{self.__class__.__name__}.create_target not properly implemented"
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
def clean_up_from_scene(self, scene: Scene) -> None:
|
|
87
|
+
super().clean_up_from_scene(scene)
|
|
88
|
+
if self.replace_mobject_with_target_in_scene:
|
|
89
|
+
scene.remove(self.mobject)
|
|
90
|
+
scene.add(self.target_mobject)
|
|
91
|
+
|
|
92
|
+
def update_config(self, **kwargs) -> None:
|
|
93
|
+
Animation.update_config(self, **kwargs)
|
|
94
|
+
if "path_arc" in kwargs:
|
|
95
|
+
self.path_func = path_along_arc(
|
|
96
|
+
kwargs["path_arc"],
|
|
97
|
+
kwargs.get("path_arc_axis", OUT)
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
def get_all_mobjects(self) -> list[Mobject]:
|
|
101
|
+
return [
|
|
102
|
+
self.mobject,
|
|
103
|
+
self.starting_mobject,
|
|
104
|
+
self.target_mobject,
|
|
105
|
+
self.target_copy,
|
|
106
|
+
]
|
|
107
|
+
|
|
108
|
+
def get_all_families_zipped(self) -> zip[tuple[Mobject]]:
|
|
109
|
+
return zip(*[
|
|
110
|
+
mob.get_family()
|
|
111
|
+
for mob in [
|
|
112
|
+
self.mobject,
|
|
113
|
+
self.starting_mobject,
|
|
114
|
+
self.target_copy,
|
|
115
|
+
]
|
|
116
|
+
])
|
|
117
|
+
|
|
118
|
+
def get_interpolation_ends(self) -> tuple[Mobject, Mobject]:
|
|
119
|
+
return self.starting_mobject, self.target_copy
|
|
120
|
+
|
|
121
|
+
def interpolate_submobject(
|
|
122
|
+
self,
|
|
123
|
+
submob: Mobject,
|
|
124
|
+
start: Mobject,
|
|
125
|
+
target_copy: Mobject,
|
|
126
|
+
alpha: float
|
|
127
|
+
):
|
|
128
|
+
submob.interpolate(start, target_copy, alpha, self.path_func)
|
|
129
|
+
return self
|
|
130
|
+
|
|
131
|
+
editor_thumbnail = (
|
|
132
|
+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 24">'
|
|
133
|
+
'<g opacity="0.18">'
|
|
134
|
+
'<path d="M22.3 3.1Q20.1 3.1 17.9 3.1Q15.7 3.1 13.4 3.1Q11.2 3.1 9.0 3.1Q6.8 3.1 4.6 3.1Q4.6 5.3 4.6 7.6Q4.6 9.8 4.6 12.0Q4.6 14.2 4.6 16.4Q4.6 18.7 4.6 20.9Q6.8 20.9 9.0 20.9Q11.2 20.9 13.4 20.9Q15.7 20.9 17.9 20.9Q20.1 20.9 22.3 20.9Q22.3 18.7 22.3 16.4Q22.3 14.2 22.3 12.0Q22.3 9.8 22.3 7.6Q22.3 5.3 22.3 3.1Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
135
|
+
'</g>'
|
|
136
|
+
'<g opacity="0.32">'
|
|
137
|
+
'<path d="M27.3 5.2Q25.6 4.7 23.7 4.3Q21.8 3.9 19.8 3.5Q17.8 3.2 15.6 3.0Q13.5 2.8 11.3 2.8Q10.9 4.5 10.4 6.4Q10.0 8.3 9.7 10.3Q9.4 12.4 9.2 14.5Q9.0 16.6 9.0 18.8Q10.7 19.3 12.6 19.7Q14.5 20.1 16.5 20.5Q18.5 20.8 20.6 21.0Q22.8 21.2 24.9 21.2Q25.4 19.5 25.8 17.6Q26.3 15.7 26.6 13.7Q26.9 11.6 27.1 9.5Q27.3 7.4 27.3 5.2Z" fill="#7FD2A9" fill-opacity="0.60" stroke="#D4EBE3" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
138
|
+
'</g>'
|
|
139
|
+
'<g opacity="0.55">'
|
|
140
|
+
'<path d="M40.0 10.6Q39.6 8.9 38.6 7.3Q37.6 5.8 36.1 4.6Q34.6 3.5 32.7 2.8Q30.8 2.2 28.7 2.2Q27.1 2.5 25.5 3.5Q24.0 4.5 22.8 6.1Q21.6 7.6 21.0 9.5Q20.4 11.4 20.4 13.4Q20.7 15.1 21.7 16.7Q22.7 18.2 24.3 19.4Q25.8 20.5 27.7 21.2Q29.6 21.8 31.6 21.8Q33.3 21.5 34.8 20.5Q36.4 19.5 37.6 17.9Q38.7 16.4 39.4 14.5Q40.0 12.6 40.0 10.6Z" fill="#E4F524" fill-opacity="0.60" stroke="#F6F0C0" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
141
|
+
'</g>'
|
|
142
|
+
'<path d="M43.4 12.0Q43.4 10.0 42.7 8.2Q41.9 6.3 40.5 4.9Q39.1 3.5 37.3 2.8Q35.4 2.0 33.4 2.0Q31.5 2.0 29.6 2.8Q27.8 3.5 26.4 4.9Q25.0 6.3 24.2 8.2Q23.4 10.0 23.4 12.0Q23.4 14.0 24.2 15.8Q25.0 17.7 26.4 19.1Q27.8 20.5 29.6 21.2Q31.5 22.0 33.4 22.0Q35.4 22.0 37.3 21.2Q39.1 20.5 40.5 19.1Q41.9 17.7 42.7 15.8Q43.4 14.0 43.4 12.0Z" fill="#FFFF00" fill-opacity="0.60" stroke="#FFF1B6" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
143
|
+
'</svg>'
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
class ReplacementTransform(Transform):
|
|
148
|
+
replace_mobject_with_target_in_scene: bool = True
|
|
149
|
+
|
|
150
|
+
def begin(self) -> None:
|
|
151
|
+
if self.mobject is not self.target_mobject:
|
|
152
|
+
self._pre_transform_mobject = self.mobject.copy()
|
|
153
|
+
super().begin()
|
|
154
|
+
|
|
155
|
+
def clean_up_from_scene(self, scene: Scene) -> None:
|
|
156
|
+
super().clean_up_from_scene(scene)
|
|
157
|
+
if self.mobject is not self.target_mobject and hasattr(self, "_pre_transform_mobject"):
|
|
158
|
+
self.mobject.become(self._pre_transform_mobject)
|
|
159
|
+
|
|
160
|
+
editor_thumbnail = (
|
|
161
|
+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 24">'
|
|
162
|
+
'<g opacity="0.18">'
|
|
163
|
+
'<path d="M22.3 3.1Q20.1 3.1 17.9 3.1Q15.7 3.1 13.4 3.1Q11.2 3.1 9.0 3.1Q6.8 3.1 4.6 3.1Q4.6 5.3 4.6 7.6Q4.6 9.8 4.6 12.0Q4.6 14.2 4.6 16.4Q4.6 18.7 4.6 20.9Q6.8 20.9 9.0 20.9Q11.2 20.9 13.4 20.9Q15.7 20.9 17.9 20.9Q20.1 20.9 22.3 20.9Q22.3 18.7 22.3 16.4Q22.3 14.2 22.3 12.0Q22.3 9.8 22.3 7.6Q22.3 5.3 22.3 3.1Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
164
|
+
'</g>'
|
|
165
|
+
'<g opacity="0.32">'
|
|
166
|
+
'<path d="M27.3 5.2Q25.6 4.7 23.7 4.3Q21.8 3.9 19.8 3.5Q17.8 3.2 15.6 3.0Q13.5 2.8 11.3 2.8Q10.9 4.5 10.4 6.4Q10.0 8.3 9.7 10.3Q9.4 12.4 9.2 14.5Q9.0 16.6 9.0 18.8Q10.7 19.3 12.6 19.7Q14.5 20.1 16.5 20.5Q18.5 20.8 20.6 21.0Q22.8 21.2 24.9 21.2Q25.4 19.5 25.8 17.6Q26.3 15.7 26.6 13.7Q26.9 11.6 27.1 9.5Q27.3 7.4 27.3 5.2Z" fill="#7FD2A9" fill-opacity="0.60" stroke="#D4EBE3" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
167
|
+
'</g>'
|
|
168
|
+
'<g opacity="0.55">'
|
|
169
|
+
'<path d="M40.0 10.6Q39.6 8.9 38.6 7.3Q37.6 5.8 36.1 4.6Q34.6 3.5 32.7 2.8Q30.8 2.2 28.7 2.2Q27.1 2.5 25.5 3.5Q24.0 4.5 22.8 6.1Q21.6 7.6 21.0 9.5Q20.4 11.4 20.4 13.4Q20.7 15.1 21.7 16.7Q22.7 18.2 24.3 19.4Q25.8 20.5 27.7 21.2Q29.6 21.8 31.6 21.8Q33.3 21.5 34.8 20.5Q36.4 19.5 37.6 17.9Q38.7 16.4 39.4 14.5Q40.0 12.6 40.0 10.6Z" fill="#E4F524" fill-opacity="0.60" stroke="#F6F0C0" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
170
|
+
'</g>'
|
|
171
|
+
'<path d="M43.4 12.0Q43.4 10.0 42.7 8.2Q41.9 6.3 40.5 4.9Q39.1 3.5 37.3 2.8Q35.4 2.0 33.4 2.0Q31.5 2.0 29.6 2.8Q27.8 3.5 26.4 4.9Q25.0 6.3 24.2 8.2Q23.4 10.0 23.4 12.0Q23.4 14.0 24.2 15.8Q25.0 17.7 26.4 19.1Q27.8 20.5 29.6 21.2Q31.5 22.0 33.4 22.0Q35.4 22.0 37.3 21.2Q39.1 20.5 40.5 19.1Q41.9 17.7 42.7 15.8Q43.4 14.0 43.4 12.0Z" fill="#FFFF00" fill-opacity="0.60" stroke="#FFF1B6" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
172
|
+
'</svg>'
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
class TransformFromCopy(Transform):
|
|
177
|
+
replace_mobject_with_target_in_scene: bool = True
|
|
178
|
+
|
|
179
|
+
def __init__(self, mobject: Mobject, target_mobject: Mobject, **kwargs):
|
|
180
|
+
super().__init__(mobject.copy(), target_mobject, **kwargs)
|
|
181
|
+
|
|
182
|
+
editor_thumbnail = (
|
|
183
|
+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 24">'
|
|
184
|
+
'<g opacity="0.18">'
|
|
185
|
+
'<path d="M22.3 3.1Q20.1 3.1 17.9 3.1Q15.7 3.1 13.4 3.1Q11.2 3.1 9.0 3.1Q6.8 3.1 4.6 3.1Q4.6 5.3 4.6 7.6Q4.6 9.8 4.6 12.0Q4.6 14.2 4.6 16.4Q4.6 18.7 4.6 20.9Q6.8 20.9 9.0 20.9Q11.2 20.9 13.4 20.9Q15.7 20.9 17.9 20.9Q20.1 20.9 22.3 20.9Q22.3 18.7 22.3 16.4Q22.3 14.2 22.3 12.0Q22.3 9.8 22.3 7.6Q22.3 5.3 22.3 3.1Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
186
|
+
'</g>'
|
|
187
|
+
'<g opacity="0.32">'
|
|
188
|
+
'<path d="M27.3 5.2Q25.6 4.7 23.7 4.3Q21.8 3.9 19.8 3.5Q17.8 3.2 15.6 3.0Q13.5 2.8 11.3 2.8Q10.9 4.5 10.4 6.4Q10.0 8.3 9.7 10.3Q9.4 12.4 9.2 14.5Q9.0 16.6 9.0 18.8Q10.7 19.3 12.6 19.7Q14.5 20.1 16.5 20.5Q18.5 20.8 20.6 21.0Q22.8 21.2 24.9 21.2Q25.4 19.5 25.8 17.6Q26.3 15.7 26.6 13.7Q26.9 11.6 27.1 9.5Q27.3 7.4 27.3 5.2Z" fill="#7FD2A9" fill-opacity="0.60" stroke="#D4EBE3" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
189
|
+
'</g>'
|
|
190
|
+
'<g opacity="0.55">'
|
|
191
|
+
'<path d="M40.0 10.6Q39.6 8.9 38.6 7.3Q37.6 5.8 36.1 4.6Q34.6 3.5 32.7 2.8Q30.8 2.2 28.7 2.2Q27.1 2.5 25.5 3.5Q24.0 4.5 22.8 6.1Q21.6 7.6 21.0 9.5Q20.4 11.4 20.4 13.4Q20.7 15.1 21.7 16.7Q22.7 18.2 24.3 19.4Q25.8 20.5 27.7 21.2Q29.6 21.8 31.6 21.8Q33.3 21.5 34.8 20.5Q36.4 19.5 37.6 17.9Q38.7 16.4 39.4 14.5Q40.0 12.6 40.0 10.6Z" fill="#E4F524" fill-opacity="0.60" stroke="#F6F0C0" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
192
|
+
'</g>'
|
|
193
|
+
'<path d="M43.4 12.0Q43.4 10.0 42.7 8.2Q41.9 6.3 40.5 4.9Q39.1 3.5 37.3 2.8Q35.4 2.0 33.4 2.0Q31.5 2.0 29.6 2.8Q27.8 3.5 26.4 4.9Q25.0 6.3 24.2 8.2Q23.4 10.0 23.4 12.0Q23.4 14.0 24.2 15.8Q25.0 17.7 26.4 19.1Q27.8 20.5 29.6 21.2Q31.5 22.0 33.4 22.0Q35.4 22.0 37.3 21.2Q39.1 20.5 40.5 19.1Q41.9 17.7 42.7 15.8Q43.4 14.0 43.4 12.0Z" fill="#FFFF00" fill-opacity="0.60" stroke="#FFF1B6" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
194
|
+
'</svg>'
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
class MoveToTarget(Transform):
|
|
199
|
+
def __init__(self, mobject: Mobject, **kwargs):
|
|
200
|
+
self.check_validity_of_input(mobject)
|
|
201
|
+
super().__init__(mobject, mobject.target, **kwargs)
|
|
202
|
+
|
|
203
|
+
def check_validity_of_input(self, mobject: Mobject) -> None:
|
|
204
|
+
if not hasattr(mobject, "target"):
|
|
205
|
+
raise Exception(
|
|
206
|
+
"MoveToTarget called on mobject without attribute 'target'"
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
editor_thumbnail = (
|
|
210
|
+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">'
|
|
211
|
+
'<rect x="2.5" y="8" width="7" height="7" rx="1" fill="#58C4DD"/>'
|
|
212
|
+
'<rect x="14.5" y="8" width="7" height="7" rx="1" stroke="#DDDDDD" stroke-width="1.1" stroke-dasharray="1.8 1.4" fill="none" stroke-linecap="round" stroke-linejoin="round"/>'
|
|
213
|
+
'<path d="M10.5 11.5H12" stroke="#DDDDDD" stroke-width="1.2" fill="none" stroke-linecap="round" stroke-linejoin="round"/>'
|
|
214
|
+
'<path d="M13.8 11.5L12.1 12.5L12.1 10.5Z" fill="#DDDDDD"/>'
|
|
215
|
+
'</svg>'
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
class _MethodAnimation(MoveToTarget):
|
|
220
|
+
def __init__(self, mobject: Mobject, methods: list[Callable], **kwargs):
|
|
221
|
+
self.methods = methods
|
|
222
|
+
super().__init__(mobject, **kwargs)
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
class ApplyMethod(Transform):
|
|
226
|
+
def __init__(self, method: Annotated[Callable, Example("{selected}.scale, 0.5")], *args, **kwargs):
|
|
227
|
+
"""
|
|
228
|
+
method is a method of Mobject, *args are arguments for
|
|
229
|
+
that method. Key word arguments should be passed in
|
|
230
|
+
as the last arg, as a dict, since **kwargs is for
|
|
231
|
+
configuration of the transform itself
|
|
232
|
+
|
|
233
|
+
Relies on the fact that mobject methods return the mobject
|
|
234
|
+
"""
|
|
235
|
+
self.check_validity_of_input(method)
|
|
236
|
+
self.method = method
|
|
237
|
+
self.method_args = args
|
|
238
|
+
super().__init__(method.__self__, **kwargs)
|
|
239
|
+
|
|
240
|
+
def check_validity_of_input(self, method: Callable) -> None:
|
|
241
|
+
if not inspect.ismethod(method):
|
|
242
|
+
raise Exception(
|
|
243
|
+
"Whoops, looks like you accidentally invoked "
|
|
244
|
+
"the method you want to animate"
|
|
245
|
+
)
|
|
246
|
+
assert isinstance(method.__self__, Mobject)
|
|
247
|
+
|
|
248
|
+
def create_target(self) -> Mobject:
|
|
249
|
+
method = self.method
|
|
250
|
+
# Make sure it's a list so that args.pop() works
|
|
251
|
+
args = list(self.method_args)
|
|
252
|
+
|
|
253
|
+
if len(args) > 0 and isinstance(args[-1], dict):
|
|
254
|
+
method_kwargs = args.pop()
|
|
255
|
+
else:
|
|
256
|
+
method_kwargs = {}
|
|
257
|
+
target = method.__self__.copy()
|
|
258
|
+
method.__func__(target, *args, **method_kwargs)
|
|
259
|
+
return target
|
|
260
|
+
|
|
261
|
+
editor_thumbnail = (
|
|
262
|
+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 24">'
|
|
263
|
+
'<path d="M14.2 5.9Q8.1 5.9 2.0 5.9Q2.0 12.0 2.0 18.1Q8.1 18.1 14.2 18.1Q14.2 12.0 14.2 5.9Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
264
|
+
'<path d="M28.4 7.6Q24.0 7.6 19.6 7.6Q19.6 12.0 19.6 16.4Q24.0 16.4 28.4 16.4Q28.4 12.0 28.4 7.6Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
265
|
+
'<path d="M43.0 8.9Q39.9 8.9 36.7 8.9Q36.7 12.0 36.7 15.1Q39.9 15.1 43.0 15.1Q43.0 12.0 43.0 8.9Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
266
|
+
'</svg>'
|
|
267
|
+
)
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
class ApplyPointwiseFunction(ApplyMethod):
|
|
271
|
+
def __init__(
|
|
272
|
+
self,
|
|
273
|
+
function: Annotated[Callable[[np.ndarray], np.ndarray], Example('lambda p: p * 1.5')],
|
|
274
|
+
mobject: Mobject,
|
|
275
|
+
run_time: Duration = 3.0,
|
|
276
|
+
**kwargs
|
|
277
|
+
):
|
|
278
|
+
super().__init__(mobject.apply_function, function, run_time=run_time, **kwargs)
|
|
279
|
+
|
|
280
|
+
editor_thumbnail = (
|
|
281
|
+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 24">'
|
|
282
|
+
'<path d="M12.3 7.8Q8.1 7.8 3.9 7.8Q3.9 12.0 3.9 16.2Q8.1 16.2 12.3 16.2Q12.3 12.0 12.3 7.8Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
283
|
+
'<path d="M29.3 6.7Q24.0 6.7 18.7 6.7Q18.7 12.0 18.7 17.3Q24.0 17.3 29.3 17.3Q29.3 12.0 29.3 6.7Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
284
|
+
'<path d="M46.0 5.9Q39.9 5.9 33.8 5.9Q33.8 12.0 33.8 18.1Q39.9 18.1 46.0 18.1Q46.0 12.0 46.0 5.9Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
285
|
+
'</svg>'
|
|
286
|
+
)
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
class ApplyPointwiseFunctionToCenter(Transform):
|
|
290
|
+
def __init__(
|
|
291
|
+
self,
|
|
292
|
+
function: Annotated[Callable[[np.ndarray], np.ndarray], Example('lambda p: p + UP')],
|
|
293
|
+
mobject: Mobject,
|
|
294
|
+
**kwargs
|
|
295
|
+
):
|
|
296
|
+
self.function = function
|
|
297
|
+
super().__init__(mobject, **kwargs)
|
|
298
|
+
|
|
299
|
+
def create_target(self) -> Mobject:
|
|
300
|
+
return self.mobject.copy().move_to(self.function(self.mobject.get_center()))
|
|
301
|
+
|
|
302
|
+
editor_thumbnail = (
|
|
303
|
+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 24">'
|
|
304
|
+
'<g opacity="0.18">'
|
|
305
|
+
'<path d="M30.2 9.7Q24.0 9.7 17.8 9.7Q17.8 15.8 17.8 22.0Q24.0 22.0 30.2 22.0Q30.2 15.8 30.2 9.7Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
306
|
+
'</g>'
|
|
307
|
+
'<g opacity="0.32">'
|
|
308
|
+
'<path d="M30.2 7.9Q24.0 7.9 17.8 7.9Q17.8 14.0 17.8 20.2Q24.0 20.2 30.2 20.2Q30.2 14.0 30.2 7.9Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
309
|
+
'</g>'
|
|
310
|
+
'<g opacity="0.55">'
|
|
311
|
+
'<path d="M30.2 3.3Q24.0 3.3 17.8 3.3Q17.8 9.4 17.8 15.6Q24.0 15.6 30.2 15.6Q30.2 9.4 30.2 3.3Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
312
|
+
'</g>'
|
|
313
|
+
'<path d="M30.2 2.0Q24.0 2.0 17.8 2.0Q17.8 8.2 17.8 14.3Q24.0 14.3 30.2 14.3Q30.2 8.2 30.2 2.0Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
314
|
+
'</svg>'
|
|
315
|
+
)
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
class FadeToColor(ApplyMethod):
|
|
319
|
+
def __init__(
|
|
320
|
+
self,
|
|
321
|
+
mobject: Mobject,
|
|
322
|
+
color: Annotated[ManimColor, Example('YELLOW')],
|
|
323
|
+
**kwargs
|
|
324
|
+
):
|
|
325
|
+
super().__init__(mobject.set_color, color, **kwargs)
|
|
326
|
+
|
|
327
|
+
editor_thumbnail = (
|
|
328
|
+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 24">'
|
|
329
|
+
'<path d="M14.2 5.9Q8.1 5.9 2.0 5.9Q2.0 12.0 2.0 18.1Q8.1 18.1 14.2 18.1Q14.2 12.0 14.2 5.9Z" fill="#62C7D0" fill-opacity="0.60" stroke="#CAEAE3" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
330
|
+
'<path d="M30.1 5.9Q24.0 5.9 17.9 5.9Q17.9 12.0 17.9 18.1Q24.0 18.1 30.1 18.1Q30.1 12.0 30.1 5.9Z" fill="#BBE75A" fill-opacity="0.60" stroke="#E8F662" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
331
|
+
'<path d="M46.0 5.9Q39.9 5.9 33.8 5.9Q33.8 12.0 33.8 18.1Q39.9 18.1 46.0 18.1Q46.0 12.0 46.0 5.9Z" fill="#FFFF00" fill-opacity="0.60" stroke="#FFFF00" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
332
|
+
'</svg>'
|
|
333
|
+
)
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
class ScaleInPlace(ApplyMethod):
|
|
337
|
+
def __init__(
|
|
338
|
+
self,
|
|
339
|
+
mobject: Mobject,
|
|
340
|
+
scale_factor: Annotated[Annotated[float, Range(0.1, 4.0, 0.05)], Example('1.5')],
|
|
341
|
+
**kwargs
|
|
342
|
+
):
|
|
343
|
+
super().__init__(mobject.scale, scale_factor, **kwargs)
|
|
344
|
+
|
|
345
|
+
editor_thumbnail = (
|
|
346
|
+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 24">'
|
|
347
|
+
'<path d="M12.3 7.8Q8.1 7.8 3.9 7.8Q3.9 12.0 3.9 16.2Q8.1 16.2 12.3 16.2Q12.3 12.0 12.3 7.8Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
348
|
+
'<path d="M29.3 6.7Q24.0 6.7 18.7 6.7Q18.7 12.0 18.7 17.3Q24.0 17.3 29.3 17.3Q29.3 12.0 29.3 6.7Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
349
|
+
'<path d="M46.0 5.9Q39.9 5.9 33.8 5.9Q33.8 12.0 33.8 18.1Q39.9 18.1 46.0 18.1Q46.0 12.0 46.0 5.9Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
350
|
+
'</svg>'
|
|
351
|
+
)
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
class ShrinkToCenter(ScaleInPlace):
|
|
355
|
+
def __init__(self, mobject: Mobject, **kwargs):
|
|
356
|
+
super().__init__(mobject, 0, **kwargs)
|
|
357
|
+
|
|
358
|
+
editor_thumbnail = (
|
|
359
|
+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 24">'
|
|
360
|
+
'<path d="M14.2 5.9Q8.1 5.9 2.0 5.9Q2.0 12.0 2.0 18.1Q8.1 18.1 14.2 18.1Q14.2 12.0 14.2 5.9Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
361
|
+
'<path d="M26.6 9.4Q24.0 9.4 21.4 9.4Q21.4 12.0 21.4 14.6Q24.0 14.6 26.6 14.6Q26.6 12.0 26.6 9.4Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
362
|
+
'<path d="M39.9 12.0Q39.9 12.0 39.9 12.0Q39.9 12.0 39.9 12.0Q39.9 12.0 39.9 12.0Q39.9 12.0 39.9 12.0Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
363
|
+
'</svg>'
|
|
364
|
+
)
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
class Restore(Transform):
|
|
368
|
+
def __init__(self, mobject: Mobject, **kwargs):
|
|
369
|
+
if not hasattr(mobject, "saved_state") or mobject.saved_state is None:
|
|
370
|
+
raise Exception("Trying to restore without having saved")
|
|
371
|
+
super().__init__(mobject, mobject.saved_state, **kwargs)
|
|
372
|
+
|
|
373
|
+
editor_thumbnail = (
|
|
374
|
+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">'
|
|
375
|
+
'<rect x="8.5" y="8.5" width="7" height="7" rx="1" fill="#58C4DD"/>'
|
|
376
|
+
'<path d="M5 15A7.5 7.5 0 1 0 6.2 7.2" stroke="#DDDDDD" stroke-width="1.4" fill="none" stroke-linecap="round" stroke-linejoin="round"/>'
|
|
377
|
+
'<path d="M5.4 6L8.4 6L6.9 8.6Z" fill="#DDDDDD"/>'
|
|
378
|
+
'</svg>'
|
|
379
|
+
)
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
class ApplyFunction(Transform):
|
|
383
|
+
def __init__(
|
|
384
|
+
self,
|
|
385
|
+
function: Annotated[Callable[[Mobject], Mobject], Example('lambda m: m.shift(UP)')],
|
|
386
|
+
mobject: Mobject,
|
|
387
|
+
**kwargs
|
|
388
|
+
):
|
|
389
|
+
self.function = function
|
|
390
|
+
super().__init__(mobject, **kwargs)
|
|
391
|
+
|
|
392
|
+
def create_target(self) -> Mobject:
|
|
393
|
+
target = self.function(self.mobject.copy())
|
|
394
|
+
if not isinstance(target, Mobject):
|
|
395
|
+
raise Exception("Functions passed to ApplyFunction must return object of type Mobject")
|
|
396
|
+
return target
|
|
397
|
+
|
|
398
|
+
editor_thumbnail = (
|
|
399
|
+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 24">'
|
|
400
|
+
'<g opacity="0.18">'
|
|
401
|
+
'<path d="M30.2 9.7Q24.0 9.7 17.8 9.7Q17.8 15.8 17.8 22.0Q24.0 22.0 30.2 22.0Q30.2 15.8 30.2 9.7Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
402
|
+
'</g>'
|
|
403
|
+
'<g opacity="0.32">'
|
|
404
|
+
'<path d="M30.2 7.9Q24.0 7.9 17.8 7.9Q17.8 14.0 17.8 20.2Q24.0 20.2 30.2 20.2Q30.2 14.0 30.2 7.9Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
405
|
+
'</g>'
|
|
406
|
+
'<g opacity="0.55">'
|
|
407
|
+
'<path d="M30.2 3.3Q24.0 3.3 17.8 3.3Q17.8 9.4 17.8 15.6Q24.0 15.6 30.2 15.6Q30.2 9.4 30.2 3.3Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
408
|
+
'</g>'
|
|
409
|
+
'<path d="M30.2 2.0Q24.0 2.0 17.8 2.0Q17.8 8.2 17.8 14.3Q24.0 14.3 30.2 14.3Q30.2 8.2 30.2 2.0Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
410
|
+
'</svg>'
|
|
411
|
+
)
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
class ApplyMatrix(ApplyPointwiseFunction):
|
|
415
|
+
def __init__(
|
|
416
|
+
self,
|
|
417
|
+
matrix: Annotated[npt.ArrayLike, Example('[[0, -1], [1, 0]]')],
|
|
418
|
+
mobject: Mobject,
|
|
419
|
+
**kwargs
|
|
420
|
+
):
|
|
421
|
+
matrix = self.initialize_matrix(matrix)
|
|
422
|
+
|
|
423
|
+
def func(p):
|
|
424
|
+
return np.dot(p, matrix.T)
|
|
425
|
+
|
|
426
|
+
super().__init__(func, mobject, **kwargs)
|
|
427
|
+
|
|
428
|
+
def initialize_matrix(self, matrix: npt.ArrayLike) -> np.ndarray:
|
|
429
|
+
matrix = np.array(matrix)
|
|
430
|
+
if matrix.shape == (2, 2):
|
|
431
|
+
new_matrix = np.identity(3)
|
|
432
|
+
new_matrix[:2, :2] = matrix
|
|
433
|
+
matrix = new_matrix
|
|
434
|
+
elif matrix.shape != (3, 3):
|
|
435
|
+
raise Exception("Matrix has bad dimensions")
|
|
436
|
+
return matrix
|
|
437
|
+
|
|
438
|
+
editor_thumbnail = (
|
|
439
|
+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 24">'
|
|
440
|
+
'<path d="M13.5 5.9Q7.8 6.2 2.0 6.6Q2.4 12.4 2.7 18.1Q8.5 17.8 14.2 17.4Q13.9 11.6 13.5 5.9Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
441
|
+
'<path d="M22.9 5.9Q20.4 9.5 17.9 13.1Q21.5 15.6 25.1 18.1Q27.6 14.5 30.1 10.9Q26.5 8.4 22.9 5.9Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
442
|
+
'<path d="M33.8 5.9Q33.8 12.0 33.8 18.1Q39.9 18.1 46.0 18.1Q46.0 12.0 46.0 5.9Q39.9 5.9 33.8 5.9Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
443
|
+
'</svg>'
|
|
444
|
+
)
|
|
445
|
+
|
|
446
|
+
|
|
447
|
+
class ApplyComplexFunction(ApplyMethod):
|
|
448
|
+
def __init__(
|
|
449
|
+
self,
|
|
450
|
+
function: Annotated[Callable[[complex], complex], Example('lambda z: z ** 2')],
|
|
451
|
+
mobject: Mobject,
|
|
452
|
+
**kwargs
|
|
453
|
+
):
|
|
454
|
+
self.function = function
|
|
455
|
+
method = mobject.apply_complex_function
|
|
456
|
+
super().__init__(method, function, **kwargs)
|
|
457
|
+
|
|
458
|
+
def init_path_func(self) -> None:
|
|
459
|
+
func1 = self.function(complex(1))
|
|
460
|
+
self.path_arc = np.log(func1).imag
|
|
461
|
+
super().init_path_func()
|
|
462
|
+
|
|
463
|
+
editor_thumbnail = (
|
|
464
|
+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 24">'
|
|
465
|
+
'<path d="M14.1 5.5Q7.9 6.1 2.3 6.7Q2.6 12.0 2.3 17.3Q7.9 17.9 14.1 18.5Q14.3 12.0 14.1 5.5Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
466
|
+
'<path d="M26.4 3.5Q20.9 9.5 21.3 15.4Q24.3 12.0 21.3 8.6Q20.9 14.5 26.4 20.5Q29.4 12.0 26.4 3.5Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
467
|
+
'<path d="M39.5 2.0Q34.5 12.0 39.5 22.0Q44.5 12.0 39.5 2.0Q34.5 12.0 39.5 22.0Q44.5 12.0 39.5 2.0Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
468
|
+
'</svg>'
|
|
469
|
+
)
|
|
470
|
+
|
|
471
|
+
###
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
class CyclicReplace(Transform):
|
|
475
|
+
def __init__(self, *mobjects: Mobject, path_arc: Angle = 90 * DEG, **kwargs):
|
|
476
|
+
super().__init__(Group(*mobjects), path_arc=path_arc, **kwargs)
|
|
477
|
+
|
|
478
|
+
def create_target(self) -> Mobject:
|
|
479
|
+
group = self.mobject
|
|
480
|
+
target = group.copy()
|
|
481
|
+
cycled_targets = [target[-1], *target[:-1]]
|
|
482
|
+
for m1, m2 in zip(cycled_targets, group):
|
|
483
|
+
m1.move_to(m2)
|
|
484
|
+
return target
|
|
485
|
+
|
|
486
|
+
editor_thumbnail = (
|
|
487
|
+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 24">'
|
|
488
|
+
'<path d="M14.2 5.9Q8.1 5.9 2.0 5.9Q2.0 12.0 2.0 18.1Q8.1 18.1 14.2 18.1Q14.2 12.0 14.2 5.9Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
489
|
+
'<path d="M30.1 5.9Q24.0 5.9 17.9 5.9Q17.9 12.0 17.9 18.1Q24.0 18.1 30.1 18.1Q30.1 12.0 30.1 5.9Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
490
|
+
'<path d="M46.0 5.9Q39.9 5.9 33.8 5.9Q33.8 12.0 33.8 18.1Q39.9 18.1 46.0 18.1Q46.0 12.0 46.0 5.9Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
491
|
+
'</svg>'
|
|
492
|
+
)
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
class Swap(CyclicReplace):
|
|
496
|
+
"""Alternate name for CyclicReplace"""
|
|
497
|
+
pass
|
|
498
|
+
|
|
499
|
+
editor_thumbnail = (
|
|
500
|
+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 24">'
|
|
501
|
+
'<path d="M14.2 5.9Q8.1 5.9 2.0 5.9Q2.0 12.0 2.0 18.1Q8.1 18.1 14.2 18.1Q14.2 12.0 14.2 5.9Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
502
|
+
'<path d="M30.1 5.9Q24.0 5.9 17.9 5.9Q17.9 12.0 17.9 18.1Q24.0 18.1 30.1 18.1Q30.1 12.0 30.1 5.9Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
503
|
+
'<path d="M46.0 5.9Q39.9 5.9 33.8 5.9Q33.8 12.0 33.8 18.1Q39.9 18.1 46.0 18.1Q46.0 12.0 46.0 5.9Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
|
|
504
|
+
'</svg>'
|
|
505
|
+
)
|