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,570 @@
1
+ from __future__ import annotations
2
+
3
+ # What the Visual Editor files this module's classes under
4
+ __editor_category__ = 'Text & Math'
5
+
6
+ import numpy as np
7
+
8
+ from datacut.constants import DOWN, LEFT, RIGHT, ORIGIN
9
+ from datacut.constants import DEG
10
+ from datacut.mobject.numbers import DecimalNumber
11
+ from datacut.mobject.svg.tex_mobject import Tex
12
+ from datacut.mobject.types.vectorized_mobject import VGroup
13
+ from datacut.mobject.types.vectorized_mobject import VMobject
14
+ from datacut.typing import UnsignedFloat, UnsignedInt
15
+
16
+ from typing import TYPE_CHECKING
17
+ from datacut.typing import Annotated, Kwargs
18
+
19
+ if TYPE_CHECKING:
20
+ from datacut.typing import Annotated, Example
21
+ from typing import Sequence, Union, Optional
22
+ from datacut.typing import ManimColor, Vect3, VectNArray, Self
23
+
24
+ StringMatrixType = Union[Sequence[Sequence[str]], np.ndarray[int, np.dtype[np.str_]]]
25
+ FloatMatrixType = Union[Sequence[Sequence[float]], VectNArray]
26
+ VMobjectMatrixType = Sequence[Sequence[VMobject]]
27
+ GenericMatrixType = Union[FloatMatrixType, StringMatrixType, VMobjectMatrixType]
28
+
29
+
30
+ class Matrix(VMobject):
31
+ def __init__(
32
+ self,
33
+ matrix: Annotated[GenericMatrixType, Example('[[1, 0], [0, 1]]')],
34
+ v_buff: float = 0.5,
35
+ h_buff: float = 0.5,
36
+ bracket_h_buff: float = 0.2,
37
+ bracket_v_buff: float = 0.25,
38
+ height: UnsignedFloat | None = None,
39
+ element_config: dict = dict(),
40
+ element_alignment_corner: Vect3 = DOWN,
41
+ ellipses_row: Optional[int] = None,
42
+ ellipses_col: Optional[int] = None,
43
+ ):
44
+ """
45
+ Matrix can either include numbers, tex_strings,
46
+ or mobjects
47
+ """
48
+ super().__init__()
49
+
50
+ self.mob_matrix = self.create_mobject_matrix(
51
+ matrix, v_buff, h_buff, element_alignment_corner,
52
+ **element_config
53
+ )
54
+
55
+ # Create helpful groups for the elements
56
+ n_cols = len(self.mob_matrix[0])
57
+ self.elements = [elem for row in self.mob_matrix for elem in row]
58
+ self.columns = VGroup(*(
59
+ VGroup(*(row[i] for row in self.mob_matrix))
60
+ for i in range(n_cols)
61
+ ))
62
+ self.rows = VGroup(*(VGroup(*row) for row in self.mob_matrix))
63
+ if height is not None:
64
+ self.rows.set_height(height - 2 * bracket_v_buff)
65
+ self.brackets = self.create_brackets(self.rows, bracket_v_buff, bracket_h_buff)
66
+ self.ellipses = []
67
+
68
+ # Add elements and brackets
69
+ self.add(*self.elements)
70
+ self.add(*self.brackets)
71
+ self.center()
72
+
73
+ # Potentially add ellipses
74
+ self.swap_entries_for_ellipses(
75
+ ellipses_row,
76
+ ellipses_col,
77
+ )
78
+
79
+ # Draw fills together
80
+ self.draw_fills_together_if_disjoint()
81
+
82
+ @classmethod
83
+ async def create(
84
+ cls,
85
+ matrix: GenericMatrixType,
86
+ v_buff: float = 0.5,
87
+ h_buff: float = 0.5,
88
+ bracket_h_buff: float = 0.2,
89
+ bracket_v_buff: float = 0.25,
90
+ height: UnsignedFloat | None = None,
91
+ element_config: dict = dict(),
92
+ element_alignment_corner: Vect3 = DOWN,
93
+ ellipses_row: Optional[int] = None,
94
+ ellipses_col: Optional[int] = None,
95
+ ) -> Matrix:
96
+ import sys
97
+ if sys.platform != "emscripten":
98
+ return cls(
99
+ matrix,
100
+ v_buff=v_buff,
101
+ h_buff=h_buff,
102
+ bracket_h_buff=bracket_h_buff,
103
+ bracket_v_buff=bracket_v_buff,
104
+ height=height,
105
+ element_config=element_config,
106
+ element_alignment_corner=element_alignment_corner,
107
+ ellipses_row=ellipses_row,
108
+ ellipses_col=ellipses_col,
109
+ )
110
+ inst = cls.__new__(cls)
111
+ VMobject.__init__(inst)
112
+ inst.mob_matrix = await inst.create_mobject_matrix_async(
113
+ matrix, v_buff, h_buff, element_alignment_corner,
114
+ **element_config
115
+ )
116
+ n_cols = len(inst.mob_matrix[0])
117
+ inst.elements = [elem for row in inst.mob_matrix for elem in row]
118
+ inst.columns = VGroup(*(
119
+ VGroup(*(row[i] for row in inst.mob_matrix))
120
+ for i in range(n_cols)
121
+ ))
122
+ inst.rows = VGroup(*(VGroup(*row) for row in inst.mob_matrix))
123
+ if height is not None:
124
+ inst.rows.set_height(height - 2 * bracket_v_buff)
125
+ inst.brackets = await inst.create_brackets_async(inst.rows, bracket_v_buff, bracket_h_buff)
126
+ inst.ellipses = []
127
+ inst.add(*inst.elements)
128
+ inst.add(*inst.brackets)
129
+ inst.center()
130
+ await inst.swap_entries_for_ellipses_async(ellipses_row, ellipses_col)
131
+ inst.draw_fills_together_if_disjoint()
132
+ return inst
133
+
134
+ def copy(self, deep: bool = False):
135
+ result = super().copy(deep)
136
+ self_family = self.get_family()
137
+ copy_family = result.get_family()
138
+ for attr in ["elements", "ellipses"]:
139
+ setattr(result, attr, [
140
+ copy_family[self_family.index(mob)]
141
+ for mob in getattr(self, attr)
142
+ ])
143
+ return result
144
+
145
+ def create_mobject_matrix(
146
+ self,
147
+ matrix: GenericMatrixType,
148
+ v_buff: float,
149
+ h_buff: float,
150
+ aligned_corner: Vect3,
151
+ **element_config
152
+ ) -> VMobjectMatrixType:
153
+ """
154
+ Creates and organizes the matrix of mobjects
155
+ """
156
+ mob_matrix = [
157
+ [
158
+ self.element_to_mobject(element, **element_config)
159
+ for element in row
160
+ ]
161
+ for row in matrix
162
+ ]
163
+ max_width = max(elem.get_width() for row in mob_matrix for elem in row)
164
+ max_height = max(elem.get_height() for row in mob_matrix for elem in row)
165
+ x_step = (max_width + h_buff) * RIGHT
166
+ y_step = (max_height + v_buff) * DOWN
167
+ for i, row in enumerate(mob_matrix):
168
+ for j, elem in enumerate(row):
169
+ elem.move_to(i * y_step + j * x_step, aligned_corner)
170
+ return mob_matrix
171
+
172
+ def element_to_mobject(self, element, **config) -> VMobject:
173
+ if isinstance(element, VMobject):
174
+ return element
175
+ elif isinstance(element, float | complex):
176
+ return DecimalNumber(element, **config)
177
+ else:
178
+ return Tex(str(element), **config)
179
+
180
+ def create_brackets(self, rows, v_buff: float, h_buff: float) -> VGroup:
181
+ brackets = Tex("".join((
182
+ R"\left[\begin{array}{c}",
183
+ *len(rows) * [R"\quad \\"],
184
+ R"\end{array}\right]",
185
+ )))
186
+ brackets.set_height(rows.get_height() + v_buff)
187
+ l_bracket = brackets[:len(brackets) // 2]
188
+ r_bracket = brackets[len(brackets) // 2:]
189
+ l_bracket.next_to(rows, LEFT, h_buff)
190
+ r_bracket.next_to(rows, RIGHT, h_buff)
191
+ return VGroup(l_bracket, r_bracket)
192
+
193
+ async def create_mobject_matrix_async(
194
+ self,
195
+ matrix: GenericMatrixType,
196
+ v_buff: float,
197
+ h_buff: float,
198
+ aligned_corner: Vect3,
199
+ **element_config
200
+ ) -> VMobjectMatrixType:
201
+ mob_matrix = []
202
+ for row in matrix:
203
+ mob_row = []
204
+ for element in row:
205
+ mob_row.append(await self.element_to_mobject_async(element, **element_config))
206
+ mob_matrix.append(mob_row)
207
+ max_width = max(elem.get_width() for row in mob_matrix for elem in row)
208
+ max_height = max(elem.get_height() for row in mob_matrix for elem in row)
209
+ x_step = (max_width + h_buff) * RIGHT
210
+ y_step = (max_height + v_buff) * DOWN
211
+ for i, row in enumerate(mob_matrix):
212
+ for j, elem in enumerate(row):
213
+ elem.move_to(i * y_step + j * x_step, aligned_corner)
214
+ return mob_matrix
215
+
216
+ async def element_to_mobject_async(self, element, **config) -> VMobject:
217
+ import inspect
218
+ if isinstance(element, VMobject):
219
+ return element
220
+ elif isinstance(element, float | complex):
221
+ return await DecimalNumber.create(element, **config)
222
+ else:
223
+ res = Tex.create(str(element), **config)
224
+ return await res if inspect.isawaitable(res) else res
225
+
226
+ async def create_brackets_async(self, rows, v_buff: float, h_buff: float) -> VGroup:
227
+ import inspect
228
+ brackets = Tex.create("".join((
229
+ R"\left[\begin{array}{c}",
230
+ *len(rows) * [R"\quad \\"],
231
+ R"\end{array}\right]",
232
+ )))
233
+ if inspect.isawaitable(brackets):
234
+ brackets = await brackets
235
+ brackets.set_height(rows.get_height() + v_buff)
236
+ l_bracket = brackets[:len(brackets) // 2]
237
+ r_bracket = brackets[len(brackets) // 2:]
238
+ l_bracket.next_to(rows, LEFT, h_buff)
239
+ r_bracket.next_to(rows, RIGHT, h_buff)
240
+ return VGroup(l_bracket, r_bracket)
241
+
242
+ def get_column(self, index: int):
243
+ if not 0 <= index < len(self.columns):
244
+ raise IndexError(f"Index {index} out of bound for matrix with {len(self.columns)} columns")
245
+ return self.columns[index]
246
+
247
+ def get_row(self, index: int):
248
+ if not 0 <= index < len(self.rows):
249
+ raise IndexError(f"Index {index} out of bound for matrix with {len(self.rows)} rows")
250
+ return self.rows[index]
251
+
252
+ def get_columns(self) -> VGroup:
253
+ return self.columns
254
+
255
+ def get_rows(self) -> VGroup:
256
+ return self.rows
257
+
258
+ def set_column_colors(self, *colors: ManimColor) -> Self:
259
+ columns = self.get_columns()
260
+ for color, column in zip(colors, columns):
261
+ column.set_color(color)
262
+ return self
263
+
264
+ def add_background_to_entries(self) -> Self:
265
+ for mob in self.get_entries():
266
+ mob.add_background_rectangle()
267
+ return self
268
+
269
+ def swap_entry_for_dots(self, entry, dots):
270
+ dots.move_to(entry)
271
+ entry.become(dots)
272
+ if entry in self.elements:
273
+ self.elements.remove(entry)
274
+ if entry not in self.ellipses:
275
+ self.ellipses.append(entry)
276
+
277
+ def swap_entries_for_ellipses(
278
+ self,
279
+ row_index: Optional[int] = None,
280
+ col_index: Optional[int] = None,
281
+ height_ratio: float = 0.65,
282
+ width_ratio: float = 0.4
283
+ ):
284
+ rows = self.get_rows()
285
+ cols = self.get_columns()
286
+
287
+ avg_row_height = rows.get_height() / len(rows)
288
+ vdots_height = height_ratio * avg_row_height
289
+
290
+ avg_col_width = cols.get_width() / len(cols)
291
+ hdots_width = width_ratio * avg_col_width
292
+
293
+ use_vdots = row_index is not None and -len(rows) <= row_index < len(rows)
294
+ use_hdots = col_index is not None and -len(cols) <= col_index < len(cols)
295
+
296
+ if use_vdots:
297
+ for column in cols:
298
+ # Add vdots
299
+ dots = Tex(R"\vdots")
300
+ dots.set_height(vdots_height)
301
+ self.swap_entry_for_dots(column[row_index], dots)
302
+ if use_hdots:
303
+ for row in rows:
304
+ # Add hdots
305
+ dots = Tex(R"\hdots")
306
+ dots.set_width(hdots_width)
307
+ self.swap_entry_for_dots(row[col_index], dots)
308
+ if use_vdots and use_hdots:
309
+ rows[row_index][col_index].rotate(-45 * DEG)
310
+ return self
311
+
312
+ async def swap_entries_for_ellipses_async(
313
+ self,
314
+ row_index: Optional[int] = None,
315
+ col_index: Optional[int] = None,
316
+ height_ratio: float = 0.65,
317
+ width_ratio: float = 0.4
318
+ ):
319
+ import inspect
320
+ rows = self.get_rows()
321
+ cols = self.get_columns()
322
+
323
+ avg_row_height = rows.get_height() / len(rows)
324
+ vdots_height = height_ratio * avg_row_height
325
+
326
+ avg_col_width = cols.get_width() / len(cols)
327
+ hdots_width = width_ratio * avg_col_width
328
+
329
+ use_vdots = row_index is not None and -len(rows) <= row_index < len(rows)
330
+ use_hdots = col_index is not None and -len(cols) <= col_index < len(cols)
331
+
332
+ if use_vdots:
333
+ for column in cols:
334
+ dots = Tex.create(R"\vdots")
335
+ if inspect.isawaitable(dots):
336
+ dots = await dots
337
+ dots.set_height(vdots_height)
338
+ self.swap_entry_for_dots(column[row_index], dots)
339
+ if use_hdots:
340
+ for row in rows:
341
+ dots = Tex.create(R"\hdots")
342
+ if inspect.isawaitable(dots):
343
+ dots = await dots
344
+ dots.set_width(hdots_width)
345
+ self.swap_entry_for_dots(row[col_index], dots)
346
+ if use_vdots and use_hdots:
347
+ rows[row_index][col_index].rotate(-45 * DEG)
348
+ return self
349
+
350
+ def get_mob_matrix(self) -> VMobjectMatrixType:
351
+ return self.mob_matrix
352
+
353
+ def get_entries(self) -> VGroup:
354
+ return VGroup(*self.elements)
355
+
356
+ def get_brackets(self) -> VGroup:
357
+ return VGroup(*self.brackets)
358
+
359
+ def get_ellipses(self) -> VGroup:
360
+ return VGroup(*self.ellipses)
361
+
362
+ editor_thumbnail = (
363
+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">'
364
+ '<path d="M8.0 5.2Q7.8 5.4 7.5 5.5Q7.3 5.6 6.9 5.6Q6.9 5.7 6.9 5.8Q7.2 5.8 7.4 5.7Q7.5 5.7 7.7 5.6Q7.7 7.1 7.7 8.6Q7.7 8.6 7.7 8.7Q7.6 8.7 7.6 8.8Q7.6 8.8 7.5 8.8Q7.3 8.8 7.2 8.8Q7.1 8.8 7.0 8.8Q7.0 8.9 7.0 9.0Q7.1 9.0 7.3 9.0Q7.6 9.0 7.9 9.0Q8.3 9.0 8.5 9.0Q8.7 9.0 8.8 9.0Q8.8 8.9 8.8 8.8Q8.7 8.8 8.6 8.8Q8.5 8.8 8.4 8.8Q8.3 8.8 8.2 8.8Q8.2 8.7 8.2 8.7Q8.1 8.6 8.1 8.6Q8.1 7.0 8.1 5.4Q8.1 5.3 8.1 5.2Q8.1 5.2 8.0 5.2Z" fill="#FFFFFF" fill-opacity="1.00" fill-rule="evenodd" stroke-linejoin="round"/>'
365
+ '<path d="M16.3 9.0Q16.9 9.0 17.3 8.5Q17.6 8.0 17.6 7.1Q17.6 6.4 17.4 6.0Q17.3 5.5 17.0 5.3Q16.9 5.2 16.7 5.1Q16.5 5.1 16.3 5.1Q15.7 5.1 15.4 5.6Q15.1 6.1 15.1 7.1Q15.1 7.9 15.4 8.4Q15.7 9.0 16.3 9.0ZM17.0 5.9Q17.0 6.0 17.0 6.3Q17.0 6.6 17.0 7.0Q17.0 7.4 17.0 7.7Q17.0 8.0 17.0 8.2Q16.9 8.5 16.8 8.7Q16.6 8.9 16.3 8.9Q16.2 8.9 16.1 8.8Q16.0 8.8 16.0 8.7Q15.8 8.6 15.8 8.4Q15.7 8.2 15.7 7.9Q15.7 7.8 15.6 7.6Q15.6 7.3 15.6 7.0Q15.6 6.6 15.7 6.4Q15.7 6.1 15.7 5.9Q15.7 5.7 15.8 5.6Q15.9 5.4 16.0 5.3Q16.1 5.3 16.2 5.3Q16.3 5.2 16.3 5.2Q16.6 5.2 16.8 5.4Q16.9 5.6 17.0 5.9Z" fill="#FFFFFF" fill-opacity="1.00" fill-rule="evenodd" stroke-linejoin="round"/>'
366
+ '<path d="M7.7 18.9Q8.4 18.9 8.7 18.4Q9.0 17.9 9.0 17.0Q9.0 16.3 8.8 15.9Q8.7 15.4 8.4 15.2Q8.3 15.1 8.1 15.0Q7.9 15.0 7.8 15.0Q7.1 15.0 6.8 15.5Q6.5 16.0 6.5 17.0Q6.5 17.8 6.8 18.3Q7.1 18.9 7.7 18.9ZM8.4 15.8Q8.4 15.9 8.4 16.2Q8.4 16.5 8.4 16.9Q8.4 17.3 8.4 17.6Q8.4 17.9 8.4 18.1Q8.3 18.4 8.2 18.6Q8.0 18.8 7.7 18.8Q7.6 18.8 7.5 18.7Q7.5 18.7 7.4 18.6Q7.2 18.5 7.2 18.3Q7.1 18.1 7.1 17.8Q7.1 17.7 7.1 17.5Q7.1 17.3 7.1 16.9Q7.1 16.5 7.1 16.3Q7.1 16.0 7.1 15.9Q7.1 15.6 7.2 15.5Q7.3 15.3 7.4 15.2Q7.5 15.2 7.6 15.2Q7.7 15.1 7.7 15.1Q8.0 15.1 8.2 15.3Q8.3 15.5 8.4 15.8Z" fill="#FFFFFF" fill-opacity="1.00" fill-rule="evenodd" stroke-linejoin="round"/>'
367
+ '<path d="M16.6 15.1Q16.4 15.3 16.1 15.4Q15.9 15.5 15.5 15.5Q15.5 15.6 15.5 15.7Q15.8 15.7 15.9 15.7Q16.1 15.6 16.3 15.5Q16.3 17.0 16.3 18.5Q16.3 18.5 16.3 18.6Q16.2 18.6 16.2 18.7Q16.2 18.7 16.1 18.7Q15.9 18.7 15.8 18.7Q15.7 18.7 15.6 18.7Q15.6 18.8 15.6 18.9Q15.7 18.9 15.9 18.9Q16.1 18.9 16.5 18.9Q16.9 18.9 17.1 18.9Q17.3 18.9 17.4 18.9Q17.4 18.8 17.4 18.7Q17.3 18.7 17.2 18.7Q17.1 18.7 16.9 18.7Q16.8 18.7 16.8 18.7Q16.8 18.6 16.8 18.6Q16.7 18.5 16.7 18.5Q16.7 16.9 16.7 15.3Q16.7 15.2 16.7 15.1Q16.7 15.1 16.6 15.1Z" fill="#FFFFFF" fill-opacity="1.00" fill-rule="evenodd" stroke-linejoin="round"/>'
368
+ '<path d="M3.7 20.0Q3.1 20.0 2.4 20.0Q2.4 12.0 2.4 4.0Q3.1 4.0 3.7 4.0Q3.8 4.0 3.9 4.0Q3.9 3.9 3.9 3.8Q3.9 3.7 3.9 3.6Q3.8 3.6 3.7 3.6Q2.9 3.6 2.0 3.6Q2.0 12.0 2.0 20.4Q2.9 20.4 3.7 20.4Q3.8 20.4 3.9 20.4Q3.9 20.3 3.9 20.2Q3.9 20.1 3.9 20.0Q3.8 20.0 3.7 20.0Z" fill="#FFFFFF" fill-opacity="1.00" fill-rule="evenodd" stroke-linejoin="round"/>'
369
+ '<path d="M20.3 20.4Q21.1 20.4 22.0 20.4Q22.0 12.0 22.0 3.6Q21.1 3.6 20.3 3.6Q20.2 3.6 20.1 3.6Q20.1 3.7 20.1 3.8Q20.1 3.9 20.1 4.0Q20.2 4.0 20.3 4.0Q20.9 4.0 21.6 4.0Q21.6 12.0 21.6 20.0Q20.9 20.0 20.3 20.0Q20.2 20.0 20.1 20.0Q20.1 20.1 20.1 20.2Q20.1 20.3 20.1 20.4Q20.2 20.4 20.3 20.4Z" fill="#FFFFFF" fill-opacity="1.00" fill-rule="evenodd" stroke-linejoin="round"/>'
370
+ '</svg>'
371
+ )
372
+
373
+
374
+ class DecimalMatrix(Matrix):
375
+ def __init__(
376
+ self,
377
+ matrix: Annotated[FloatMatrixType, Example('[[1.5, 0.0], [0.0, 2.5]]')],
378
+ num_decimal_places: UnsignedInt = 2,
379
+ decimal_config: Annotated[dict, Kwargs("datacut.mobject.numbers.DecimalNumber", exclude=('number', 'num_decimal_places'))] = dict(),
380
+ **config
381
+ ):
382
+ self.float_matrix = matrix
383
+ super().__init__(
384
+ matrix,
385
+ element_config=dict(
386
+ num_decimal_places=num_decimal_places,
387
+ **decimal_config
388
+ ),
389
+ **config
390
+ )
391
+
392
+ def element_to_mobject(self, element, **decimal_config) -> DecimalNumber:
393
+ return DecimalNumber(element, **decimal_config)
394
+
395
+ async def element_to_mobject_async(self, element, **decimal_config) -> DecimalNumber:
396
+ return await DecimalNumber.create(element, **decimal_config)
397
+
398
+ @classmethod
399
+ async def create(
400
+ cls,
401
+ matrix: FloatMatrixType,
402
+ num_decimal_places: UnsignedInt = 2,
403
+ decimal_config: Annotated[dict, Kwargs("datacut.mobject.numbers.DecimalNumber", exclude=('number', 'num_decimal_places'))] = dict(),
404
+ **config
405
+ ) -> DecimalMatrix:
406
+ inst = await Matrix.create.__func__(
407
+ cls,
408
+ matrix,
409
+ element_config=dict(
410
+ num_decimal_places=num_decimal_places,
411
+ **decimal_config
412
+ ),
413
+ **config
414
+ )
415
+ inst.float_matrix = matrix
416
+ return inst
417
+
418
+ editor_thumbnail = (
419
+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">'
420
+ '<polygon points="5,10 10,10 11,10 11,10 11,9 11,9 10,8 10,8 10,8 10,8 9,8 8,8 6,8 5,9" fill="#FFFFFF" fill-opacity="0.70" stroke="#FFFFFF" stroke-width="0.8"/>'
421
+ '<polygon points="14,10 14,10 19,10 20,10 20,9 20,9 19,8 19,8 19,8 19,8 14,8 14,9 14,9" fill="#FFFFFF" fill-opacity="0.70" stroke="#FFFFFF" stroke-width="0.8"/>'
422
+ '<polygon points="5,16 6,16 11,16 11,15 11,15 11,14 11,14 11,14 10,14 10,14 10,14 6,14 5,14 5,14" fill="#FFFFFF" fill-opacity="0.70" stroke="#FFFFFF" stroke-width="0.8"/>'
423
+ '<polygon points="14,16 19,16 20,15 20,14 19,14 19,14 19,14 19,14 19,14 18,14 17,14 15,14 15,14 14,14 14,14 14,14 14,14 14,14" fill="#FFFFFF" fill-opacity="0.70" stroke="#FFFFFF" stroke-width="0.8"/>'
424
+ '<polygon points="2,13 3,16 4,16 4,16 4,8 4,8 3,8" fill="#FFFFFF" fill-opacity="0.70" stroke="#FFFFFF" stroke-width="0.8"/>'
425
+ '<polygon points="21,13 21,16 21,16 21,16 22,16 22,8 21,8 21,8 21,8" fill="#FFFFFF" fill-opacity="0.70" stroke="#FFFFFF" stroke-width="0.8"/>'
426
+ '</svg>'
427
+ )
428
+
429
+
430
+ class IntegerMatrix(DecimalMatrix):
431
+ def __init__(
432
+ self,
433
+ matrix: Annotated[FloatMatrixType, Example('[[1, 0], [0, 1]]')],
434
+ num_decimal_places: UnsignedInt = 0,
435
+ decimal_config: Annotated[dict, Kwargs("datacut.mobject.numbers.DecimalNumber", exclude=('number', 'num_decimal_places'))] = dict(),
436
+ **config
437
+ ):
438
+ super().__init__(matrix, num_decimal_places, decimal_config, **config)
439
+
440
+ @classmethod
441
+ async def create(
442
+ cls,
443
+ matrix: FloatMatrixType,
444
+ num_decimal_places: UnsignedInt = 0,
445
+ decimal_config: Annotated[dict, Kwargs("datacut.mobject.numbers.DecimalNumber", exclude=('number', 'num_decimal_places'))] = dict(),
446
+ **config
447
+ ) -> IntegerMatrix:
448
+ return await super().create(matrix, num_decimal_places, decimal_config, **config)
449
+
450
+ editor_thumbnail = (
451
+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">'
452
+ '<path d="M8.0 5.2Q7.8 5.4 7.5 5.5Q7.3 5.6 6.9 5.6Q6.9 5.7 6.9 5.8Q7.2 5.8 7.4 5.7Q7.5 5.7 7.7 5.6Q7.7 7.1 7.7 8.6Q7.7 8.6 7.7 8.7Q7.6 8.7 7.6 8.8Q7.6 8.8 7.5 8.8Q7.3 8.8 7.2 8.8Q7.1 8.8 7.0 8.8Q7.0 8.9 7.0 9.0Q7.1 9.0 7.3 9.0Q7.6 9.0 7.9 9.0Q8.3 9.0 8.5 9.0Q8.7 9.0 8.8 9.0Q8.8 8.9 8.8 8.8Q8.7 8.8 8.6 8.8Q8.5 8.8 8.4 8.8Q8.3 8.8 8.2 8.8Q8.2 8.7 8.2 8.7Q8.1 8.6 8.1 8.6Q8.1 7.0 8.1 5.4Q8.1 5.3 8.1 5.2Q8.1 5.2 8.0 5.2Z" fill="#FFFFFF" fill-opacity="1.00" fill-rule="evenodd" stroke-linejoin="round"/>'
453
+ '<path d="M16.3 9.0Q16.9 9.0 17.3 8.5Q17.6 8.0 17.6 7.1Q17.6 6.4 17.4 6.0Q17.3 5.5 17.0 5.3Q16.9 5.2 16.7 5.1Q16.5 5.1 16.3 5.1Q15.7 5.1 15.4 5.6Q15.1 6.1 15.1 7.1Q15.1 7.9 15.4 8.4Q15.7 9.0 16.3 9.0ZM17.0 5.9Q17.0 6.0 17.0 6.3Q17.0 6.6 17.0 7.0Q17.0 7.4 17.0 7.7Q17.0 8.0 17.0 8.2Q16.9 8.5 16.8 8.7Q16.6 8.9 16.3 8.9Q16.2 8.9 16.1 8.8Q16.0 8.8 16.0 8.7Q15.8 8.6 15.8 8.4Q15.7 8.2 15.7 7.9Q15.7 7.8 15.6 7.6Q15.6 7.3 15.6 7.0Q15.6 6.6 15.7 6.4Q15.7 6.1 15.7 5.9Q15.7 5.7 15.8 5.6Q15.9 5.4 16.0 5.3Q16.1 5.3 16.2 5.3Q16.3 5.2 16.3 5.2Q16.6 5.2 16.8 5.4Q16.9 5.6 17.0 5.9Z" fill="#FFFFFF" fill-opacity="1.00" fill-rule="evenodd" stroke-linejoin="round"/>'
454
+ '<path d="M7.7 18.9Q8.4 18.9 8.7 18.4Q9.0 17.9 9.0 17.0Q9.0 16.3 8.8 15.9Q8.7 15.4 8.4 15.2Q8.3 15.1 8.1 15.0Q7.9 15.0 7.8 15.0Q7.1 15.0 6.8 15.5Q6.5 16.0 6.5 17.0Q6.5 17.8 6.8 18.3Q7.1 18.9 7.7 18.9ZM8.4 15.8Q8.4 15.9 8.4 16.2Q8.4 16.5 8.4 16.9Q8.4 17.3 8.4 17.6Q8.4 17.9 8.4 18.1Q8.3 18.4 8.2 18.6Q8.0 18.8 7.7 18.8Q7.6 18.8 7.5 18.7Q7.5 18.7 7.4 18.6Q7.2 18.5 7.2 18.3Q7.1 18.1 7.1 17.8Q7.1 17.7 7.1 17.5Q7.1 17.3 7.1 16.9Q7.1 16.5 7.1 16.3Q7.1 16.0 7.1 15.9Q7.1 15.6 7.2 15.5Q7.3 15.3 7.4 15.2Q7.5 15.2 7.6 15.2Q7.7 15.1 7.7 15.1Q8.0 15.1 8.2 15.3Q8.3 15.5 8.4 15.8Z" fill="#FFFFFF" fill-opacity="1.00" fill-rule="evenodd" stroke-linejoin="round"/>'
455
+ '<path d="M16.6 15.1Q16.4 15.3 16.1 15.4Q15.9 15.5 15.5 15.5Q15.5 15.6 15.5 15.7Q15.8 15.7 15.9 15.7Q16.1 15.6 16.3 15.5Q16.3 17.0 16.3 18.5Q16.3 18.5 16.3 18.6Q16.2 18.6 16.2 18.7Q16.2 18.7 16.1 18.7Q15.9 18.7 15.8 18.7Q15.7 18.7 15.6 18.7Q15.6 18.8 15.6 18.9Q15.7 18.9 15.9 18.9Q16.1 18.9 16.5 18.9Q16.9 18.9 17.1 18.9Q17.3 18.9 17.4 18.9Q17.4 18.8 17.4 18.7Q17.3 18.7 17.2 18.7Q17.1 18.7 16.9 18.7Q16.8 18.7 16.8 18.7Q16.8 18.6 16.8 18.6Q16.7 18.5 16.7 18.5Q16.7 16.9 16.7 15.3Q16.7 15.2 16.7 15.1Q16.7 15.1 16.6 15.1Z" fill="#FFFFFF" fill-opacity="1.00" fill-rule="evenodd" stroke-linejoin="round"/>'
456
+ '<path d="M3.7 20.0Q3.1 20.0 2.4 20.0Q2.4 12.0 2.4 4.0Q3.1 4.0 3.7 4.0Q3.8 4.0 3.9 4.0Q3.9 3.9 3.9 3.8Q3.9 3.7 3.9 3.6Q3.8 3.6 3.7 3.6Q2.9 3.6 2.0 3.6Q2.0 12.0 2.0 20.4Q2.9 20.4 3.7 20.4Q3.8 20.4 3.9 20.4Q3.9 20.3 3.9 20.2Q3.9 20.1 3.9 20.0Q3.8 20.0 3.7 20.0Z" fill="#FFFFFF" fill-opacity="1.00" fill-rule="evenodd" stroke-linejoin="round"/>'
457
+ '<path d="M20.3 20.4Q21.1 20.4 22.0 20.4Q22.0 12.0 22.0 3.6Q21.1 3.6 20.3 3.6Q20.2 3.6 20.1 3.6Q20.1 3.7 20.1 3.8Q20.1 3.9 20.1 4.0Q20.2 4.0 20.3 4.0Q20.9 4.0 21.6 4.0Q21.6 12.0 21.6 20.0Q20.9 20.0 20.3 20.0Q20.2 20.0 20.1 20.0Q20.1 20.1 20.1 20.2Q20.1 20.3 20.1 20.4Q20.2 20.4 20.3 20.4Z" fill="#FFFFFF" fill-opacity="1.00" fill-rule="evenodd" stroke-linejoin="round"/>'
458
+ '</svg>'
459
+ )
460
+
461
+
462
+ class TexMatrix(Matrix):
463
+ def __init__(
464
+ self,
465
+ matrix: Annotated[StringMatrixType, Example('[["a", "b"], ["c", "d"]]')],
466
+ tex_config: Annotated[dict, Kwargs("datacut.mobject.svg.tex_mobject.Tex")] = dict(),
467
+ **config,
468
+ ):
469
+ super().__init__(
470
+ matrix,
471
+ element_config=tex_config,
472
+ **config
473
+ )
474
+
475
+ @classmethod
476
+ async def create(
477
+ cls,
478
+ matrix: StringMatrixType,
479
+ tex_config: Annotated[dict, Kwargs("datacut.mobject.svg.tex_mobject.Tex")] = dict(),
480
+ **config,
481
+ ) -> TexMatrix:
482
+ return await super().create(matrix, element_config=tex_config, **config)
483
+
484
+ editor_thumbnail = (
485
+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">'
486
+ '<path d="M9.0 8.3Q9.0 8.2 9.0 8.2Q8.9 8.2 8.9 8.2Q8.9 8.2 8.8 8.2Q8.8 8.2 8.8 8.3Q8.7 8.6 8.6 8.8Q8.5 9.0 8.4 9.0Q8.3 9.0 8.3 8.9Q8.3 8.8 8.3 8.7Q8.3 8.7 8.3 8.6Q8.3 8.5 8.3 8.3Q8.5 7.7 8.6 7.1Q8.7 7.0 8.7 6.9Q8.7 6.9 8.7 6.9Q8.7 6.8 8.6 6.7Q8.6 6.7 8.5 6.7Q8.4 6.7 8.4 6.8Q8.3 6.8 8.3 6.9Q8.2 6.7 8.1 6.7Q7.9 6.6 7.8 6.6Q7.5 6.6 7.3 6.7Q7.0 6.9 6.8 7.1Q6.6 7.4 6.5 7.7Q6.4 7.9 6.4 8.2Q6.4 8.6 6.6 8.9Q6.8 9.1 7.2 9.1Q7.4 9.1 7.5 9.0Q7.7 8.9 7.9 8.7Q7.9 8.9 8.1 9.0Q8.2 9.1 8.4 9.1Q8.6 9.1 8.8 8.8Q8.9 8.7 9.0 8.3ZM8.1 7.0Q8.1 7.1 8.2 7.1Q8.2 7.2 8.2 7.2Q8.2 7.2 8.2 7.3Q8.2 7.3 8.2 7.3Q8.0 7.8 7.9 8.4Q7.9 8.4 7.9 8.5Q7.8 8.5 7.8 8.6Q7.6 8.8 7.5 8.9Q7.3 9.0 7.2 9.0Q7.0 9.0 6.9 8.8Q6.9 8.7 6.9 8.5Q6.9 8.4 6.9 8.2Q6.9 8.1 7.0 7.9Q7.0 7.5 7.2 7.3Q7.3 7.0 7.5 6.9Q7.5 6.8 7.6 6.8Q7.7 6.8 7.8 6.8Q7.9 6.8 8.0 6.8Q8.1 6.9 8.1 7.0Z" fill="#FFFFFF" fill-opacity="1.00" fill-rule="evenodd" stroke-linejoin="round"/>'
487
+ '<path d="M16.6 6.6Q16.5 6.6 16.3 6.6Q16.2 6.7 16.0 6.9Q16.2 6.1 16.4 5.3Q16.4 5.2 16.4 5.2Q16.4 5.2 16.3 5.2Q16.2 5.2 15.8 5.2Q15.7 5.2 15.7 5.2Q15.6 5.3 15.6 5.3Q15.5 5.3 15.5 5.4Q15.5 5.4 15.6 5.4Q15.6 5.5 15.7 5.5Q15.7 5.5 15.7 5.5Q15.9 5.5 15.9 5.5Q15.9 5.6 15.9 5.8Q15.9 5.8 15.9 5.9Q15.6 6.8 15.4 7.7Q15.4 7.8 15.4 8.0Q15.3 8.1 15.3 8.2Q15.3 8.6 15.5 8.9Q15.7 9.1 16.0 9.1Q16.3 9.1 16.6 9.0Q16.8 8.8 17.0 8.6Q17.2 8.3 17.3 8.0Q17.4 7.8 17.4 7.5Q17.4 7.1 17.2 6.8Q17.0 6.6 16.6 6.6ZM16.6 6.7Q16.8 6.7 16.9 6.9Q17.0 7.0 17.0 7.2Q17.0 7.4 16.9 7.5Q16.9 7.7 16.9 7.8Q16.8 8.2 16.6 8.4Q16.5 8.7 16.4 8.8Q16.3 8.9 16.2 8.9Q16.1 9.0 16.0 9.0Q15.9 9.0 15.8 8.8Q15.7 8.7 15.7 8.4Q15.7 8.3 15.7 8.2Q15.7 8.0 15.8 7.9Q15.9 7.6 15.9 7.4Q15.9 7.3 15.9 7.3Q16.0 7.2 16.0 7.2Q16.2 7.0 16.3 6.9Q16.5 6.7 16.6 6.7Z" fill="#FFFFFF" fill-opacity="1.00" fill-rule="evenodd" stroke-linejoin="round"/>'
488
+ '<path d="M8.2 16.9Q8.2 17.0 8.3 17.1Q8.3 17.2 8.4 17.2Q8.6 17.2 8.7 17.0Q8.8 16.9 8.8 16.8Q8.8 16.6 8.6 16.4Q8.4 16.3 8.1 16.3Q7.8 16.3 7.6 16.4Q7.3 16.5 7.1 16.8Q6.8 17.0 6.7 17.3Q6.6 17.6 6.6 17.9Q6.6 18.3 6.9 18.5Q7.1 18.8 7.5 18.8Q7.7 18.8 7.9 18.8Q8.1 18.7 8.3 18.6Q8.5 18.5 8.6 18.4Q8.7 18.3 8.7 18.2Q8.8 18.2 8.8 18.2Q8.8 18.2 8.8 18.1Q8.8 18.1 8.8 18.1Q8.7 18.0 8.7 18.0Q8.7 18.0 8.7 18.1Q8.6 18.1 8.6 18.1Q8.5 18.3 8.3 18.4Q8.1 18.5 7.9 18.6Q7.8 18.6 7.7 18.6Q7.6 18.7 7.5 18.7Q7.3 18.7 7.2 18.5Q7.1 18.4 7.1 18.1Q7.1 17.8 7.2 17.5Q7.3 17.2 7.4 17.0Q7.5 16.8 7.7 16.6Q7.9 16.4 8.1 16.4Q8.3 16.4 8.4 16.5Q8.5 16.5 8.5 16.6Q8.4 16.6 8.3 16.7Q8.2 16.8 8.2 16.9Z" fill="#FFFFFF" fill-opacity="1.00" fill-rule="evenodd" stroke-linejoin="round"/>'
489
+ '<path d="M17.2 15.2Q17.0 15.9 16.9 16.6Q16.8 16.4 16.6 16.3Q16.5 16.3 16.4 16.3Q16.1 16.3 15.8 16.4Q15.6 16.5 15.4 16.8Q15.2 17.1 15.1 17.4Q15.0 17.6 15.0 17.9Q15.0 18.3 15.2 18.5Q15.4 18.8 15.8 18.8Q15.9 18.8 16.1 18.7Q16.3 18.6 16.5 18.4Q16.5 18.6 16.6 18.7Q16.8 18.8 17.0 18.8Q17.2 18.8 17.4 18.5Q17.5 18.3 17.6 17.9Q17.6 17.9 17.5 17.9Q17.5 17.9 17.5 17.9Q17.4 17.9 17.4 17.9Q17.4 17.9 17.4 18.0Q17.3 18.3 17.2 18.5Q17.1 18.6 17.0 18.6Q16.9 18.6 16.9 18.6Q16.8 18.5 16.8 18.4Q16.8 18.4 16.9 18.3Q16.9 18.2 16.9 18.2Q17.3 16.6 17.7 15.0Q17.7 15.0 17.7 14.9Q17.7 14.9 17.6 14.9Q17.6 14.9 17.6 14.9Q17.5 14.9 17.3 14.9Q17.1 14.9 16.9 14.9Q16.8 14.9 16.8 15.0Q16.8 15.0 16.8 15.1Q16.8 15.1 16.8 15.1Q16.9 15.2 16.9 15.2Q16.9 15.2 17.0 15.2Q17.2 15.2 17.2 15.2ZM16.7 16.7Q16.7 16.7 16.8 16.8Q16.8 16.9 16.8 16.9Q16.8 16.9 16.8 16.9Q16.8 17.0 16.8 17.0Q16.6 17.5 16.5 18.1Q16.5 18.1 16.4 18.2Q16.4 18.2 16.4 18.3Q16.2 18.5 16.1 18.5Q15.9 18.6 15.8 18.6Q15.6 18.6 15.5 18.5Q15.4 18.4 15.4 18.1Q15.4 18.0 15.5 17.9Q15.5 17.7 15.5 17.5Q15.6 17.2 15.8 16.9Q15.9 16.7 16.0 16.6Q16.1 16.5 16.2 16.5Q16.3 16.4 16.4 16.4Q16.5 16.4 16.6 16.5Q16.6 16.5 16.7 16.7Z" fill="#FFFFFF" fill-opacity="1.00" fill-rule="evenodd" stroke-linejoin="round"/>'
490
+ '<path d="M3.7 19.8Q3.1 19.8 2.4 19.8Q2.4 12.0 2.4 4.2Q3.1 4.2 3.7 4.2Q3.8 4.2 3.8 4.1Q3.9 4.1 3.9 4.0Q3.9 3.9 3.8 3.8Q3.8 3.7 3.7 3.7Q2.8 3.7 2.0 3.7Q2.0 12.0 2.0 20.3Q2.8 20.3 3.7 20.3Q3.8 20.3 3.8 20.2Q3.9 20.1 3.9 20.0Q3.9 19.9 3.8 19.9Q3.8 19.8 3.7 19.8Z" fill="#FFFFFF" fill-opacity="1.00" fill-rule="evenodd" stroke-linejoin="round"/>'
491
+ '<path d="M20.3 20.3Q21.2 20.3 22.0 20.3Q22.0 12.0 22.0 3.7Q21.2 3.7 20.3 3.7Q20.2 3.7 20.2 3.8Q20.1 3.9 20.1 4.0Q20.1 4.1 20.2 4.1Q20.2 4.2 20.3 4.2Q20.9 4.2 21.6 4.2Q21.6 12.0 21.6 19.8Q20.9 19.8 20.3 19.8Q20.2 19.8 20.2 19.9Q20.1 19.9 20.1 20.0Q20.1 20.1 20.2 20.2Q20.2 20.3 20.3 20.3Z" fill="#FFFFFF" fill-opacity="1.00" fill-rule="evenodd" stroke-linejoin="round"/>'
492
+ '</svg>'
493
+ )
494
+
495
+
496
+ class MobjectMatrix(Matrix):
497
+ def __init__(
498
+ self,
499
+ group: Annotated[VGroup, Example("VGroup(Square(), Circle(), Triangle(), Dot())")],
500
+ n_rows: UnsignedInt | None = None,
501
+ n_cols: UnsignedInt | None = None,
502
+ height: UnsignedFloat = 4.0,
503
+ element_alignment_corner: Vect3 = ORIGIN,
504
+ **config,
505
+ ):
506
+ # Have fallback defaults of n_rows and n_cols
507
+ n_mobs = len(group)
508
+ if n_rows is None:
509
+ n_rows = int(np.sqrt(n_mobs)) if n_cols is None else n_mobs // n_cols
510
+ if n_cols is None:
511
+ n_cols = n_mobs // n_rows
512
+
513
+ if len(group) < n_rows * n_cols:
514
+ raise Exception("Input to MobjectMatrix must have at least n_rows * n_cols entries")
515
+
516
+ mob_matrix = [
517
+ [group[n * n_cols + k] for k in range(n_cols)]
518
+ for n in range(n_rows)
519
+ ]
520
+ config.update(
521
+ height=height,
522
+ element_alignment_corner=element_alignment_corner,
523
+ )
524
+ super().__init__(mob_matrix, **config)
525
+
526
+ @classmethod
527
+ async def create(
528
+ cls,
529
+ group: VGroup,
530
+ n_rows: UnsignedInt | None = None,
531
+ n_cols: UnsignedInt | None = None,
532
+ height: UnsignedFloat = 4.0,
533
+ element_alignment_corner=ORIGIN,
534
+ **config,
535
+ ) -> MobjectMatrix:
536
+ n_mobs = len(group)
537
+ if n_rows is None:
538
+ n_rows = int(np.sqrt(n_mobs)) if n_cols is None else n_mobs // n_cols
539
+ if n_cols is None:
540
+ n_cols = n_mobs // n_rows
541
+
542
+ if len(group) < n_rows * n_cols:
543
+ raise Exception("Input to MobjectMatrix must have at least n_rows * n_cols entries")
544
+
545
+ mob_matrix = [
546
+ [group[n * n_cols + k] for k in range(n_cols)]
547
+ for n in range(n_rows)
548
+ ]
549
+ config.update(
550
+ height=height,
551
+ element_alignment_corner=element_alignment_corner,
552
+ )
553
+ return await super().create(mob_matrix, **config)
554
+
555
+ def element_to_mobject(self, element: VMobject, **config) -> VMobject:
556
+ return element
557
+
558
+ async def element_to_mobject_async(self, element: VMobject, **config) -> VMobject:
559
+ return element
560
+
561
+ editor_thumbnail = (
562
+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">'
563
+ '<path d="M11.1 5.0Q7.8 5.0 4.5 5.0Q4.5 8.3 4.5 11.6Q7.8 11.6 11.1 11.6Q11.1 8.3 11.1 5.0Z" fill="none" stroke="#DDDDDD" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
564
+ '<path d="M19.4 8.3Q19.4 7.6 19.1 7.0Q18.9 6.4 18.4 6.0Q17.9 5.5 17.3 5.2Q16.7 5.0 16.1 5.0Q15.4 5.0 14.8 5.2Q14.2 5.5 13.7 6.0Q13.3 6.4 13.0 7.0Q12.8 7.6 12.8 8.3Q12.8 8.9 13.0 9.6Q13.3 10.2 13.7 10.6Q14.2 11.1 14.8 11.3Q15.4 11.6 16.1 11.6Q16.7 11.6 17.3 11.3Q17.9 11.1 18.4 10.6Q18.9 10.2 19.1 9.6Q19.4 8.9 19.4 8.3Z" fill="none" stroke="#FC6255" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
565
+ '<path d="M7.8 14.1Q6.4 16.5 5.0 19.0Q7.8 19.0 10.7 19.0Q9.2 16.5 7.8 14.1Z" fill="none" stroke="#DDDDDD" stroke-opacity="1.00" stroke-width="1.3" fill-rule="evenodd" stroke-linejoin="round"/>'
566
+ '<path d="M16.3 16.5Q16.3 16.5 16.3 16.4Q16.3 16.4 16.2 16.3Q16.2 16.3 16.2 16.3Q16.1 16.3 16.1 16.3Q16.0 16.3 16.0 16.3Q15.9 16.3 15.9 16.3Q15.8 16.4 15.8 16.4Q15.8 16.5 15.8 16.5Q15.8 16.6 15.8 16.6Q15.8 16.7 15.9 16.7Q15.9 16.8 16.0 16.8Q16.0 16.8 16.1 16.8Q16.1 16.8 16.2 16.8Q16.2 16.8 16.2 16.7Q16.3 16.7 16.3 16.6Q16.3 16.6 16.3 16.5Z" fill="#FFFFFF" fill-opacity="1.00" fill-rule="evenodd" stroke-linejoin="round"/>'
567
+ '<path d="M3.5 19.1Q3.0 19.1 2.4 19.1Q2.4 12.0 2.4 4.9Q3.0 4.9 3.5 4.9Q3.6 4.9 3.7 4.9Q3.7 4.8 3.7 4.7Q3.7 4.6 3.7 4.5Q3.6 4.5 3.5 4.5Q2.8 4.5 2.0 4.5Q2.0 12.0 2.0 19.5Q2.8 19.5 3.5 19.5Q3.6 19.5 3.7 19.5Q3.7 19.4 3.7 19.3Q3.7 19.2 3.7 19.2Q3.6 19.1 3.5 19.1Z" fill="#FFFFFF" fill-opacity="1.00" fill-rule="evenodd" stroke-linejoin="round"/>'
568
+ '<path d="M20.5 19.5Q21.2 19.5 22.0 19.5Q22.0 12.0 22.0 4.5Q21.2 4.5 20.5 4.5Q20.4 4.5 20.3 4.5Q20.3 4.6 20.3 4.7Q20.3 4.8 20.3 4.9Q20.4 4.9 20.5 4.9Q21.0 4.9 21.6 4.9Q21.6 12.0 21.6 19.1Q21.0 19.1 20.5 19.1Q20.4 19.1 20.3 19.1Q20.3 19.2 20.3 19.3Q20.3 19.4 20.3 19.5Q20.4 19.5 20.5 19.5Z" fill="#FFFFFF" fill-opacity="1.00" fill-rule="evenodd" stroke-linejoin="round"/>'
569
+ '</svg>'
570
+ )