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.
Files changed (193) hide show
  1. datacut/__init__.py +121 -0
  2. datacut/__main__.py +122 -0
  3. datacut/animation/__init__.py +0 -0
  4. datacut/animation/animation.py +336 -0
  5. datacut/animation/composition.py +258 -0
  6. datacut/animation/creation.py +315 -0
  7. datacut/animation/fading.py +328 -0
  8. datacut/animation/growing.py +90 -0
  9. datacut/animation/indication.py +608 -0
  10. datacut/animation/movement.py +165 -0
  11. datacut/animation/numbers.py +92 -0
  12. datacut/animation/physics.py +453 -0
  13. datacut/animation/rotation.py +95 -0
  14. datacut/animation/specialized.py +956 -0
  15. datacut/animation/transform.py +505 -0
  16. datacut/animation/transform_matching_parts.py +343 -0
  17. datacut/animation/update.py +95 -0
  18. datacut/camera/__init__.py +0 -0
  19. datacut/camera/camera.py +795 -0
  20. datacut/camera/camera_frame.py +320 -0
  21. datacut/camera/cinematography.py +1166 -0
  22. datacut/config.py +479 -0
  23. datacut/constants.py +160 -0
  24. datacut/css/__init__.py +189 -0
  25. datacut/css/easing.py +328 -0
  26. datacut/css/engine.py +1727 -0
  27. datacut/css/gradients.py +678 -0
  28. datacut/css/motion.py +1615 -0
  29. datacut/css/parser.py +741 -0
  30. datacut/css/presets.py +143 -0
  31. datacut/css/shader_fill.py +703 -0
  32. datacut/css/values.py +650 -0
  33. datacut/default_config.yml +224 -0
  34. datacut/event_handler/__init__.py +6 -0
  35. datacut/event_handler/event_dispatcher.py +161 -0
  36. datacut/event_handler/event_listner.py +31 -0
  37. datacut/event_handler/event_type.py +11 -0
  38. datacut/event_handler/picking.py +111 -0
  39. datacut/event_keys.py +53 -0
  40. datacut/extract_scene.py +200 -0
  41. datacut/layout/__init__.py +39 -0
  42. datacut/layout/components.py +425 -0
  43. datacut/layout/containers.py +1520 -0
  44. datacut/logger.py +13 -0
  45. datacut/mobject/__init__.py +0 -0
  46. datacut/mobject/boolean_ops.py +168 -0
  47. datacut/mobject/changing.py +209 -0
  48. datacut/mobject/coordinate_systems.py +1056 -0
  49. datacut/mobject/fractals.py +348 -0
  50. datacut/mobject/frame.py +80 -0
  51. datacut/mobject/functions.py +147 -0
  52. datacut/mobject/geometry.py +1834 -0
  53. datacut/mobject/gltf.py +243 -0
  54. datacut/mobject/interactive.py +906 -0
  55. datacut/mobject/lights.py +366 -0
  56. datacut/mobject/materials.py +207 -0
  57. datacut/mobject/matrix.py +570 -0
  58. datacut/mobject/mesh3d.py +2288 -0
  59. datacut/mobject/mobject.py +2885 -0
  60. datacut/mobject/mobject_update_utils.py +123 -0
  61. datacut/mobject/model.py +543 -0
  62. datacut/mobject/number_line.py +517 -0
  63. datacut/mobject/numbers.py +441 -0
  64. datacut/mobject/probability.py +536 -0
  65. datacut/mobject/shape_matchers.py +161 -0
  66. datacut/mobject/subtitles.py +260 -0
  67. datacut/mobject/svg/__init__.py +0 -0
  68. datacut/mobject/svg/brace.py +356 -0
  69. datacut/mobject/svg/drawings.py +1041 -0
  70. datacut/mobject/svg/old_tex_mobject.py +335 -0
  71. datacut/mobject/svg/path_cache.py +155 -0
  72. datacut/mobject/svg/special_tex.py +216 -0
  73. datacut/mobject/svg/string_mobject.py +622 -0
  74. datacut/mobject/svg/svg_mobject.py +657 -0
  75. datacut/mobject/svg/svg_parse.py +437 -0
  76. datacut/mobject/svg/tex_mobject.py +499 -0
  77. datacut/mobject/svg/text_mobject.py +702 -0
  78. datacut/mobject/svg/typst_mobject.py +864 -0
  79. datacut/mobject/three_dimensions.py +686 -0
  80. datacut/mobject/types/__init__.py +0 -0
  81. datacut/mobject/types/dot_cloud.py +220 -0
  82. datacut/mobject/types/image_mobject.py +130 -0
  83. datacut/mobject/types/point_cloud_mobject.py +138 -0
  84. datacut/mobject/types/shader_mobject.py +268 -0
  85. datacut/mobject/types/surface.py +848 -0
  86. datacut/mobject/types/vectorized_mobject.py +1749 -0
  87. datacut/mobject/types/video_mobject.py +3902 -0
  88. datacut/mobject/value_tracker.py +110 -0
  89. datacut/mobject/vector_field.py +585 -0
  90. datacut/module_loader.py +176 -0
  91. datacut/reactive/__init__.py +25 -0
  92. datacut/reactive/signals.py +610 -0
  93. datacut/renderer/__init__.py +4 -0
  94. datacut/renderer/drawing.py +1066 -0
  95. datacut/renderer/gpu.py +800 -0
  96. datacut/renderer/material.py +88 -0
  97. datacut/renderer/pipeline.py +179 -0
  98. datacut/renderer/post_process.py +577 -0
  99. datacut/renderer/renderer.py +1285 -0
  100. datacut/renderer/shader_source.py +146 -0
  101. datacut/renderer/shared_buffer.py +185 -0
  102. datacut/renderer/texture.py +217 -0
  103. datacut/renderer/uniform_block.py +118 -0
  104. datacut/scene/__init__.py +0 -0
  105. datacut/scene/incremental.py +233 -0
  106. datacut/scene/interactive_scene.py +758 -0
  107. datacut/scene/performance.py +226 -0
  108. datacut/scene/presentation_scene.py +783 -0
  109. datacut/scene/recording.py +541 -0
  110. datacut/scene/safe_zones.py +323 -0
  111. datacut/scene/scene.py +2849 -0
  112. datacut/scene/scene_embed.py +277 -0
  113. datacut/scene/scene_file_writer.py +1014 -0
  114. datacut/scene/scene_task.py +183 -0
  115. datacut/scene/sfx.py +164 -0
  116. datacut/scene/sound.py +702 -0
  117. datacut/scene/sound_clip.py +580 -0
  118. datacut/scene/timeline.py +1689 -0
  119. datacut/scene/transcript.py +503 -0
  120. datacut/shaders/fill.wgsl +107 -0
  121. datacut/shaders/fill_depth.wgsl +198 -0
  122. datacut/shaders/image.wgsl +25 -0
  123. datacut/shaders/inserts/NOTE.md +16 -0
  124. datacut/shaders/inserts/clip_test.wgsl +14 -0
  125. datacut/shaders/inserts/complex_functions.wgsl +20 -0
  126. datacut/shaders/inserts/fill_color.wgsl +10 -0
  127. datacut/shaders/inserts/finalize_color.wgsl +44 -0
  128. datacut/shaders/inserts/frame_uniforms.wgsl +37 -0
  129. datacut/shaders/inserts/frame_units.wgsl +18 -0
  130. datacut/shaders/inserts/image_quad.wgsl +28 -0
  131. datacut/shaders/inserts/mobject_uniforms.wgsl +11 -0
  132. datacut/shaders/inserts/project_point.wgsl +44 -0
  133. datacut/shaders/inserts/quad_corners.wgsl +12 -0
  134. datacut/shaders/inserts/read_data.wgsl +33 -0
  135. datacut/shaders/inserts/surface_mesh.wgsl +106 -0
  136. datacut/shaders/mandelbrot_fractal.wgsl +100 -0
  137. datacut/shaders/mesh.wgsl +474 -0
  138. datacut/shaders/newton_fractal.wgsl +200 -0
  139. datacut/shaders/present.wgsl +62 -0
  140. datacut/shaders/stroke.wgsl +1141 -0
  141. datacut/shaders/stroke_depth.wgsl +1136 -0
  142. datacut/shaders/surface.wgsl +40 -0
  143. datacut/shaders/textured_surface.wgsl +59 -0
  144. datacut/shaders/true_dot.wgsl +78 -0
  145. datacut/shaders/video.wgsl +42 -0
  146. datacut/tex_templates.yml +736 -0
  147. datacut/transcribe.py +32 -0
  148. datacut/typing.py +412 -0
  149. datacut/utils/__init__.py +0 -0
  150. datacut/utils/bezier.py +467 -0
  151. datacut/utils/browser_audio.py +423 -0
  152. datacut/utils/browser_code_transform.py +1293 -0
  153. datacut/utils/browser_completions.py +2255 -0
  154. datacut/utils/browser_fonts.py +143 -0
  155. datacut/utils/browser_pathops.py +47 -0
  156. datacut/utils/browser_scheduler.py +18 -0
  157. datacut/utils/browser_typst.py +82 -0
  158. datacut/utils/cache.py +34 -0
  159. datacut/utils/cinematic_vfx.py +779 -0
  160. datacut/utils/color.py +203 -0
  161. datacut/utils/debug.py +46 -0
  162. datacut/utils/dict_ops.py +22 -0
  163. datacut/utils/directories.py +55 -0
  164. datacut/utils/editor_signatures.py +1806 -0
  165. datacut/utils/editor_thumbnails.py +769 -0
  166. datacut/utils/family_ops.py +48 -0
  167. datacut/utils/file_ops.py +65 -0
  168. datacut/utils/images.py +52 -0
  169. datacut/utils/iterables.py +216 -0
  170. datacut/utils/native.py +280 -0
  171. datacut/utils/paths.py +83 -0
  172. datacut/utils/rate_functions.py +154 -0
  173. datacut/utils/render_geometry.py +186 -0
  174. datacut/utils/simple_functions.py +99 -0
  175. datacut/utils/sounds.py +43 -0
  176. datacut/utils/space_ops.py +460 -0
  177. datacut/utils/structured_array.py +256 -0
  178. datacut/utils/svg_export.py +102 -0
  179. datacut/utils/tex.py +139 -0
  180. datacut/utils/tex_file_writing.py +164 -0
  181. datacut/utils/tex_to_symbol_count.py +186 -0
  182. datacut/utils/typst_file_writing.py +205 -0
  183. datacut/utils/vfx_presets.py +4543 -0
  184. datacut/utils/visual_css.py +737 -0
  185. datacut/utils/visual_editor.py +4292 -0
  186. datacut/utils/window_audio.py +760 -0
  187. datacut/window.py +910 -0
  188. datacut-0.1.0.dist-info/METADATA +226 -0
  189. datacut-0.1.0.dist-info/RECORD +193 -0
  190. datacut-0.1.0.dist-info/WHEEL +5 -0
  191. datacut-0.1.0.dist-info/entry_points.txt +2 -0
  192. datacut-0.1.0.dist-info/licenses/LICENSE.md +21 -0
  193. datacut-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,328 @@
1
+ from __future__ import annotations
2
+
3
+ # What the Visual Editor files this module's classes under
4
+ __editor_category__ = 'Fading'
5
+
6
+ import numpy as np
7
+
8
+ from datacut.animation.animation import Animation
9
+ from datacut.animation.transform import Transform
10
+ from datacut.constants import ORIGIN
11
+ from datacut.mobject.types.vectorized_mobject import VMobject
12
+ from datacut.mobject.mobject import Group
13
+ from datacut.utils.bezier import interpolate
14
+ from datacut.utils.rate_functions import there_and_back
15
+
16
+ from typing import TYPE_CHECKING
17
+
18
+ if TYPE_CHECKING:
19
+ from datacut.typing import Annotated, Example
20
+ from datacut.typing import RateFunction
21
+ from typing import Callable
22
+ from datacut.mobject.mobject import Mobject
23
+ from datacut.scene.scene import Scene
24
+ from datacut.typing import Vect3
25
+
26
+
27
+ class Fade(Transform):
28
+ def __init__(
29
+ self,
30
+ mobject: Mobject,
31
+ shift: Vect3 = ORIGIN,
32
+ scale: float = 1,
33
+ **kwargs
34
+ ):
35
+ self.shift_vect = shift
36
+ self.scale_factor = scale
37
+ super().__init__(mobject, **kwargs)
38
+
39
+ editor_thumbnail = (
40
+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">'
41
+ '<rect x="2" y="8" width="6" height="8" rx="1" fill="#58C4DD" fill-opacity="1.0"/>'
42
+ '<rect x="9" y="8" width="6" height="8" rx="1" fill="#58C4DD" fill-opacity="0.5"/>'
43
+ '<rect x="16" y="8" width="6" height="8" rx="1" fill="#58C4DD" fill-opacity="0.18"/>'
44
+ '</svg>'
45
+ )
46
+
47
+
48
+ class FadeIn(Fade):
49
+ def create_target(self) -> Mobject:
50
+ return self.mobject.copy()
51
+
52
+ def create_starting_mobject(self) -> Mobject:
53
+ start = super().create_starting_mobject()
54
+ start.set_opacity(0)
55
+ start.scale(1.0 / self.scale_factor)
56
+ start.shift(-self.shift_vect)
57
+ return start
58
+
59
+ editor_thumbnail = (
60
+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 24">'
61
+ '<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.03" stroke="#C7E9F1" stroke-opacity="0.06" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
62
+ '<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.36" stroke="#C7E9F1" stroke-opacity="0.59" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
63
+ '<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"/>'
64
+ '</svg>'
65
+ )
66
+
67
+
68
+ class FadeOut(Fade):
69
+ def __init__(
70
+ self,
71
+ mobject: Mobject,
72
+ shift: Vect3 = ORIGIN,
73
+ remover: bool = True,
74
+ final_alpha_value: float = 0.0, # Put it back in original state when done,
75
+ **kwargs
76
+ ):
77
+ super().__init__(
78
+ mobject, shift,
79
+ remover=remover,
80
+ final_alpha_value=final_alpha_value,
81
+ **kwargs
82
+ )
83
+
84
+ def create_target(self) -> Mobject:
85
+ result = self.mobject.copy()
86
+ result.set_opacity(0)
87
+ result.shift(self.shift_vect)
88
+ result.scale(self.scale_factor)
89
+ return result
90
+
91
+ editor_thumbnail = (
92
+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 24">'
93
+ '<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.57" stroke="#C7E9F1" stroke-opacity="0.94" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
94
+ '<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.24" stroke="#C7E9F1" stroke-opacity="0.41" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
95
+ '<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="none" stroke="#58C4DD" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
96
+ '</svg>'
97
+ )
98
+
99
+
100
+ class FadeInFromPoint(FadeIn):
101
+ def __init__(self, mobject: Mobject, point: Annotated[Vect3, Example('ORIGIN')], **kwargs):
102
+ super().__init__(
103
+ mobject,
104
+ shift=mobject.get_center() - point,
105
+ scale=np.inf,
106
+ **kwargs,
107
+ )
108
+
109
+ editor_thumbnail = (
110
+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 24">'
111
+ '<path d="M8.5 11.6Q8.1 11.6 7.8 11.6Q7.8 12.0 7.8 12.4Q8.1 12.4 8.5 12.4Q8.5 12.0 8.5 11.6Z" fill="#58C4DD" fill-opacity="0.03" stroke="#C7E9F1" stroke-opacity="0.06" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
112
+ '<path d="M27.6 8.4Q24.0 8.4 20.4 8.4Q20.4 12.0 20.4 15.6Q24.0 15.6 27.6 15.6Q27.6 12.0 27.6 8.4Z" fill="#58C4DD" fill-opacity="0.36" stroke="#C7E9F1" stroke-opacity="0.59" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
113
+ '<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"/>'
114
+ '</svg>'
115
+ )
116
+
117
+
118
+ class FadeOutToPoint(FadeOut):
119
+ def __init__(self, mobject: Mobject, point: Annotated[Vect3, Example('ORIGIN')], **kwargs):
120
+ super().__init__(
121
+ mobject,
122
+ shift=point - mobject.get_center(),
123
+ scale=0,
124
+ **kwargs,
125
+ )
126
+
127
+ editor_thumbnail = (
128
+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 24">'
129
+ '<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.57" stroke="#C7E9F1" stroke-opacity="0.94" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
130
+ '<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.24" stroke="#C7E9F1" stroke-opacity="0.41" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
131
+ '<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="none" stroke="#58C4DD" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
132
+ '</svg>'
133
+ )
134
+
135
+
136
+ class FadeTransform(Transform):
137
+ def __init__(
138
+ self,
139
+ mobject: Mobject,
140
+ target_mobject: Mobject,
141
+ stretch: bool = True,
142
+ dim_to_match: int = 1,
143
+ **kwargs
144
+ ):
145
+ self.to_add_on_completion = target_mobject
146
+ self.stretch = stretch
147
+ self.dim_to_match = dim_to_match
148
+
149
+ mobject.save_state()
150
+ super().__init__(Group(mobject, target_mobject.copy()), **kwargs)
151
+
152
+ def begin(self) -> None:
153
+ self.ending_mobject = self.mobject.copy()
154
+ Animation.begin(self)
155
+ # Both 'start' and 'end' consists of the source and target mobjects.
156
+ # At the start, the traget should be faded replacing the source,
157
+ # and at the end it should be the other way around.
158
+ start, end = self.starting_mobject, self.ending_mobject
159
+ for m0, m1 in ((start[1], start[0]), (end[0], end[1])):
160
+ self.ghost_to(m0, m1)
161
+ # The two ends only became what they are here, so what a blend between them comes to
162
+ # has to be settled again, having been settled over what they held a moment ago
163
+ self.prepare_interpolation()
164
+
165
+ def ghost_to(self, source: Mobject, target: Mobject) -> None:
166
+ source.replace(target, stretch=self.stretch, dim_to_match=self.dim_to_match)
167
+ source.set_uniform(**target.get_uniforms())
168
+ source.set_opacity(0)
169
+
170
+ def get_all_mobjects(self) -> list[Mobject]:
171
+ return [
172
+ self.mobject,
173
+ self.starting_mobject,
174
+ self.ending_mobject,
175
+ ]
176
+
177
+ def get_all_families_zipped(self) -> zip[tuple[Mobject]]:
178
+ return Animation.get_all_families_zipped(self)
179
+
180
+ def get_interpolation_ends(self) -> tuple[Mobject, Mobject]:
181
+ # Its own pair rather than Transform's, this one never having made a target_copy
182
+ return self.starting_mobject, self.ending_mobject
183
+
184
+ def clean_up_from_scene(self, scene: Scene) -> None:
185
+ Animation.clean_up_from_scene(self, scene)
186
+ scene.remove(self.mobject)
187
+ self.mobject[0].restore()
188
+ if not self.remover:
189
+ scene.add(self.to_add_on_completion)
190
+
191
+ editor_thumbnail = (
192
+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 24">'
193
+ '<g opacity="0.18">'
194
+ '<path d="M22.3 3.1Q13.4 3.1 4.6 3.1Q4.6 12.0 4.6 20.9Q13.4 20.9 22.3 20.9Q22.3 12.0 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"/>'
195
+ '<path d="M22.3 12.0Q22.3 10.2 21.7 8.6Q21.0 7.0 19.7 5.7Q18.5 4.5 16.8 3.8Q15.2 3.1 13.4 3.1Q11.7 3.1 10.0 3.8Q8.4 4.5 7.2 5.7Q5.9 7.0 5.2 8.6Q4.6 10.2 4.6 12.0Q4.6 13.8 5.2 15.4Q5.9 17.0 7.2 18.3Q8.4 19.5 10.0 20.2Q11.7 20.9 13.4 20.9Q15.2 20.9 16.8 20.2Q18.5 19.5 19.7 18.3Q21.0 17.0 21.7 15.4Q22.3 13.8 22.3 12.0Z" fill="none" stroke="#58C4DD" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
196
+ '</g>'
197
+ '<g opacity="0.32">'
198
+ '<path d="M27.3 2.8Q18.1 2.8 9.0 2.8Q9.0 12.0 9.0 21.2Q18.1 21.2 27.3 21.2Q27.3 12.0 27.3 2.8Z" fill="#7FD2A9" fill-opacity="0.46" stroke="#C7E9F1" stroke-opacity="0.76" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
199
+ '<path d="M27.3 12.0Q27.3 10.2 26.6 8.5Q25.9 6.8 24.6 5.5Q23.3 4.2 21.6 3.5Q20.0 2.8 18.1 2.8Q16.3 2.8 14.6 3.5Q13.0 4.2 11.7 5.5Q10.4 6.8 9.7 8.5Q9.0 10.2 9.0 12.0Q9.0 13.8 9.7 15.5Q10.4 17.2 11.7 18.5Q13.0 19.8 14.6 20.5Q16.3 21.2 18.1 21.2Q20.0 21.2 21.6 20.5Q23.3 19.8 24.6 18.5Q25.9 17.2 26.6 15.5Q27.3 13.8 27.3 12.0Z" fill="#7FD2A9" fill-opacity="0.14" stroke="#FFF1B6" stroke-opacity="0.24" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
200
+ '</g>'
201
+ '<g opacity="0.55">'
202
+ '<path d="M40.0 2.2Q30.2 2.2 20.4 2.2Q20.4 12.0 20.4 21.8Q30.2 21.8 40.0 21.8Q40.0 12.0 40.0 2.2Z" fill="#E4F524" fill-opacity="0.10" stroke="#C7E9F1" stroke-opacity="0.16" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
203
+ '<path d="M40.0 12.0Q40.0 10.0 39.3 8.2Q38.5 6.4 37.1 5.1Q35.7 3.7 33.9 2.9Q32.1 2.2 30.2 2.2Q28.2 2.2 26.4 2.9Q24.6 3.7 23.2 5.1Q21.9 6.4 21.1 8.2Q20.4 10.0 20.4 12.0Q20.4 14.0 21.1 15.8Q21.9 17.6 23.2 18.9Q24.6 20.3 26.4 21.1Q28.2 21.8 30.2 21.8Q32.1 21.8 33.9 21.1Q35.7 20.3 37.1 18.9Q38.5 17.6 39.3 15.8Q40.0 14.0 40.0 12.0Z" fill="#E4F524" fill-opacity="0.50" stroke="#FFF1B6" stroke-opacity="0.84" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
204
+ '</g>'
205
+ '<path d="M43.4 2.0Q33.4 2.0 23.4 2.0Q23.4 12.0 23.4 22.0Q33.4 22.0 43.4 22.0Q43.4 12.0 43.4 2.0Z" fill="none" stroke="#FFFF00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
206
+ '<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"/>'
207
+ '</svg>'
208
+ )
209
+
210
+
211
+ class FadeTransformPieces(FadeTransform):
212
+ def begin(self) -> None:
213
+ self.mobject[0].align_family(self.mobject[1])
214
+ super().begin()
215
+
216
+ def ghost_to(self, source: Mobject, target: Mobject) -> None:
217
+ for sm0, sm1 in zip(source.get_family(), target.get_family()):
218
+ super().ghost_to(sm0, sm1)
219
+
220
+ editor_thumbnail = (
221
+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 24">'
222
+ '<g opacity="0.18">'
223
+ '<path d="M22.3 3.1Q13.4 3.1 4.6 3.1Q4.6 12.0 4.6 20.9Q13.4 20.9 22.3 20.9Q22.3 12.0 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"/>'
224
+ '<path d="M22.3 12.0Q22.3 10.2 21.7 8.6Q21.0 7.0 19.7 5.7Q18.5 4.5 16.8 3.8Q15.2 3.1 13.4 3.1Q11.7 3.1 10.0 3.8Q8.4 4.5 7.2 5.7Q5.9 7.0 5.2 8.6Q4.6 10.2 4.6 12.0Q4.6 13.8 5.2 15.4Q5.9 17.0 7.2 18.3Q8.4 19.5 10.0 20.2Q11.7 20.9 13.4 20.9Q15.2 20.9 16.8 20.2Q18.5 19.5 19.7 18.3Q21.0 17.0 21.7 15.4Q22.3 13.8 22.3 12.0Z" fill="none" stroke="#58C4DD" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
225
+ '</g>'
226
+ '<g opacity="0.32">'
227
+ '<path d="M27.3 2.8Q18.1 2.8 9.0 2.8Q9.0 12.0 9.0 21.2Q18.1 21.2 27.3 21.2Q27.3 12.0 27.3 2.8Z" fill="#7FD2A9" fill-opacity="0.46" stroke="#C7E9F1" stroke-opacity="0.76" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
228
+ '<path d="M27.3 12.0Q27.3 10.2 26.6 8.5Q25.9 6.8 24.6 5.5Q23.3 4.2 21.6 3.5Q20.0 2.8 18.1 2.8Q16.3 2.8 14.6 3.5Q13.0 4.2 11.7 5.5Q10.4 6.8 9.7 8.5Q9.0 10.2 9.0 12.0Q9.0 13.8 9.7 15.5Q10.4 17.2 11.7 18.5Q13.0 19.8 14.6 20.5Q16.3 21.2 18.1 21.2Q20.0 21.2 21.6 20.5Q23.3 19.8 24.6 18.5Q25.9 17.2 26.6 15.5Q27.3 13.8 27.3 12.0Z" fill="#7FD2A9" fill-opacity="0.14" stroke="#FFF1B6" stroke-opacity="0.24" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
229
+ '</g>'
230
+ '<g opacity="0.55">'
231
+ '<path d="M40.0 2.2Q30.2 2.2 20.4 2.2Q20.4 12.0 20.4 21.8Q30.2 21.8 40.0 21.8Q40.0 12.0 40.0 2.2Z" fill="#E4F524" fill-opacity="0.10" stroke="#C7E9F1" stroke-opacity="0.16" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
232
+ '<path d="M40.0 12.0Q40.0 10.0 39.3 8.2Q38.5 6.4 37.1 5.1Q35.7 3.7 33.9 2.9Q32.1 2.2 30.2 2.2Q28.2 2.2 26.4 2.9Q24.6 3.7 23.2 5.1Q21.9 6.4 21.1 8.2Q20.4 10.0 20.4 12.0Q20.4 14.0 21.1 15.8Q21.9 17.6 23.2 18.9Q24.6 20.3 26.4 21.1Q28.2 21.8 30.2 21.8Q32.1 21.8 33.9 21.1Q35.7 20.3 37.1 18.9Q38.5 17.6 39.3 15.8Q40.0 14.0 40.0 12.0Z" fill="#E4F524" fill-opacity="0.50" stroke="#FFF1B6" stroke-opacity="0.84" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
233
+ '</g>'
234
+ '<path d="M43.4 2.0Q33.4 2.0 23.4 2.0Q23.4 12.0 23.4 22.0Q33.4 22.0 43.4 22.0Q43.4 12.0 43.4 2.0Z" fill="none" stroke="#FFFF00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
235
+ '<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"/>'
236
+ '</svg>'
237
+ )
238
+
239
+
240
+ class VFadeIn(Animation):
241
+ """
242
+ VFadeIn and VFadeOut only work for VMobjects,
243
+ """
244
+ def __init__(self, vmobject: VMobject, suspend_mobject_updating: bool = False, **kwargs):
245
+ super().__init__(
246
+ vmobject,
247
+ suspend_mobject_updating=suspend_mobject_updating,
248
+ **kwargs
249
+ )
250
+
251
+ def interpolate_submobject(
252
+ self,
253
+ submob: VMobject,
254
+ start: VMobject,
255
+ alpha: float
256
+ ) -> None:
257
+ submob.set_stroke(
258
+ opacity=interpolate(0, start.get_stroke_opacity(), alpha)
259
+ )
260
+ submob.set_fill(
261
+ opacity=interpolate(0, start.get_fill_opacity(), alpha)
262
+ )
263
+
264
+ editor_thumbnail = (
265
+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 24">'
266
+ '<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.03" stroke="#C7E9F1" stroke-opacity="0.06" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
267
+ '<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.36" stroke="#C7E9F1" stroke-opacity="0.59" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
268
+ '<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"/>'
269
+ '</svg>'
270
+ )
271
+
272
+
273
+ class VFadeOut(VFadeIn):
274
+ def __init__(
275
+ self,
276
+ vmobject: VMobject,
277
+ remover: bool = True,
278
+ final_alpha_value: float = 0.0,
279
+ **kwargs
280
+ ):
281
+ super().__init__(
282
+ vmobject,
283
+ remover=remover,
284
+ final_alpha_value=final_alpha_value,
285
+ **kwargs
286
+ )
287
+
288
+ def interpolate_submobject(
289
+ self,
290
+ submob: VMobject,
291
+ start: VMobject,
292
+ alpha: float
293
+ ) -> None:
294
+ super().interpolate_submobject(submob, start, 1 - alpha)
295
+
296
+ editor_thumbnail = (
297
+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 24">'
298
+ '<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.57" stroke="#C7E9F1" stroke-opacity="0.94" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
299
+ '<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.24" stroke="#C7E9F1" stroke-opacity="0.41" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
300
+ '<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="none" stroke="#58C4DD" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
301
+ '</svg>'
302
+ )
303
+
304
+
305
+ class VFadeInThenOut(VFadeIn):
306
+ def __init__(
307
+ self,
308
+ vmobject: VMobject,
309
+ rate_func: RateFunction = there_and_back,
310
+ remover: bool = True,
311
+ final_alpha_value: float = 0.5,
312
+ **kwargs
313
+ ):
314
+ super().__init__(
315
+ vmobject,
316
+ rate_func=rate_func,
317
+ remover=remover,
318
+ final_alpha_value=final_alpha_value,
319
+ **kwargs
320
+ )
321
+
322
+ editor_thumbnail = (
323
+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 24">'
324
+ '<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.19" stroke="#C7E9F1" stroke-opacity="0.32" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
325
+ '<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.59" stroke="#C7E9F1" stroke-opacity="0.99" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
326
+ '<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="none" stroke="#58C4DD" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
327
+ '</svg>'
328
+ )
@@ -0,0 +1,90 @@
1
+ from __future__ import annotations
2
+
3
+ # What the Visual Editor files this module's classes under
4
+ __editor_category__ = 'Creation'
5
+
6
+ from datacut.animation.transform import Transform
7
+
8
+ from typing import TYPE_CHECKING
9
+
10
+ if TYPE_CHECKING:
11
+ from datacut.typing import Annotated, Direction, Example, Vect3
12
+ import numpy as np
13
+
14
+ from datacut.mobject.geometry import Arrow
15
+ from datacut.mobject.mobject import Mobject
16
+ from datacut.typing import ManimColor
17
+
18
+
19
+ class GrowFromPoint(Transform):
20
+ def __init__(
21
+ self,
22
+ mobject: Mobject,
23
+ point: Annotated[Vect3, Example('ORIGIN')],
24
+ point_color: ManimColor = None,
25
+ **kwargs
26
+ ):
27
+ self.point = point
28
+ self.point_color = point_color
29
+ super().__init__(mobject, **kwargs)
30
+
31
+ def create_target(self) -> Mobject:
32
+ return self.mobject.copy()
33
+
34
+ def create_starting_mobject(self) -> Mobject:
35
+ start = super().create_starting_mobject()
36
+ start.scale(0)
37
+ start.move_to(self.point)
38
+ if self.point_color is not None:
39
+ start.set_color(self.point_color)
40
+ return start
41
+
42
+ editor_thumbnail = (
43
+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 24">'
44
+ '<path d="M8.5 11.6Q8.1 11.6 7.8 11.6Q7.8 12.0 7.8 12.4Q8.1 12.4 8.5 12.4Q8.5 12.0 8.5 11.6Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
45
+ '<path d="M27.6 8.4Q24.0 8.4 20.4 8.4Q20.4 12.0 20.4 15.6Q24.0 15.6 27.6 15.6Q27.6 12.0 27.6 8.4Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
46
+ '<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"/>'
47
+ '</svg>'
48
+ )
49
+
50
+
51
+ class GrowFromCenter(GrowFromPoint):
52
+ def __init__(self, mobject: Mobject, **kwargs):
53
+ point = mobject.get_center()
54
+ super().__init__(mobject, point, **kwargs)
55
+
56
+ editor_thumbnail = (
57
+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 24">'
58
+ '<path d="M8.5 11.6Q8.1 11.6 7.8 11.6Q7.8 12.0 7.8 12.4Q8.1 12.4 8.5 12.4Q8.5 12.0 8.5 11.6Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
59
+ '<path d="M27.6 8.4Q24.0 8.4 20.4 8.4Q20.4 12.0 20.4 15.6Q24.0 15.6 27.6 15.6Q27.6 12.0 27.6 8.4Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
60
+ '<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"/>'
61
+ '</svg>'
62
+ )
63
+
64
+
65
+ class GrowFromEdge(GrowFromPoint):
66
+ def __init__(self, mobject: Mobject, edge: Annotated[Direction, Example('DOWN')], **kwargs):
67
+ point = mobject.get_bounding_box_point(edge)
68
+ super().__init__(mobject, point, **kwargs)
69
+
70
+ editor_thumbnail = (
71
+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 24">'
72
+ '<path d="M8.5 17.4Q8.1 17.4 7.8 17.4Q7.8 17.8 7.8 18.1Q8.1 18.1 8.5 18.1Q8.5 17.8 8.5 17.4Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
73
+ '<path d="M27.6 10.9Q24.0 10.9 20.4 10.9Q20.4 14.5 20.4 18.1Q24.0 18.1 27.6 18.1Q27.6 14.5 27.6 10.9Z" fill="#58C4DD" fill-opacity="0.60" stroke="#C7E9F1" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
74
+ '<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"/>'
75
+ '</svg>'
76
+ )
77
+
78
+
79
+ class GrowArrow(GrowFromPoint):
80
+ def __init__(self, arrow: Arrow, **kwargs):
81
+ point = arrow.get_start()
82
+ super().__init__(arrow, point, **kwargs)
83
+
84
+ editor_thumbnail = (
85
+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 24">'
86
+ '<path d="M14.2 5.9Q13.9 5.9 13.5 5.9Q13.5 6.2 13.5 6.6Q13.9 6.6 14.2 6.6Q14.2 6.2 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"/>'
87
+ '<path d="M30.1 5.9Q26.5 5.9 22.9 5.9Q22.9 9.5 22.9 13.1Q26.5 13.1 30.1 13.1Q30.1 9.5 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"/>'
88
+ '<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"/>'
89
+ '</svg>'
90
+ )