Skip to content

The animation engine for agents: blazingly fast math and 3D videos with Manim's Python API, on a Rust GPU core.

Python

Expose public scene API

Sina Atalay2751fbc03afc
diff --git a/src/manimgx/__init__.py b/src/manimgx/__init__.py
index e8b8852b..148f5587 100644
--- a/src/manimgx/__init__.py
+++ b/src/manimgx/__init__.py
@@ -1,366 +1,127 @@
-from manimgx.animations.bases.animation import Animation
-from manimgx.animations.bases.animation_group import (
- AnimationGroup,
- LaggedStart,
- Succession,
+"""Manim's authoring API, backed by manimgx's scene, object and animation models."""
+
+import numpy as np
+
+from manimgx import audio as voices
+from manimgx.animation.easing import *
+from manimgx.animation.matching import *
+from manimgx.animation.motion import *
+from manimgx.animation.timeline import *
+from manimgx.animation.transform import Animate
+from manimgx.animation.updaters import *
+from manimgx.audio import Speech
+from manimgx.audio.sound import Sound
+from manimgx.config import Degrees, Munits, Percent, Pixels, config
+from manimgx.constants import *
+from manimgx.drawing.geometry import (
+ STRAIGHT_PATH_THRESHOLD,
+ Coefficients,
+ Floats,
+ Path,
+ QuickHull,
+ R3_to_complex,
+ Step,
+ angle_axis_from_quaternion,
+ angle_between_vectors,
+ angle_of_vector,
+ bezier,
+ carried,
+ cartesian_to_spherical,
+ center_of_mass,
+ clockwise_path,
+ compass_directions,
+ complex_func_to_R3_func,
+ complex_to_R3,
+ counterclockwise_path,
+ cross2d,
+ earclip_triangulation,
+ find_intersection,
+ get_unit_normal,
+ get_winding_number,
+ interpolate,
+ inverse_interpolate,
+ line_intersection,
+ midpoint,
+ norm_squared,
+ normalize,
+ normalize_along_axis,
+ path_along_arc,
+ path_along_circles,
+ perpendicular_bisector,
+ polylabel,
+ quaternion_conjugate,
+ quaternion_from_angle_axis,
+ quaternion_mult,
+ regular_vertices,
+ rotate_vector,
+ rotation_about_z,
+ rotation_matrix,
+ rotation_matrix_from_quaternion,
+ rotation_matrix_transpose,
+ rotation_matrix_transpose_from_quaternion,
+ shoelace,
+ shoelace_direction,
+ sigmoid,
+ spherical_to_cartesian,
+ spiral_path,
+ straight_path,
+ thick_diagonal,
+ z_to_vector,
)
-from manimgx.animations.bases.animation_on_mobject import AnimationOnMobject
-from manimgx.animations.create import Create
-from manimgx.animations.fade_in import FadeIn
-from manimgx.animations.fade_out import FadeOut
-from manimgx.animations.lagged_start_map import LaggedStartMap
-from manimgx.animations.morph import Morph
-from manimgx.animations.rotate import Rotate
-from manimgx.animations.scale_in_place import ScaleInPlace
-from manimgx.animations.tween import Tween
-from manimgx.animations.write import Write
-from manimgx.engine import Shading, Side
-from manimgx.mobjects.annulus import Annulus
-from manimgx.mobjects.arrow import Arrow
-from manimgx.mobjects.bases.fill_stroke_mobject import FillStrokeMobject
-from manimgx.mobjects.bases.mobject import Mobject
-from manimgx.mobjects.bases.planar_path import PlanarPath
-from manimgx.mobjects.bases.planar_path_mobject import PlanarPathMobject
-from manimgx.mobjects.bases.surface_mobject import Surface, SurfaceMobject
-from manimgx.mobjects.circle import Circle
-from manimgx.mobjects.cone import Cone
-from manimgx.mobjects.cube import Cube
-from manimgx.mobjects.cubic_bezier import CubicBezier
-from manimgx.mobjects.curved_arrow import CurvedArrow
-from manimgx.mobjects.cylinder import Cylinder
-from manimgx.mobjects.dashed_line import DashedLine
-from manimgx.mobjects.dot import Dot
-from manimgx.mobjects.double_arrow import DoubleArrow
-from manimgx.mobjects.ellipse import Ellipse
-from manimgx.mobjects.group import Group
-from manimgx.mobjects.hexagon import Hexagon
-from manimgx.mobjects.image import Image
-from manimgx.mobjects.line import Line
-from manimgx.mobjects.math_tex import MathTex
-from manimgx.mobjects.pentagon import Pentagon
-from manimgx.mobjects.polygon import Polygon
-from manimgx.mobjects.rectangle import Rectangle
-from manimgx.mobjects.regular_polygon import RegularPolygon
-from manimgx.mobjects.rounded_rectangle import RoundedRectangle
-from manimgx.mobjects.sector import AnnularSector
-from manimgx.mobjects.sphere import Sphere
-from manimgx.mobjects.square import Square
-from manimgx.mobjects.star import Star
-from manimgx.mobjects.tex import Tex
-from manimgx.mobjects.torus import Torus
-from manimgx.mobjects.triangle import Triangle
-from manimgx.mobjects.typst import Typst
-from manimgx.mobjects.value_tracker import ValueTracker
-from manimgx.mobjects.vector import Vector
-from manimgx.primitives.color import Color, Opacity, StrokeWidth, parse_color
-from manimgx.primitives.manim_colors import (
- BLACK,
- BLUE,
- BLUE_A,
- BLUE_B,
- BLUE_C,
- BLUE_D,
- BLUE_E,
- DARK_BLUE,
- DARK_BROWN,
- GOLD,
- GOLD_A,
- GOLD_B,
- GOLD_C,
- GOLD_D,
- GOLD_E,
- GRAY_A,
- GRAY_B,
- GRAY_C,
- GRAY_D,
- GRAY_E,
- GREEN,
- GREEN_A,
- GREEN_B,
- GREEN_C,
- GREEN_D,
- GREEN_E,
- GREY_A,
- GREY_B,
- GREY_C,
- GREY_D,
- GREY_E,
- LIGHT_BROWN,
- LIGHT_PINK,
- MAROON,
- MAROON_A,
- MAROON_B,
- MAROON_C,
- MAROON_D,
- MAROON_E,
- ORANGE,
- PINK,
- PURE_BLUE,
- PURE_GREEN,
- PURE_RED,
- PURPLE,
- PURPLE_A,
- PURPLE_B,
- PURPLE_C,
- PURPLE_D,
- PURPLE_E,
- RED,
- RED_A,
- RED_B,
- RED_C,
- RED_D,
- RED_E,
- TEAL,
- TEAL_A,
- TEAL_B,
- TEAL_C,
- TEAL_D,
- TEAL_E,
- WHITE,
- YELLOW,
- YELLOW_A,
- YELLOW_B,
- YELLOW_C,
- YELLOW_D,
- YELLOW_E,
+from manimgx.drawing.paint import *
+from manimgx.drawing.paint import stretch_array as stretch_array_to_length
+from manimgx.mobject import (
+ ComplexValueTracker,
+ Group,
+ MeshMobject,
+ Mobject,
+ Mobject1D,
+ PGroup,
+ PMobject,
+ Point,
+ ValueTracker,
+ VDict,
+ VectorizedPoint,
+ VGroup,
+ VMobject,
+ override_animate,
+ override_animation,
+ remove_list_redundancies,
)
-from manimgx.primitives.rate_functions import (
- RateFunc,
- double_smooth,
- ease_in_back,
- ease_in_bounce,
- ease_in_circ,
- ease_in_cubic,
- ease_in_elastic,
- ease_in_expo,
- ease_in_out_back,
- ease_in_out_bounce,
- ease_in_out_circ,
- ease_in_out_cubic,
- ease_in_out_elastic,
- ease_in_out_expo,
- ease_in_out_quad,
- ease_in_out_quart,
- ease_in_out_quint,
- ease_in_out_sine,
- ease_in_quad,
- ease_in_quart,
- ease_in_quint,
- ease_in_sine,
- ease_out_back,
- ease_out_bounce,
- ease_out_circ,
- ease_out_cubic,
- ease_out_elastic,
- ease_out_expo,
- ease_out_quad,
- ease_out_quart,
- ease_out_quint,
- ease_out_sine,
- exponential_decay,
- linear,
- lingering,
- running_start,
- rush_from,
- rush_into,
- scaled_func,
- slow_into,
- smooth,
- smootherstep,
- smoothstep,
- squished_func,
- there_and_back,
- there_and_back_with_pause,
- wiggle,
+from manimgx.mobjects.annotations import *
+from manimgx.mobjects.code import *
+from manimgx.mobjects.graph import *
+from manimgx.mobjects.grid import *
+from manimgx.mobjects.images import ImageMobject, ImageMobjectFromCamera
+from manimgx.mobjects.lights import *
+from manimgx.mobjects.logo import *
+from manimgx.mobjects.numbers import DecimalNumber, Integer, Variable, index_labels
+from manimgx.mobjects.plotting import *
+from manimgx.mobjects.shapes import *
+from manimgx.mobjects.shapes import PointCloudDot
+from manimgx.mobjects.svg import SVGMobject, VMobjectFromSVGPath
+from manimgx.mobjects.text import (
+ BulletedList,
+ MathTex,
+ MathTexPart,
+ MathTypst,
+ Paragraph,
+ SingleStringMathTex,
+ Tex,
+ Text,
+ Title,
+ Typst,
+)
+from manimgx.mobjects.three_d import *
+from manimgx.mobjects.vector_field import *
+from manimgx.rendering.film import Film
+from manimgx.rendering.window import Window
+from manimgx.scene import (
+ Camera,
+ LinearTransformationScene,
+ MovingCameraScene,
+ Scene,
+ ThreeDScene,
+ VectorScene,
+ ZoomedScene,
)
-from manimgx.primitives.units import PI, Angle, RunTime
-from manimgx.primitives.vector import DOWN, IN, LEFT, ORIGIN, OUT, RIGHT, UP
-from manimgx.scene import Scene
-
-__all__ = [
- "BLACK",
- "BLUE",
- "BLUE_A",
- "BLUE_B",
- "BLUE_C",
- "BLUE_D",
- "BLUE_E",
- "DARK_BLUE",
- "DARK_BROWN",
- "DOWN",
- "GOLD",
- "GOLD_A",
- "GOLD_B",
- "GOLD_C",
- "GOLD_D",
- "GOLD_E",
- "GRAY_A",
- "GRAY_B",
- "GRAY_C",
- "GRAY_D",
- "GRAY_E",
- "GREEN",
- "GREEN_A",
- "GREEN_B",
- "GREEN_C",
- "GREEN_D",
- "GREEN_E",
- "GREY_A",
- "GREY_B",
- "GREY_C",
- "GREY_D",
- "GREY_E",
- "IN",
- "LEFT",
- "LIGHT_BROWN",
- "LIGHT_PINK",
- "MAROON",
- "MAROON_A",
- "MAROON_B",
- "MAROON_C",
- "MAROON_D",
- "MAROON_E",
- "ORANGE",
- "ORIGIN",
- "OUT",
- "PI",
- "PINK",
- "PURE_BLUE",
- "PURE_GREEN",
- "PURE_RED",
- "PURPLE",
- "PURPLE_A",
- "PURPLE_B",
- "PURPLE_C",
- "PURPLE_D",
- "PURPLE_E",
- "RED",
- "RED_A",
- "RED_B",
- "RED_C",
- "RED_D",
- "RED_E",
- "RIGHT",
- "TEAL",
- "TEAL_A",
- "TEAL_B",
- "TEAL_C",
- "TEAL_D",
- "TEAL_E",
- "UP",
- "WHITE",
- "YELLOW",
- "YELLOW_A",
- "YELLOW_B",
- "YELLOW_C",
- "YELLOW_D",
- "YELLOW_E",
- "Angle",
- "Animation",
- "AnimationGroup",
- "AnimationOnMobject",
- "AnnularSector",
- "Annulus",
- "Arrow",
- "Circle",
- "Color",
- "Cone",
- "Create",
- "Cube",
- "CubicBezier",
- "CurvedArrow",
- "Cylinder",
- "DashedLine",
- "Dot",
- "DoubleArrow",
- "Ellipse",
- "FadeIn",
- "FadeOut",
- "FillStrokeMobject",
- "Group",
- "Hexagon",
- "Image",
- "LaggedStart",
- "LaggedStartMap",
- "Line",
- "MathTex",
- "Mobject",
- "Morph",
- "Opacity",
- "Pentagon",
- "PlanarPath",
- "PlanarPathMobject",
- "Polygon",
- "RateFunc",
- "Rectangle",
- "RegularPolygon",
- "Rotate",
- "RoundedRectangle",
- "RunTime",
- "ScaleInPlace",
- "Scene",
- "Shading",
- "Side",
- "Sphere",
- "Square",
- "Star",
- "StrokeWidth",
- "Succession",
- "Surface",
- "SurfaceMobject",
- "Tex",
- "Torus",
- "Triangle",
- "Tween",
- "Typst",
- "ValueTracker",
- "Vector",
- "Write",
- "double_smooth",
- "ease_in_back",
- "ease_in_bounce",
- "ease_in_circ",
- "ease_in_cubic",
- "ease_in_elastic",
- "ease_in_expo",
- "ease_in_out_back",
- "ease_in_out_bounce",
- "ease_in_out_circ",
- "ease_in_out_cubic",
- "ease_in_out_elastic",
- "ease_in_out_expo",
- "ease_in_out_quad",
- "ease_in_out_quart",
- "ease_in_out_quint",
- "ease_in_out_sine",
- "ease_in_quad",
- "ease_in_quart",
- "ease_in_quint",
- "ease_in_sine",
- "ease_out_back",
- "ease_out_bounce",
- "ease_out_circ",
- "ease_out_cubic",
- "ease_out_elastic",
- "ease_out_expo",
- "ease_out_quad",
- "ease_out_quart",
- "ease_out_quint",
- "ease_out_sine",
- "exponential_decay",
- "linear",
- "lingering",
- "parse_color",
- "running_start",
- "rush_from",
- "rush_into",
- "scaled_func",
- "slow_into",
- "smooth",
- "smootherstep",
- "smoothstep",
- "squished_func",
- "there_and_back",
- "there_and_back_with_pause",
- "wiggle",
-]
diff --git a/src/manimgx/__main__.py b/src/manimgx/__main__.py
new file mode 100644
index 00000000..dd6820e8
--- /dev/null
+++ b/src/manimgx/__main__.py
@@ -0,0 +1,5 @@
+"""`python -m manimgx`: the manimgx command line."""
+
+from manimgx.cli import main
+
+main()
diff --git a/src/manimgx/_engine.pyi b/src/manimgx/_engine.pyi
new file mode 100644
index 00000000..9969c57c
--- /dev/null
+++ b/src/manimgx/_engine.pyi
@@ -0,0 +1,226 @@
+"""manimgx's engine (Rust): typesets Typst documents, and draws a film's frames on the GPU and
+encodes them into an MP4.
+
+Shapes, brushes and images are uploaded once, under a nonzero key; a frame is then a view (48
+float32: projection, overlay, pixels, light, toward; then the background) and one 320-byte record
+per object (see `manimgx.rendering.feed`). A document is typeset in this process by Typst as a library, and
+its layout read off Typst's frames (see `manimgx.drawing.typesetting`).
+"""
+
+from collections.abc import Sequence
+
+# a camera's view, drawn into a texture that later views sample by its key:
+# (key, width, height, view, records)
+type CameraView = tuple[int, int, int, bytes, bytes]
+
+class Player:
+ """The GPU's player (natively only: in Pyodide the engine has no GPU, and a film records a
+ take instead, with `Recorder`)."""
+
+ def __init__(self, width: int, height: int, samples: int = 4) -> None: ...
+ def add_path(
+ self, key: int, points: bytes, subpaths: bytes, centroid_area: Sequence[float]
+ ) -> None:
+ """A path: its control points (float64 x, y, z; four per curve), its subpaths (uint32
+ first curve, end curve, closed, 0) and (centroid, Newell area vector) of its control
+ points."""
+
+ def add_points(self, key: int, vertices: bytes) -> None: ...
+ def add_mesh(
+ self,
+ key: int,
+ points: bytes,
+ uvs: bytes,
+ normals: bytes,
+ triangles: bytes,
+ outline: int = 0,
+ block: int = 0,
+ ) -> None:
+ """A mesh as its object defines it: its points and texture coordinates (float64 x, y, z
+ and u, v), its triangles (uint32, three each) and its normals (float64) when its geometry
+ gives them, or empty: each vertex's is then the area-weighted sum of its faces'.
+ `outline` > 2: the vertices are faces — blocks of `block` (by default `outline`), each
+ beginning with a closed loop of `outline` — stroked."""
+
+ def add_rows(self, key: int, rows: bytes) -> None: ...
+ def add_texture(self, key: int, width: int, height: int, rgba: bytes) -> None: ...
+ def add_environment(self, id: int, width: int, height: int, rgbe: bytes) -> None:
+ """An environment's picture (equirectangular RGBE rows, top to bottom), named `id` by
+ the views whose lights show it (kept as long as the player; 0 is the built-in
+ studio, which the player makes); its sun, if it has one, is lifted out of it into a
+ sun the views light by."""
+
+ def grow_path(self, key: int, points: bytes, closed: bool = False) -> None:
+ """Append curves (float64 control points, four per curve) to a path's last subpath;
+ `closed`: whether it now ends where it begins."""
+
+ def evict(self, keys: Sequence[int]) -> None:
+ """Forget shapes, brushes and textures no frame shows any more."""
+
+ def stored(self) -> tuple[int, int]:
+ """(bytes in the store's arrays, of which dead): what the arrays sent to the GPU hold."""
+
+ def render(
+ self, view: bytes, records: bytes, cameras: Sequence[CameraView] = ...
+ ) -> bytes:
+ """One frame, read back: RGBA8 rows, top to bottom."""
+
+ def begin_export(
+ self,
+ path: str,
+ fps: int = 60,
+ preset: str = "ultrafast",
+ crf: float = 18.0,
+ options: Sequence[tuple[str, str]] = ...,
+ ) -> None:
+ """Start an MP4 at `path` (x264 at `preset` and `crf`, `options` its own settings)."""
+
+ def push(
+ self,
+ view: bytes,
+ records: bytes,
+ repeat: int = 1,
+ cameras: Sequence[CameraView] = ...,
+ key: bool = False,
+ ) -> None:
+ """The next frame of the video, shown for `repeat` frames; `key`: a keyframe, where a
+ player can start (a section's first frame)."""
+
+ def abort_export(self) -> None:
+ """Abandon the video: nothing is written."""
+
+ def end_export(
+ self,
+ sound: bytes | None = None,
+ channels: int = 1,
+ rate: int = 48000,
+ bitrate: int = 192000,
+ ) -> tuple[float, float, float, int]:
+ """Finish the video, with `sound` beside it if given: float32 samples, interleaved,
+ `channels` of them, at `rate` samples a second, encoded as AAC-LC at about `bitrate`
+ bits a second. Returns (seconds, of which in x264, share of macroblocks converted,
+ bytes)."""
+
+def start_gpu() -> bool:
+ """Start bringing the GPU up, on a thread of its own, unless that has begun; whether this
+ call began it (natively only). What draws first waits for it, and so does Python as it
+ exits. A process that will draw calls it as early as it knows; one that never draws never
+ brings the GPU up."""
+
+def decode_audio(data: bytes, rate: int) -> tuple[bytes, int]:
+ """A file's audio (its bytes, any container and codec the engine's FFmpeg decodes: WAV,
+ AIFF, CAF, MP3, AAC, Opus, Vorbis, FLAC, ALAC; in MP4, MOV, WebM, Matroska) at `rate` samples
+ a second, starting and ending where the file declares: float32 samples, interleaved, and how
+ many channels (1 or 2: wider sound is mixed down to stereo)."""
+
+def resample_audio(samples: bytes, channels: int, rate: float, to: float) -> bytes:
+ """Interleaved float32 samples of `channels` channels at `rate` samples a second,
+ resampled to `to`."""
+
+def read_hdr(data: bytes) -> tuple[int, int, bytes]:
+ """A Radiance (.hdr) file's picture (its bytes) as an environment keeps it: its width,
+ height, and RGBE pixels row by row from the top, halved until no wider than 4096."""
+
+class Recorder:
+ """A take being recorded: the engine's calls — the same uploads a player takes, then frames —
+ written as the stream manimgx's player (in a window, or a page) plays back. It
+ draws nothing."""
+
+ def __init__(self, width: int, height: int, fps: float) -> None: ...
+ def add_path(
+ self, key: int, points: bytes, subpaths: bytes, centroid_area: Sequence[float]
+ ) -> None: ...
+ def add_points(self, key: int, vertices: bytes) -> None: ...
+ def add_mesh(
+ self,
+ key: int,
+ points: bytes,
+ uvs: bytes,
+ normals: bytes,
+ triangles: bytes,
+ outline: int = 0,
+ block: int = 0,
+ ) -> None: ...
+ def add_rows(self, key: int, rows: bytes) -> None: ...
+ def add_texture(self, key: int, width: int, height: int, rgba: bytes) -> None: ...
+ def add_environment(
+ self, id: int, width: int, height: int, rgbe: bytes
+ ) -> None: ...
+ def grow_path(self, key: int, points: bytes, closed: bool = False) -> None: ...
+ def evict(self, keys: Sequence[int]) -> None: ...
+ def stored(self) -> tuple[int, int]:
+ """(0, 0): a take holds nothing on a GPU."""
+
+ def frame(
+ self,
+ view: bytes,
+ records: bytes,
+ repeat: int = 1,
+ cameras: Sequence[CameraView] = ...,
+ ) -> None:
+ """The next frame, shown for `repeat` frames (as a player's `push`)."""
+
+ def note(self, json: str) -> None:
+ """A note for whoever shows the take (JSON: a play that ended, a section, the
+ captions)."""
+
+ def sound(self, file: bytes) -> None:
+ """The film's sound: an audio file, which the player plays beside the frames."""
+
+ def end(self, failed: bool = False) -> None:
+ """The take's end: its film ended, or (`failed`) its scene failed."""
+
+ def drain(self) -> bytes:
+ """What has been recorded since the last drain."""
+
+def note(json: str) -> bytes:
+ """A note on its own: a message of the take's stream that belongs to no take (the file's
+ scenes, an error)."""
+
+def web() -> tuple[str, bytes] | None:
+ """The player for a page, this engine built for the browser: wasm-bindgen's JS and the
+ WebAssembly it loads, which Pyodide's engine carries; None in any other (natively, a film
+ plays in a window: `window`), or one built without it (no wasm32-unknown-unknown target).
+ """
+
+def window(title: str, time: float = 0.0, fonts: Sequence[str] = ...) -> None:
+ """Open manimgx's player in a window on this machine's screen, playing the takes that come
+ on standard input, until the window is closed or its input ends. It starts at `time`
+ seconds; its text is set in the fonts under `fonts`. Natively only."""
+
+def digest(*parts: bytes) -> int:
+ """The content key of the parts' bytes, taken as one stream (xxh3, 64 bits, never 0): what
+ names an upload, so that equal content is uploaded once."""
+
+class TypstError(Exception):
+ """Typst could not typeset a document (its errors, joined)."""
+
+def typeset(
+ source: str, font_paths: Sequence[str], packages: str | None = None
+) -> tuple[bytes, list[bytes], list[tuple[str, list[int]]], bool]:
+ """Typeset `source` (Typst): its items as float64 rows of 23 (kind, key, placement a b c d e f,
+ fill rgba, stroke rgba, stroke width, advance, node start, end, drawn start, end, node kind),
+ its shapes' cubic points (float64 x y z), its labelled groups (a label and the items inside
+ it) and whether it needed the system's fonts."""
+
+def glyph_outlines(keys: Sequence[int]) -> list[bytes]:
+ """Each key's outline as cubic points (float64 x y z, font units, y up); empty: blank."""
+
+def ligature_carets(key: int) -> list[float]:
+ """A ligature glyph's carets from its font (font units); empty: the font gives none."""
+
+def graphemes(text: str) -> list[int]:
+ """Where `text`'s graphemes start, in characters."""
+
+def mitex_math(latex: str) -> str:
+ """LaTeX math as Typst math (mitex); raises TypstError on what it can't convert."""
+
+def mitex_text(latex: str) -> str:
+ """LaTeX text as Typst markup (mitex); raises TypstError on what it can't convert."""
+
+def system_fonts_fingerprint() -> int:
+ """The system's fonts' fingerprint (their files' paths, sizes and times), once per process."""
+
+def face_fonts(dirs: Sequence[str]) -> list[bytes]:
+ """The fonts a player's face is set in: the font files in `dirs` (manimgx's), and Typst's
+ monospace one (DejaVu Sans Mono), each file's bytes."""
diff --git a/src/manimgx/animations/__init__.py b/src/manimgx/animations/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/manimgx/animations/bases/__init__.py b/src/manimgx/animations/bases/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/manimgx/animations/bases/animation.py b/src/manimgx/animations/bases/animation.py
deleted file mode 100644
index 3b9bb58c..00000000
--- a/src/manimgx/animations/bases/animation.py
+++ /dev/null
@@ -1,37 +0,0 @@
-from abc import ABC, abstractmethod
-from dataclasses import dataclass
-from typing import TYPE_CHECKING
-
-from manimgx.primitives.rate_functions import RateFunc, smooth
-from manimgx.primitives.units import RunTime
-
-if TYPE_CHECKING:
- from manimgx.mobjects.bases.mobject import Mobject
- from manimgx.scene import _Timeline
-
-
-@dataclass(kw_only=True)
-class Animation(ABC):
- run_time: RunTime = 1.0
- rate_func: RateFunc = smooth
-
- def __post_init__(self) -> None:
- self.run_time = max(0.0, self.run_time)
-
- def _scene_mobjects(self) -> "tuple[Mobject, ...]":
- """Mobjects this animation needs registered in the scene.
-
- This is intentionally explicit. Reference mobjects like ``Morph.target``
- should stay available to the animation without becoming visible just
- because they happen to be stored on the dataclass.
- """
- return ()
-
- def _register_scene_mobjects(self, builder: "_Timeline") -> None:
- for mobject in self._scene_mobjects():
- builder._register(mobject)
-
- def _prepare(self) -> None: ... # noqa: B027
-
- @abstractmethod
- def _play(self, builder: "_Timeline", run_time: float) -> None: ...
diff --git a/src/manimgx/animations/bases/animation_group.py b/src/manimgx/animations/bases/animation_group.py
deleted file mode 100644
index a5c96844..00000000
--- a/src/manimgx/animations/bases/animation_group.py
+++ /dev/null
@@ -1,51 +0,0 @@
-from typing import TYPE_CHECKING, Any
-
-from manimgx.animations.bases.animation import Animation
-from manimgx.primitives.rate_functions import RateFunc, linear
-from manimgx.primitives.units import RunTime
-
-if TYPE_CHECKING:
- from manimgx.scene import _Timeline
-
-
-class AnimationGroup(Animation):
- def __init__(
- self,
- *animations: Animation,
- lag_ratio: float = 0.0,
- run_time: RunTime = 1.0,
- rate_func: RateFunc = linear,
- ):
- self.animations = list(animations)
- self.lag_ratio = lag_ratio
- super().__init__(run_time=run_time, rate_func=rate_func)
-
- def _play(self, builder: "_Timeline", run_time: float) -> None:
- if not self.animations:
- return
- sub = builder._create_sub_timeline(run_time, self.rate_func)
- n = len(self.animations)
- total_slots = 1.0 + (n - 1) * self.lag_ratio
- child_dur = run_time / total_slots
- step = self.lag_ratio * child_dur
-
- if self.lag_ratio < 1.0:
- for anim in self.animations:
- anim._prepare()
- for i, anim in enumerate(self.animations):
- sub._cursor = i * step
- sub._play_prepared(anim, run_time=child_dur)
- else:
- for i, anim in enumerate(self.animations):
- sub._cursor = i * step
- sub.play(anim, run_time=child_dur)
-
-
-class Succession(AnimationGroup):
- def __init__(self, *animations: Animation, lag_ratio: float = 1.0, **kw: Any):
- super().__init__(*animations, lag_ratio=lag_ratio, **kw)
-
-
-class LaggedStart(AnimationGroup):
- def __init__(self, *animations: Animation, lag_ratio: float = 0.05, **kw: Any):
- super().__init__(*animations, lag_ratio=lag_ratio, **kw)
diff --git a/src/manimgx/animations/bases/animation_on_mobject.py b/src/manimgx/animations/bases/animation_on_mobject.py
deleted file mode 100644
index e225f073..00000000
--- a/src/manimgx/animations/bases/animation_on_mobject.py
+++ /dev/null
@@ -1,25 +0,0 @@
-from abc import abstractmethod
-from dataclasses import dataclass
-from typing import TYPE_CHECKING
-
-from manimgx.animations.bases.animation import Animation
-from manimgx.mobjects.bases.mobject import Mobject
-
-if TYPE_CHECKING:
- from manimgx.scene import _Timeline
-
-
-@dataclass
-class AnimationOnMobject[M: Mobject](Animation):
- mobject: M
-
- def _scene_mobjects(self) -> tuple[Mobject, ...]:
- return (self.mobject,)
-
- def _play(self, builder: "_Timeline", run_time: float) -> None:
- self._register_scene_mobjects(builder)
- builder._add_entry(self._interpolate, run_time, self.rate_func)
- self._interpolate(self.rate_func(1.0))
-
- @abstractmethod
- def _interpolate(self, alpha: float) -> None: ...
diff --git a/src/manimgx/animations/create.py b/src/manimgx/animations/create.py
deleted file mode 100644
index 2b383563..00000000
--- a/src/manimgx/animations/create.py
+++ /dev/null
@@ -1,10 +0,0 @@
-from dataclasses import dataclass
-
-from manimgx.animations.bases.animation_on_mobject import AnimationOnMobject
-from manimgx.mobjects.bases.planar_path_mobject import PlanarPathMobject
-
-
-@dataclass
-class Create(AnimationOnMobject[PlanarPathMobject]):
- def _interpolate(self, alpha: float) -> None:
- pass # TODO: implement using set_partial / reset_partial
diff --git a/src/manimgx/animations/fade_in.py b/src/manimgx/animations/fade_in.py
deleted file mode 100644
index 00a142df..00000000
--- a/src/manimgx/animations/fade_in.py
+++ /dev/null
@@ -1,31 +0,0 @@
-from dataclasses import dataclass
-
-from manimgx.animations.bases.animation_on_mobject import AnimationOnMobject
-from manimgx.mobjects.bases.fill_stroke_mobject import FillStrokeMobject
-from manimgx.mobjects.bases.mobject import Mobject
-
-
-@dataclass
-class _FadeBase(AnimationOnMobject):
- def _prepare(self) -> None:
- self._snapshots: list[tuple[Mobject, str, float]] = []
- for sub in self.mobject.iter_submobjects:
- if isinstance(sub, FillStrokeMobject):
- self._snapshots.append((sub, "fill_opacity", sub.fill_opacity))
- self._snapshots.append((sub, "stroke_opacity", sub.stroke_opacity))
- else:
- self._snapshots.append((sub, "opacity", sub.opacity))
-
- def _opacity_factor(self, alpha: float) -> float:
- raise NotImplementedError
-
- def _interpolate(self, alpha: float) -> None:
- factor = self._opacity_factor(alpha)
- for sub, field, start_val in self._snapshots:
- setattr(sub, field, start_val * factor)
-
-
-@dataclass
-class FadeIn(_FadeBase):
- def _opacity_factor(self, alpha: float) -> float:
- return alpha
diff --git a/src/manimgx/animations/fade_out.py b/src/manimgx/animations/fade_out.py
deleted file mode 100644
index bd03f710..00000000
--- a/src/manimgx/animations/fade_out.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from dataclasses import dataclass
-
-from manimgx.animations.fade_in import _FadeBase
-
-
-@dataclass
-class FadeOut(_FadeBase):
- def _opacity_factor(self, alpha: float) -> float:
- return 1.0 - alpha
diff --git a/src/manimgx/animations/lagged_start_map.py b/src/manimgx/animations/lagged_start_map.py
deleted file mode 100644
index f594a7c5..00000000
--- a/src/manimgx/animations/lagged_start_map.py
+++ /dev/null
@@ -1,24 +0,0 @@
-from typing import Any
-
-from manimgx.animations.bases.animation_group import LaggedStart
-from manimgx.animations.bases.animation_on_mobject import AnimationOnMobject
-from manimgx.mobjects.bases.mobject import Mobject
-from manimgx.primitives.rate_functions import RateFunc, linear
-from manimgx.primitives.units import RunTime
-
-
-class LaggedStartMap(LaggedStart):
- def __init__(
- self,
- animation_class: type[AnimationOnMobject[Any]],
- mobject: Mobject,
- *,
- run_time: RunTime = 2.0,
- rate_func: RateFunc = linear,
- **kw: Any,
- ) -> None:
- animations = [
- animation_class(mobject=child, rate_func=rate_func)
- for child in mobject.direct_submobjects
- ]
- super().__init__(*animations, run_time=run_time, **kw)
diff --git a/src/manimgx/animations/morph.py b/src/manimgx/animations/morph.py
deleted file mode 100644
index 5e470579..00000000
--- a/src/manimgx/animations/morph.py
+++ /dev/null
@@ -1,15 +0,0 @@
-from dataclasses import dataclass, field
-
-from manimgx.animations.bases.animation_on_mobject import AnimationOnMobject
-from manimgx.mobjects.bases.mobject import Mobject
-
-
-@dataclass
-class Morph(AnimationOnMobject):
- target: Mobject = field(kw_only=True)
-
- def _prepare(self) -> None:
- pass # TODO: reimplement without engine-level morph
-
- def _interpolate(self, alpha: float) -> None:
- pass # TODO: reimplement without engine-level morph
diff --git a/src/manimgx/animations/rotate.py b/src/manimgx/animations/rotate.py
deleted file mode 100644
index d45ac182..00000000
--- a/src/manimgx/animations/rotate.py
+++ /dev/null
@@ -1,34 +0,0 @@
-from dataclasses import dataclass, field
-
-import numpy as np
-
-from manimgx.animations.bases.animation_on_mobject import AnimationOnMobject
-from manimgx.mobjects.bases.mobject import Mobject
-from manimgx.primitives.quaternion import (
- quat_from_angle_axis,
- quat_multiply,
- quat_rotate_vectors,
-)
-from manimgx.primitives.units import PI
-from manimgx.primitives.vector import Vec3, Vec4
-
-
-@dataclass
-class Rotate(AnimationOnMobject):
- angle: float = PI
- axis: tuple[float, float, float] = field(default=(0.0, 0.0, 1.0), kw_only=True)
-
- def _prepare(self) -> None:
- self._pivot = self.mobject.center.copy()
- self._axis = np.asarray(self.axis)
- self._starts: list[tuple[Mobject, Vec3, Vec4]] = [
- (sub, sub.position.copy(), sub.quaternion.copy())
- for sub in self.mobject.iter_submobjects
- ]
-
- def _interpolate(self, alpha: float) -> None:
- q = quat_from_angle_axis(self.angle * alpha, self._axis)
- for sub, start_pos, start_quat in self._starts:
- offset = (start_pos - self._pivot).reshape(1, 3)
- sub.position = self._pivot + quat_rotate_vectors(q, offset).reshape(3)
- sub.quaternion = quat_multiply(q, start_quat)
diff --git a/src/manimgx/animations/scale_in_place.py b/src/manimgx/animations/scale_in_place.py
deleted file mode 100644
index 6bb4c4b9..00000000
--- a/src/manimgx/animations/scale_in_place.py
+++ /dev/null
@@ -1,23 +0,0 @@
-from dataclasses import dataclass
-
-from manimgx.animations.bases.animation_on_mobject import AnimationOnMobject
-from manimgx.mobjects.bases.mobject import Mobject
-from manimgx.primitives.vector import Vec3
-
-
-@dataclass
-class ScaleInPlace(AnimationOnMobject):
- scale_factor: float
-
- def _prepare(self) -> None:
- self._pivot = self.mobject.center.copy()
- self._starts: list[tuple[Mobject, Vec3, Vec3]] = [
- (sub, sub.position.copy(), sub.scale_vec.copy())
- for sub in self.mobject.iter_submobjects
- ]
-
- def _interpolate(self, alpha: float) -> None:
- factor = 1.0 + (self.scale_factor - 1.0) * alpha
- for sub, start_pos, start_scale in self._starts:
- sub.scale_vec = start_scale * factor
- sub.position = self._pivot + factor * (start_pos - self._pivot)
diff --git a/src/manimgx/animations/tween.py b/src/manimgx/animations/tween.py
deleted file mode 100644
index e0bea88f..00000000
--- a/src/manimgx/animations/tween.py
+++ /dev/null
@@ -1,126 +0,0 @@
-from typing import TYPE_CHECKING, Any
-
-import numpy as np
-
-from manimgx.animations.bases.animation import Animation
-from manimgx.primitives.color import parse_color
-from manimgx.primitives.rate_functions import RateFunc, smooth
-from manimgx.primitives.units import RunTime
-
-if TYPE_CHECKING:
- from manimgx.mobjects.bases.mobject import Mobject
- from manimgx.scene import _Timeline
-
-
-class Tween(Animation):
- """Tween arbitrary dataclass fields on any target (Mobject or ValueTracker).
-
- For Mobject targets, the mobject is automatically registered with the
- timeline so it becomes visible. For non-Mobject targets (e.g.
- ValueTracker), only the interpolation entry is scheduled.
- """
-
- def __init__(
- self,
- target: Any,
- *,
- run_time: RunTime = 1.0,
- rate_func: RateFunc = smooth,
- **targets: Any,
- ) -> None:
- if not targets:
- msg = "Tween requires at least one target keyword argument"
- raise ValueError(msg)
- self._target = target
- self._targets = targets
- super().__init__(run_time=run_time, rate_func=rate_func)
-
- def _prepare(self) -> None:
- self._lerps: list[_Lerp] = []
- for name, target in self._targets.items():
- if not hasattr(self._target, name):
- msg = f"{type(self._target).__name__} has no attribute {name!r}"
- raise AttributeError(msg)
- start = getattr(self._target, name)
- self._lerps.append(_make_lerp(name, start, target))
-
- def _play(self, builder: "_Timeline", run_time: float) -> None:
- self._register_scene_mobjects(builder)
- builder._add_entry(self._interpolate, run_time, self.rate_func)
- self._interpolate(self.rate_func(1.0))
-
- def _interpolate(self, alpha: float) -> None:
- for lerp in self._lerps:
- setattr(self._target, lerp.name, lerp.at(alpha))
-
- def _scene_mobjects(self) -> "tuple[Mobject, ...]":
- from manimgx.mobjects.bases.mobject import Mobject
-
- if isinstance(self._target, Mobject):
- return (self._target,)
- return ()
-
-
-class _Lerp:
- __slots__ = ("name",)
-
- def __init__(self, name: str) -> None:
- self.name = name
-
- def at(self, alpha: float) -> Any:
- raise NotImplementedError
-
-
-class _FloatLerp(_Lerp):
- __slots__ = ("_start", "_target")
-
- def __init__(self, name: str, start: float, target: float) -> None:
- super().__init__(name)
- self._start = start
- self._target = target
-
- def at(self, alpha: float) -> float:
- return self._start + alpha * (self._target - self._start)
-
-
-class _ArrayLerp(_Lerp):
- __slots__ = ("_start", "_target")
-
- def __init__(self, name: str, start: np.ndarray, target: np.ndarray) -> None:
- super().__init__(name)
- self._start = start.copy()
- self._target = target
-
- def at(self, alpha: float) -> np.ndarray:
- return self._start + alpha * (self._target - self._start)
-
-
-class _ColorLerp(_Lerp):
- __slots__ = ("_start_rgb", "_target_rgb")
-
- def __init__(self, name: str, start_color: str, target_color: str) -> None:
- super().__init__(name)
- self._start_rgb = parse_color(start_color)
- self._target_rgb = parse_color(target_color)
-
- def at(self, alpha: float) -> str:
- sr, sg, sb = self._start_rgb
- tr, tg, tb = self._target_rgb
- r = int(sr + alpha * (tr - sr))
- g = int(sg + alpha * (tg - sg))
- b = int(sb + alpha * (tb - sb))
- return f"#{r:02x}{g:02x}{b:02x}"
-
-
-def _make_lerp(name: str, start: Any, target: Any) -> _Lerp:
- if isinstance(start, str):
- if not isinstance(target, str):
- msg = f"Field {name!r}: expected str target, got {type(target).__name__}"
- raise TypeError(msg)
- return _ColorLerp(name, start, target)
- if isinstance(start, np.ndarray):
- return _ArrayLerp(name, start, np.asarray(target))
- if isinstance(start, (int, float)):
- return _FloatLerp(name, float(start), float(target))
- msg = f"Field {name!r}: unsupported type {type(start).__name__} for tweening"
- raise TypeError(msg)
diff --git a/src/manimgx/animations/write.py b/src/manimgx/animations/write.py
deleted file mode 100644
index 5f80ab9c..00000000
--- a/src/manimgx/animations/write.py
+++ /dev/null
@@ -1,16 +0,0 @@
-from dataclasses import dataclass, field
-
-from manimgx.animations.bases.animation_on_mobject import AnimationOnMobject
-from manimgx.mobjects.bases.planar_path_mobject import PlanarPathMobject
-from manimgx.primitives.rate_functions import RateFunc, smooth
-from manimgx.primitives.units import RunTime
-
-
-@dataclass
-class Write(AnimationOnMobject[PlanarPathMobject]):
- fill_lag: float = field(default=0.5, kw_only=True)
- rate_func: RateFunc = field(default=smooth, kw_only=True)
- run_time: RunTime = field(default=2.0, kw_only=True)
-
- def _interpolate(self, alpha: float) -> None:
- pass # TODO: implement using set_partial / reset_partial
diff --git a/src/manimgx/cli/__init__.py b/src/manimgx/cli/__init__.py
index ef8a57e8..741d524c 100644
--- a/src/manimgx/cli/__init__.py
+++ b/src/manimgx/cli/__init__.py
@@ -59,7 +59,7 @@ def manimgx(
),
] = False,
) -> None:
- """Render Manim Community Edition scenes on a fast GPU engine.
+ """The animation engine for agents: blazingly fast math and 3D videos with Manim's Python API, on a Rust GPU core.
A scene file is Manim CE code: `import manimgx as m`, a class deriving m.Scene, its
`construct`. Work in a loop:
diff --git a/src/manimgx/cli/scenes.py b/src/manimgx/cli/scenes.py
index 8ff2968c..60193493 100644
--- a/src/manimgx/cli/scenes.py
+++ b/src/manimgx/cli/scenes.py
@@ -19,7 +19,7 @@ from rich.console import Console
import manimgx
from manimgx.animation.timeline import Animation
from manimgx.config import Config, config
-from manimgx.rendering.film import Film, FrameSink, Play
+from manimgx.rendering.film import Film, FrameSink, Play, X264Preset
from manimgx.scene import Scene
@@ -286,6 +286,8 @@ def take(
video: str | os.PathLike[str] | None = None,
frames: FrameSink | None = None,
plays: Watch | None = None,
+ preset: X264Preset = "ultrafast",
+ crf: float = 18.0,
) -> tuple[Scene, Film]:
"""Run the scene at `look`, making its film (and video, frames and plays, as asked). On a
terminal, a status line on stderr follows the plays as they end."""
@@ -306,6 +308,8 @@ def take(
if plays is not None:
plays(made, play, did)
- return made, made.render(video, frames=frames, plays=hook)
+ return made, made.render(
+ video, frames=frames, plays=hook, preset=preset, crf=crf
+ )
except Exception as error:
raise fail(report_error(error), 1) from None
diff --git a/src/manimgx/config.py b/src/manimgx/config.py
index 05254ed6..6073eb14 100644
--- a/src/manimgx/config.py
+++ b/src/manimgx/config.py
@@ -5,8 +5,9 @@
"""Global scene configuration (a small, typed subset of CE's `config`)."""
-from dataclasses import dataclass
+from dataclasses import dataclass, field
from typing import Literal, overload
+from warnings import deprecated
import numpy as np
@@ -26,13 +27,17 @@ class Config:
takes the video's size and frame rate when it starts. It can be read and set as a
dictionary too, as Manim code does: `config["frame_width"]`,
`config["pixel_height"] = 720`.
+
+ The frame has the video's proportions, and its short side is 8 units: a wide video
+ (16:9) shows about 14.2 × 8 units, a tall one (9:16) 8 × 14.2. So what fits in the
+ 8 × 8 square at the center fits both, at the same size.
"""
pixel_width: int = 1920
"""The width of the video, in pixels (default 1920)."""
pixel_height: int = 1080
- """The height of the video, in pixels (default 1080). The frame has the video's
- proportions: `frame_height` tall, and as wide as they make it."""
+ """The height of the video, in pixels (default 1080). For a tall video (9:16), make
+ it the larger: `config.pixel_width, config.pixel_height = 1080, 1920`."""
frame_rate: float = 60
"""How many frames a second the film has (default 60): frame k shows the scene at
exactly k / `frame_rate` seconds. A video needs a whole number."""
@@ -46,18 +51,31 @@ class Config:
frames a second each frame is a tick, so the ticks cost nothing more; at a frame
rate that divides it (10, 12, 15, 20, 30), every frame falls on a tick too.
"""
- frame_height: float = 8.0
- """The height of the frame, in scene units (default 8); its width follows from the
- video's proportions."""
background_color: ParsableManimColor = BLACK
"""The color of the background (default black)."""
background_opacity: float = 1.0
"""The opacity of the background, from 0 to 1 (default 1)."""
+ _frame_height: float | None = field(default=None, repr=False)
+ """The frame's height as set, if it was (`frame_height`)."""
+
+ @property
+ def frame_height(self) -> float:
+ """The height of the frame, in scene units. Unless set, the frame's short side is
+ 8 units: a wide video's frame is 8 high, a tall one's as high as its proportions
+ make it when it is 8 wide (about 14.2 at 9:16). Its width follows from the
+ video's proportions."""
+ if self._frame_height is not None:
+ return self._frame_height
+ return 8.0 * max(1.0, self.pixel_height / self.pixel_width)
+
+ @frame_height.setter
+ def frame_height(self, value: float) -> None:
+ self._frame_height = value
@property
def frame_width(self) -> float:
"""The width of the frame, in scene units: `frame_height` times the video's
- aspect ratio (about 14.2 at 16:9)."""
+ aspect ratio (about 14.2 at 16:9, 8 at 9:16)."""
return self.frame_height * self.pixel_width / self.pixel_height
@property
@@ -67,7 +85,7 @@ class Config:
@property
def frame_y_radius(self) -> float:
- """Half the frame's height, in scene units (4 by default): the y of its top
+ """Half the frame's height, in scene units (4 for a wide video): the y of its top
edge."""
return self.frame_height / 2
@@ -156,7 +174,6 @@ config = Config()
class _PixelUnits:
-
def __mul__(self, val: float) -> float:
return val * config.frame_width / config.pixel_width
@@ -164,6 +181,9 @@ class _PixelUnits:
return val * config.frame_width / config.pixel_width
+@deprecated(
+ "use a fraction of config.frame_width or config.frame_height", category=None
+)
class Percent:
"""A length as a percentage of the frame's width or height: `25 * Percent(X_AXIS)`
is a quarter of the frame's width, in scene units.
diff --git a/src/manimgx/engine.pyi b/src/manimgx/engine.pyi
deleted file mode 100644
index 2b93e09f..00000000
--- a/src/manimgx/engine.pyi
+++ /dev/null
@@ -1,254 +0,0 @@
-import pathlib
-from collections.abc import Callable
-from typing import ClassVar
-
-from manimgx.primitives.vector import Vec3, Vec4
-
-__all__ = [
- "Camera",
- "FillRule",
- "Material",
- "Mesh",
- "Object3D",
- "PathCommand",
- "Renderer",
- "Shading",
- "Side",
- "Surface",
- "SvgGlyphData",
- "TessellationResult",
- "build_surface",
- "tessellate",
- "tessellate_svg",
-]
-
-# ── Geometry & appearance ────────────────────────────────────────────
-
-class Mesh:
- """Immutable triangulated geometry living on the GPU."""
-
- bounds: tuple[float, float, float, float, float, float]
- @staticmethod
- def empty() -> Mesh: ...
-
-class Shading:
- UNLIT: ClassVar[Shading]
- FLAT: ClassVar[Shading]
- SMOOTH: ClassVar[Shading]
-
-class Side:
- FRONT: ClassVar[Side]
- BACK: ClassVar[Side]
- BOTH: ClassVar[Side]
-
-class Material:
- """Surface appearance — color, transparency, lighting model."""
-
- def __init__(
- self,
- *,
- color: tuple[int, int, int] = (255, 255, 255),
- opacity: float = 1.0,
- shading: Shading = ...,
- side: Side = ...,
- metallic: float = 0.0,
- roughness: float = 0.5,
- emissive: tuple[int, int, int] = (0, 0, 0),
- ) -> None: ...
-
- color: tuple[int, int, int]
- opacity: float
- shading: Shading
- side: Side
- metallic: float
- roughness: float
- emissive: tuple[int, int, int]
-
-class Surface:
- """Geometry + appearance — **what to draw**.
-
- Pairs a Mesh with a Material. Carries no transform of its own.
- Attach to an Object3D (which controls *where* it is drawn).
- """
-
- def __init__(self, mesh: Mesh, material: Material) -> None: ...
- @property
- def mesh(self) -> Mesh: ...
- @mesh.setter
- def mesh(self, value: Mesh) -> None: ...
- @property
- def material(self) -> Material: ...
- @material.setter
- def material(self, value: Material) -> None: ...
-
- active: bool
- z_index: float
-
-# ── Scene graph ──────────────────────────────────────────────────────
-
-class Object3D:
- """Transform + grouping — absolute scene coordinates.
-
- An Object3D holds one or more Surfaces (the visual layers) and
- a transform (position, scale, quaternion). All coordinates are
- absolute — there is no local/world distinction.
-
- The ``parent`` link is a **grouping mechanism**: it defines "who
- moves with me" (for ``shift``/``rotate``/``apply_scale``) and
- cascading visibility. It does NOT define a coordinate space.
-
- **Property setters** set this object only — no propagation::
-
- obj.position = np.array([1.0, 0.0, 0.0]) # just this object
-
- **Group-transform methods** propagate to all descendants (in Rust)::
-
- obj.shift(RIGHT) # this object + all descendants
- obj.rotate(q, center) # this object + all descendants orbit
- obj.apply_scale(s, center) # this object + all descendants scale
-
- Visibility cascades: if ``active`` is False, all Surfaces on
- this object and any descendant are hidden.
- """
-
- def __init__(self, *surfaces: Surface) -> None: ...
- @property
- def surfaces(self) -> list[Surface]: ...
-
- # ── Transform (absolute scene coordinates) ───────────────────────
- @property
- def position(self) -> Vec3: ...
- @position.setter
- def position(self, value: Vec3) -> None: ...
- @property
- def scale(self) -> Vec3: ...
- @scale.setter
- def scale(self, value: Vec3) -> None: ...
- @property
- def quaternion(self) -> Vec4: ...
- @quaternion.setter
- def quaternion(self, value: Vec4) -> None: ...
-
- # ── Grouping ─────────────────────────────────────────────────────
- @property
- def parent(self) -> Object3D | None: ...
- @parent.setter
- def parent(self, value: Object3D | None) -> None: ...
-
- active: bool
-
- # ── Group transforms (propagate to all descendants) ──────────────
- def shift(self, offset: Vec3) -> None:
- """Shift this object and all descendants by *offset*."""
-
- def rotate(self, quaternion: Vec4, about: Vec3 | None = None) -> None:
- """Rotate this object and all descendants.
-
- *about* defaults to this object's position (rotate in place,
- descendants orbit around this object).
- """
-
- def apply_scale(self, factor: Vec3, about: Vec3 | None = None) -> None:
- """Scale this object and all descendants.
-
- *about* defaults to this object's position (scale outward from
- this object).
- """
-
-class Camera:
- """Controls the visible region and viewpoint."""
-
- def __init__(
- self,
- *,
- frame_height: float = 8.0,
- background: tuple[int, int, int] = (0, 0, 0),
- ) -> None: ...
-
- frame_height: float
- background: tuple[int, int, int]
- projection: int # 0 = orthographic (default), 1 = perspective
- fov: float # degrees, used when projection=1
-
- @property
- def position(self) -> Vec3: ...
- @position.setter
- def position(self, value: Vec3) -> None: ...
- @property
- def quaternion(self) -> Vec4: ...
- @quaternion.setter
- def quaternion(self, value: Vec4) -> None: ...
-
-class Renderer:
- """Drives the Metal GPU pipeline.
-
- 1. Create Object3Ds with Surfaces and add them.
- 2. Set a Camera.
- 3. Call render — the engine calls evaluate_frame(time) for each frame,
- you mutate Material/Object3D/Camera properties, the engine draws.
- """
-
- def __init__(self) -> None: ...
- def add(self, object3d: Object3D) -> None: ...
- def set_camera(self, camera: Camera) -> None: ...
- def render(
- self,
- *,
- evaluate_frame: Callable[[float], None],
- total_duration: float,
- output: pathlib.Path,
- width: int = 1920,
- height: int = 1080,
- fps: int = 60,
- supersample: int = 1,
- ) -> None: ...
-
-# ── Tessellation (2D paths → Mesh) ─────────────────────────────────
-
-class PathCommand:
- """SVG-style path verbs for tessellate()."""
-
- MOVE_TO: ClassVar[int]
- LINE_TO: ClassVar[int]
- CUBIC_TO: ClassVar[int]
- QUAD_TO: ClassVar[int]
- CLOSE: ClassVar[int]
-
-class FillRule:
- NON_ZERO: ClassVar[FillRule]
- EVEN_ODD: ClassVar[FillRule]
-
-class TessellationResult:
- """Output of tessellate() — separate fill and stroke meshes."""
-
- @property
- def fill_mesh(self) -> Mesh | None: ...
- @property
- def stroke_mesh(self) -> Mesh | None: ...
-
-class SvgGlyphData:
- """One glyph from tessellate_svg(), preserving its original color."""
-
- @property
- def fill_mesh(self) -> Mesh | None: ...
- @property
- def stroke_mesh(self) -> Mesh | None: ...
- @property
- def color(self) -> tuple[int, int, int]: ...
-
-def tessellate(
- command_types: list[int],
- command_data: list[float],
- *,
- fill_rule: FillRule = FillRule.NON_ZERO,
- stroke_width: float = 0.0,
-) -> TessellationResult: ...
-def tessellate_svg(svg_bytes: bytes) -> list[SvgGlyphData]: ...
-
-# ── 3D surface builders ───────────────────────────────────────────
-
-def build_surface(
- positions: list[float],
- normals: list[float],
- indices: list[int],
-) -> Mesh: ...
diff --git a/src/manimgx/mobjects/annulus.py b/src/manimgx/mobjects/annulus.py
deleted file mode 100644
index 5c298d77..00000000
--- a/src/manimgx/mobjects/annulus.py
+++ /dev/null
@@ -1,14 +0,0 @@
-from dataclasses import dataclass
-
-from manimgx.mobjects.bases.planar_path import PlanarPath
-from manimgx.mobjects.bases.planar_path_mobject import PlanarPathMobject
-
-
-@dataclass(kw_only=True, eq=False)
-class Annulus(PlanarPathMobject):
- inner_radius: float = 0.5
- outer_radius: float = 1.0
-
- def _create_planar_path(self, path: "PlanarPath") -> None:
- path.circle(self.outer_radius)
- path.ellipse(self.inner_radius, -self.inner_radius)
diff --git a/src/manimgx/mobjects/arrow.py b/src/manimgx/mobjects/arrow.py
deleted file mode 100644
index 5d12a82d..00000000
--- a/src/manimgx/mobjects/arrow.py
+++ /dev/null
@@ -1,35 +0,0 @@
-from dataclasses import dataclass
-
-from manimgx.mobjects.bases.planar_path import PlanarPath
-from manimgx.mobjects.bases.planar_path_mobject import PlanarPathMobject
-from manimgx.primitives.units import Angle
-
-
-@dataclass(kw_only=True, eq=False)
-class Arrow(PlanarPathMobject):
- length: float = 2.0
- shaft_width: float = 0.06
- tip_length: float = 0.3
- tip_width: float = 0.25
- angle: Angle = 0.0
-
- def _create_planar_path(self, path: "PlanarPath") -> None:
- half_length = self.length / 2
- shaft_left = -half_length
- shaft_right = half_length - self.tip_length
- hw = self.shaft_width / 2
- tw = self.tip_width / 2
- tip_x = half_length
-
- path.polygon(
- [
- (shaft_left, -hw),
- (shaft_right, -hw),
- (shaft_right, -tw),
- (tip_x, 0.0),
- (shaft_right, tw),
- (shaft_right, hw),
- (shaft_left, hw),
- ]
- )
- path.rotate(self.angle)
diff --git a/src/manimgx/mobjects/bases/__init__.py b/src/manimgx/mobjects/bases/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/manimgx/mobjects/bases/mobject.py b/src/manimgx/mobjects/bases/mobject.py
deleted file mode 100644
index bbe189b4..00000000
--- a/src/manimgx/mobjects/bases/mobject.py
+++ /dev/null
@@ -1,140 +0,0 @@
-from abc import abstractmethod
-from collections.abc import Callable, Iterator
-from dataclasses import dataclass, field
-from typing import Self
-
-import numpy as np
-
-from manimgx.engine import Object3D
-from manimgx.primitives.vector import ORIGIN, OUT, RIGHT, Vec3, Vec4
-
-
-@dataclass(kw_only=True, eq=False)
-class Mobject:
- position: Vec3 = field(default_factory=lambda: ORIGIN.copy())
- scale_factor: Vec3 = field(default_factory=lambda: np.array([1.0, 1.0, 1.0]))
- quaternion: Vec4 = field(default_factory=lambda: np.array([0.0, 0.0, 0.0, 1.0]))
-
- _updaters: list[Callable[[Self, float], None]] = field(
- default_factory=list, init=False, repr=False
- )
- _direct_submobjects: list["Mobject"] = field(default_factory=list, init=False)
-
- @property
- @abstractmethod
- def _object3d(self) -> Object3D: ...
-
- # Engine sync:
- def __setattr__(self, name, value):
- super().__setattr__(name, value)
- handler = getattr(self, f"_on_{name}_changed", None)
- if handler:
- handler(value)
-
- def _on_position_change(self) -> None:
- self._object3d.position = self.position
-
- def _on_scale_factor_change(self) -> None:
- self._object3d.scale = self.scale_factor
-
- def _on_quaternion_change(self) -> None:
- self._object3d.quaternion = self.quaternion
-
- # Submobjects:
-
- @property
- def submobjects_iter(self) -> Iterator["Mobject"]:
- stack: list[Mobject] = [self]
- while stack:
- mob = stack.pop()
- yield mob
- stack.extend(reversed(mob._direct_submobjects))
-
- def add(self, *mobjects: "Mobject") -> Self:
- for m in mobjects:
- if m is self or m in self._direct_submobjects:
- continue
- m._object3d.parent = self._object3d
- self._direct_submobjects.append(m)
- return self
-
- def remove(self, *mobjects: "Mobject") -> Self:
- to_remove = set(mobjects)
- for m in to_remove:
- if m in self._direct_submobjects:
- m._object3d.parent = None
- self._direct_submobjects = [
- s for s in self._direct_submobjects if s not in to_remove
- ]
- return self
-
- # Updaters:
-
- def add_updater(self, func: Callable[[Self, float], None]) -> Self:
- self._updaters.append(func)
- return self
-
- def remove_updater(self, func: Callable[[Self, float], None]) -> Self:
- self._updaters = [u for u in self._updaters if u is not func]
- return self
-
- def clear_updaters(self) -> Self:
- self._updaters.clear()
- return self
-
- # Transforms:
-
- def shift(self, offset: Vec3) -> Self: ...
- def rotate(
- self,
- angle: float,
- axis: Vec3 = OUT,
- about_point: Vec3 | None = None,
- ) -> Self: ...
- def scale(
- self,
- factor: float,
- about_point: Vec3 | None = None,
- ) -> Self: ...
- def move_to(
- self,
- target: "Vec3 | Mobject",
- aligned_edge: Vec3 = ORIGIN,
- coor_mask: Vec3 | None = None,
- ) -> Self: ...
- def next_to(
- self,
- target: "Vec3 | Mobject",
- direction: Vec3 = RIGHT,
- buff: float = 0.25,
- ) -> Self: ...
- def align_to(self, target: "Vec3 | Mobject", direction: Vec3) -> Self: ...
- def arrange(
- self,
- direction: Vec3 = RIGHT,
- buff: float = 0.25,
- center: bool = True,
- ) -> Self: ...
- def rotate_quaternion(
- self,
- quaternion: Vec4,
- about_point: Vec3 | None = None,
- ) -> Self: ...
- def scale_x(self, factor: float, about_point: Vec3 | None = None) -> Self: ...
- def scale_y(self, factor: float, about_point: Vec3 | None = None) -> Self: ...
- def scale_z(self, factor: float, about_point: Vec3 | None = None) -> Self: ...
- def scale_to_fit_width(self, width: float) -> Self: ...
- def scale_to_fit_height(self, height: float) -> Self: ...
- def scale_to_fit_depth(self, depth: float) -> Self: ...
- def stretch_to_fit_width(self, width: float) -> Self: ...
- def stretch_to_fit_height(self, height: float) -> Self: ...
- def stretch_to_fit_depth(self, depth: float) -> Self: ...
-
- # Geometry queries:
-
- def bounding_box(self) -> tuple[Vec3, Vec3]: ...
- def width(self) -> float: ...
- def height(self) -> float: ...
- def depth(self) -> float: ...
- def center(self) -> Vec3: ...
- def get_critical_point(self, direction: Vec3) -> Vec3: ...
diff --git a/src/manimgx/mobjects/bases/planar_path_mobject.py b/src/manimgx/mobjects/bases/planar_path_mobject.py
deleted file mode 100644
index 537f1f61..00000000
--- a/src/manimgx/mobjects/bases/planar_path_mobject.py
+++ /dev/null
@@ -1,453 +0,0 @@
-import functools
-import math
-from abc import abstractmethod
-from collections.abc import Sequence
-from dataclasses import dataclass
-from typing import Self
-
-from manimgx.engine import (
- Material,
- Object3D,
- PathCommand,
- Side,
- Surface,
- tessellate,
-)
-from manimgx.mobjects.bases.mobject import Mobject
-from manimgx.primitives.color import Color, parse_color
-
-# For Manim CE compatibility:
-STROKE_WIDTH_CONVERSION: float = 0.01
-KAPPA = 4 / 3 * (math.sqrt(2) - 1)
-
-
-@dataclass(kw_only=True, eq=False)
-class PlanarPathMobject(Mobject):
- color: Color = "white"
- opacity: float = 1.0
- stroke_color: Color = "white"
- stroke_opacity: float = 1.0
- stroke_width: float = 0.0
-
- @abstractmethod
- def _create_planar_path(self, path: "PlanarPath") -> None: ...
-
- @functools.cached_property
- def _object3d(self) -> Object3D:
- path = PlanarPath()
- self._create_planar_path(path)
- tessellation = tessellate(
- path.command_types,
- path.command_data,
- stroke_width=self.stroke_width * STROKE_WIDTH_CONVERSION,
- )
- assert tessellation.fill_mesh is not None
- assert tessellation.stroke_mesh is not None
- return Object3D(
- Surface(
- tessellation.fill_mesh,
- Material(
- side=Side.BOTH,
- color=parse_color(self.color),
- opacity=self.opacity,
- ),
- ),
- Surface(
- tessellation.stroke_mesh,
- Material(
- color=parse_color(self.stroke_color),
- opacity=self.stroke_opacity,
- ),
- ),
- )
-
- def _on_color_change(self, value: Color) -> None:
- self._object3d.surfaces[0].material.color = parse_color(value)
-
- def _on_opacity_change(self, value: float) -> None:
- self._object3d.surfaces[0].material.opacity = value
-
- def _on_stroke_color_change(self, value: Color) -> None:
- self._object3d.surfaces[1].material.color = parse_color(value)
-
- def _on_stroke_opacity_change(self, value: float) -> None:
- self._object3d.surfaces[1].material.opacity = value
-
-
-# ── PlanarPath ────────────────────────────────────────────────────────
-
-
-class PlanarPath:
- __slots__ = ("command_data", "command_types")
-
- def __init__(self) -> None:
- self.command_types: list[int] = []
- self.command_data: list[float] = []
-
- def _emit(self, cmd: int, *coords: float) -> Self:
- self.command_types.append(cmd)
- self.command_data.extend(coords)
- return self
-
- def move_to(self, x: float, y: float) -> Self:
- return self._emit(PathCommand.MOVE_TO, x, y)
-
- def line_to(self, x: float, y: float) -> Self:
- return self._emit(PathCommand.LINE_TO, x, y)
-
- def cubic_to(
- self,
- c1x: float,
- c1y: float,
- c2x: float,
- c2y: float,
- x: float,
- y: float,
- ) -> Self:
- return self._emit(PathCommand.CUBIC_TO, c1x, c1y, c2x, c2y, x, y)
-
- def arc_to(
- self,
- radius: float,
- start_angle: float,
- sweep_angle: float,
- *,
- cx: float = 0.0,
- cy: float = 0.0,
- ) -> Self:
- if abs(sweep_angle) < 1e-12:
- return self
- n_segments = max(1, math.ceil(abs(sweep_angle) / (math.pi / 2)))
- segment_angle = sweep_angle / n_segments
- k = (4.0 / 3.0) * math.tan(segment_angle / 4.0)
- angle = start_angle
- for _ in range(n_segments):
- cos_a = math.cos(angle)
- sin_a = math.sin(angle)
- cos_end = math.cos(angle + segment_angle)
- sin_end = math.sin(angle + segment_angle)
- self.cubic_to(
- cx + radius * (cos_a - k * sin_a),
- cy + radius * (sin_a + k * cos_a),
- cx + radius * (cos_end + k * sin_end),
- cy + radius * (sin_end - k * cos_end),
- cx + radius * cos_end,
- cy + radius * sin_end,
- )
- angle += segment_angle
- return self
-
- def close(self) -> Self:
- return self._emit(PathCommand.CLOSE)
-
- def subpath(self, start: float, end: float) -> "PlanarPath":
- if end <= start or end <= 0.0:
- return PlanarPath()
- end = min(end, 1.0)
- start = max(start, 0.0)
-
- segments: list[tuple[int, list[float], float]] = [] # (cmd, coords, arc_len)
- data = self.command_data
- di = 0
- last_x, last_y = 0.0, 0.0
- start_x, start_y = 0.0, 0.0
-
- for cmd in self.command_types:
- if cmd == PathCommand.MOVE_TO:
- x, y = data[di], data[di + 1]
- di += 2
- segments.append((cmd, [x, y], 0.0))
- last_x, last_y = x, y
- start_x, start_y = x, y
- elif cmd == PathCommand.LINE_TO:
- x, y = data[di], data[di + 1]
- di += 2
- length = math.hypot(x - last_x, y - last_y)
- segments.append((cmd, [last_x, last_y, x, y], length))
- last_x, last_y = x, y
- elif cmd == PathCommand.CUBIC_TO:
- c1x, c1y = data[di], data[di + 1]
- c2x, c2y = data[di + 2], data[di + 3]
- ex, ey = data[di + 4], data[di + 5]
- di += 6
- length = cubic_arc_length(last_x, last_y, c1x, c1y, c2x, c2y, ex, ey)
- segments.append(
- (cmd, [last_x, last_y, c1x, c1y, c2x, c2y, ex, ey], length)
- )
- last_x, last_y = ex, ey
- elif cmd == PathCommand.CLOSE:
- length = math.hypot(start_x - last_x, start_y - last_y)
- segments.append((cmd, [last_x, last_y, start_x, start_y], length))
- last_x, last_y = start_x, start_y
-
- total_length = sum(seg[2] for seg in segments)
- if total_length < 1e-12:
- return PlanarPath()
-
- target_start = start * total_length
- target_end = end * total_length
-
- result = PlanarPath()
- cumulative = 0.0
- first_point: tuple[float, float] | None = None
- last_emitted_x, last_emitted_y = 0.0, 0.0
-
- for cmd, coords, seg_len in segments:
- seg_start = cumulative
- seg_end = cumulative + seg_len
- cumulative = seg_end
-
- if seg_end <= target_start:
- continue # entirely before clip region
- if seg_start >= target_end:
- break # past clip region
-
- if cmd == PathCommand.MOVE_TO:
- x, y = coords[0], coords[1]
- if first_point is None:
- result.move_to(x, y)
- first_point = (x, y)
- last_emitted_x, last_emitted_y = x, y
- continue
-
- if cmd == PathCommand.LINE_TO or cmd == PathCommand.CLOSE:
- x0, y0, x1, y1 = coords[0], coords[1], coords[2], coords[3]
- t0 = 0.0
- if seg_start < target_start:
- t0 = (target_start - seg_start) / seg_len if seg_len > 0 else 0.0
- t1 = 1.0
- if seg_end > target_end:
- t1 = (target_end - seg_start) / seg_len if seg_len > 0 else 1.0
- px0 = lerp(x0, x1, t0)
- py0 = lerp(y0, y1, t0)
- px1 = lerp(x0, x1, t1)
- py1 = lerp(y0, y1, t1)
- if first_point is None:
- result.move_to(px0, py0)
- first_point = (px0, py0)
- result.line_to(px1, py1)
- last_emitted_x, last_emitted_y = px1, py1
-
- elif cmd == PathCommand.CUBIC_TO:
- x0, y0, c1x, c1y, c2x, c2y, ex, ey = coords
- t0 = 0.0
- if seg_start < target_start and seg_len > 0:
- frac = (target_start - seg_start) / seg_len
- t0 = find_t_for_arc_fraction(
- x0, y0, c1x, c1y, c2x, c2y, ex, ey, frac, seg_len
- )
- t1 = 1.0
- if seg_end > target_end and seg_len > 0:
- frac = (target_end - seg_start) / seg_len
- t1 = find_t_for_arc_fraction(
- x0, y0, c1x, c1y, c2x, c2y, ex, ey, frac, seg_len
- )
- if t0 > 0:
- _, right = split_cubic(x0, y0, c1x, c1y, c2x, c2y, ex, ey, t0)
- x0, y0, c1x, c1y, c2x, c2y, ex, ey = right
- t1 = (t1 - t0) / (1.0 - t0) if t0 < 1.0 else 1.0
- if t1 < 1.0:
- left, _ = split_cubic(x0, y0, c1x, c1y, c2x, c2y, ex, ey, t1)
- x0, y0, c1x, c1y, c2x, c2y, ex, ey = left
-
- if first_point is None:
- result.move_to(x0, y0)
- first_point = (x0, y0)
- result.cubic_to(c1x, c1y, c2x, c2y, ex, ey)
- last_emitted_x, last_emitted_y = ex, ey
-
- if first_point is not None:
- fx, fy = first_point
- if abs(last_emitted_x - fx) > 1e-9 or abs(last_emitted_y - fy) > 1e-9:
- result.line_to(fx, fy)
- result.close()
-
- return result
-
- def circle(self, radius: float, *, x: float = 0.0, y: float = 0.0) -> Self:
- return self.ellipse(radius, radius, x=x, y=y)
-
- def ellipse(
- self, x_radius: float, y_radius: float, *, x: float = 0.0, y: float = 0.0
- ) -> Self:
- kx = x_radius * KAPPA
- ky = y_radius * KAPPA
- self.move_to(x + x_radius, y)
- self.cubic_to(x + x_radius, y + ky, x + kx, y + y_radius, x, y + y_radius)
- self.cubic_to(x - kx, y + y_radius, x - x_radius, y + ky, x - x_radius, y)
- self.cubic_to(x - x_radius, y - ky, x - kx, y - y_radius, x, y - y_radius)
- self.cubic_to(x + kx, y - y_radius, x + x_radius, y - ky, x + x_radius, y)
- self.close()
- return self
-
- def rectangle(
- self, width: float, height: float, *, x: float = 0.0, y: float = 0.0
- ) -> Self:
- hw = width / 2
- hh = height / 2
- self.move_to(x - hw, y - hh)
- self.line_to(x + hw, y - hh)
- self.line_to(x + hw, y + hh)
- self.line_to(x - hw, y + hh)
- self.close()
- return self
-
- def rounded_rectangle(
- self,
- width: float,
- height: float,
- corner_radius: float,
- *,
- x: float = 0.0,
- y: float = 0.0,
- ) -> Self:
- hw = width / 2
- hh = height / 2
- r = min(corner_radius, hw, hh)
- rk = r * KAPPA
- self.move_to(x + hw - r, y + hh)
- self.cubic_to(
- x + hw - r + rk, y + hh, x + hw, y + hh - r + rk, x + hw, y + hh - r
- )
- self.line_to(x + hw, y - (hh - r))
- self.cubic_to(
- x + hw, y - (hh - r + rk), x + hw - r + rk, y - hh, x + hw - r, y - hh
- )
- self.line_to(x - (hw - r), y - hh)
- self.cubic_to(
- x - (hw - r + rk), y - hh, x - hw, y - (hh - r + rk), x - hw, y - (hh - r)
- )
- self.line_to(x - hw, y + hh - r)
- self.cubic_to(
- x - hw, y + hh - r + rk, x - (hw - r + rk), y + hh, x - (hw - r), y + hh
- )
- self.close()
- return self
-
- def regular_polygon(
- self, radius: float, sides: int, *, x: float = 0.0, y: float = 0.0
- ) -> Self:
- angle_step = 2 * math.pi / sides
- angle_0 = -math.pi / 2
- self.move_to(x + radius * math.cos(angle_0), y + radius * math.sin(angle_0))
- for i in range(1, sides):
- angle = angle_0 + angle_step * i
- self.line_to(x + radius * math.cos(angle), y + radius * math.sin(angle))
- self.close()
- return self
-
- def polygon(self, vertices: Sequence[tuple[float, float]]) -> Self:
- if len(vertices) < 3:
- return self
- self.move_to(vertices[0][0], vertices[0][1])
- for vx, vy in vertices[1:]:
- self.line_to(vx, vy)
- self.close()
- return self
-
- def rotate(self, angle: float) -> Self:
- if abs(angle) < 1e-12:
- return self
- cos_a = math.cos(angle)
- sin_a = math.sin(angle)
- data = self.command_data
- for i in range(0, len(data), 2):
- ox, oy = data[i], data[i + 1]
- data[i] = ox * cos_a - oy * sin_a
- data[i + 1] = ox * sin_a + oy * cos_a
- return self
-
- @property
- def bounds(self) -> tuple[float, float, float, float]:
- if not self.command_data:
- return (0.0, 0.0, 0.0, 0.0)
- xs = self.command_data[0::2]
- ys = self.command_data[1::2]
- return (min(xs), min(ys), max(xs), max(ys))
-
-
-# ── Arc-length helpers ────────────────────────────────────────────────
-
-
-def cubic_arc_length(
- x0: float,
- y0: float,
- c1x: float,
- c1y: float,
- c2x: float,
- c2y: float,
- x3: float,
- y3: float,
-) -> float:
- chord = math.hypot(x3 - x0, y3 - y0)
- poly = (
- math.hypot(c1x - x0, c1y - y0)
- + math.hypot(c2x - c1x, c2y - c1y)
- + math.hypot(x3 - c2x, y3 - c2y)
- )
- if poly - chord < 1e-6:
- return (poly + chord) / 2
- left, right = split_cubic(x0, y0, c1x, c1y, c2x, c2y, x3, y3, 0.5)
- return cubic_arc_length(*left) + cubic_arc_length(*right)
-
-
-def lerp(a: float, b: float, t: float) -> float:
- return a + (b - a) * t
-
-
-def split_cubic(
- x0: float,
- y0: float,
- c1x: float,
- c1y: float,
- c2x: float,
- c2y: float,
- x3: float,
- y3: float,
- t: float,
-) -> tuple[
- tuple[float, float, float, float, float, float, float, float],
- tuple[float, float, float, float, float, float, float, float],
-]:
- """De Casteljau split at parameter t. Returns (left_8, right_8)."""
- q0x = lerp(x0, c1x, t)
- q0y = lerp(y0, c1y, t)
- q1x = lerp(c1x, c2x, t)
- q1y = lerp(c1y, c2y, t)
- q2x = lerp(c2x, x3, t)
- q2y = lerp(c2y, y3, t)
- r0x = lerp(q0x, q1x, t)
- r0y = lerp(q0y, q1y, t)
- r1x = lerp(q1x, q2x, t)
- r1y = lerp(q1y, q2y, t)
- sx = lerp(r0x, r1x, t)
- sy = lerp(r0y, r1y, t)
- left = (x0, y0, q0x, q0y, r0x, r0y, sx, sy)
- right = (sx, sy, r1x, r1y, q2x, q2y, x3, y3)
- return left, right
-
-
-def find_t_for_arc_fraction(
- x0: float,
- y0: float,
- c1x: float,
- c1y: float,
- c2x: float,
- c2y: float,
- x3: float,
- y3: float,
- target_frac: float,
- total_len: float,
-) -> float:
- """Binary search for parameter t where arc_length(0,t)/total_len ≈ target_frac."""
- target = target_frac * total_len
- lo, hi = 0.0, 1.0
- for _ in range(30): # ~1e-9 precision
- mid = (lo + hi) / 2
- left, _ = split_cubic(x0, y0, c1x, c1y, c2x, c2y, x3, y3, mid)
- length = cubic_arc_length(*left)
- if length < target:
- lo = mid
- else:
- hi = mid
- return (lo + hi) / 2
diff --git a/src/manimgx/mobjects/bases/surface_mobject.py b/src/manimgx/mobjects/bases/surface_mobject.py
deleted file mode 100644
index a9e32686..00000000
--- a/src/manimgx/mobjects/bases/surface_mobject.py
+++ /dev/null
@@ -1,174 +0,0 @@
-import functools
-import math
-from abc import abstractmethod
-from collections.abc import Callable
-from dataclasses import dataclass
-from typing import Self
-
-import numpy as np
-import numpy.typing as npt
-
-from manimgx.engine import Material, Mesh, Object3D, Side, build_surface
-from manimgx.engine import Surface as EngineSurface
-from manimgx.mobjects.bases.mobject import Mobject
-from manimgx.primitives.color import Color, parse_color
-
-type ParametricFunc = Callable[
- [npt.NDArray[np.floating], npt.NDArray[np.floating]],
- tuple[npt.NDArray, npt.NDArray, npt.NDArray],
-]
-
-
-@dataclass(kw_only=True, eq=False)
-class SurfaceMobject(Mobject):
- color: Color = "blue"
- opacity: float = 1.0
-
- @abstractmethod
- def _create_surface(self, surface: "Surface") -> None: ...
-
- @functools.cached_property
- def _object3d(self) -> Object3D:
- surface = Surface()
- self._create_surface(surface)
- surface_mesh = tesselate_surface(surface)
- return Object3D(
- EngineSurface(
- surface_mesh,
- Material(
- side=Side.BOTH,
- color=parse_color(self.color),
- opacity=self.opacity,
- ),
- ),
- )
-
- def _on_color_change(self, value: Color) -> None:
- self._object3d.surfaces[0].material.color = parse_color(value)
-
- def _on_opacity_change(self, value: float) -> None:
- self._object3d.surfaces[0].material.opacity = value
-
-
-@dataclass
-class SurfacePatch:
- func: ParametricFunc
- u_range: tuple[float, float]
- v_range: tuple[float, float]
- u_resolution: int
- v_resolution: int
-
-
-class Surface:
- __slots__ = ("_patches",)
-
- def __init__(self) -> None:
- self._patches: list[SurfacePatch] = []
-
- def parametric(
- self,
- func: ParametricFunc,
- u_range: tuple[float, float] = (0.0, 1.0),
- v_range: tuple[float, float] = (0.0, 1.0),
- u_resolution: int = 32,
- v_resolution: int = 32,
- ) -> Self:
-
- self._patches.append(
- SurfacePatch(func, u_range, v_range, u_resolution, v_resolution)
- )
- return self
-
- def revolve(
- self,
- profile: Callable[[npt.NDArray[np.floating]], tuple[npt.NDArray, npt.NDArray]],
- u_resolution: int = 32,
- v_resolution: int = 32,
- ) -> Self:
-
- def func(
- u: npt.NDArray[np.floating], v: npt.NDArray[np.floating]
- ) -> tuple[npt.NDArray, npt.NDArray, npt.NDArray]:
- theta = u * 2 * math.pi
- radius, z = profile(v)
- x = radius * np.cos(theta)
- y = radius * np.sin(theta)
- return x, y, z
-
- return self.parametric(
- func, u_resolution=u_resolution, v_resolution=v_resolution
- )
-
- def box(
- self,
- size_x: float = 1.0,
- size_y: float = 1.0,
- size_z: float = 1.0,
- ) -> Self:
- sizes = (size_x, size_y, size_z)
-
- def _face(axis: int, sign: float) -> ParametricFunc:
- a1 = (axis + 1) % 3
- a2 = (axis + 2) % 3
-
- def func(
- u: npt.NDArray[np.floating], v: npt.NDArray[np.floating]
- ) -> tuple[npt.NDArray, npt.NDArray, npt.NDArray]:
- coords: list[npt.NDArray] = [np.empty_like(u)] * 3
- coords[axis] = np.full_like(u, sign * sizes[axis] / 2)
- coords[a1] = (u - 0.5) * sizes[a1]
- coords[a2] = (v - 0.5) * sizes[a2]
- return coords[0], coords[1], coords[2]
-
- return func
-
- for axis in range(3):
- for sign in (1.0, -1.0):
- self.parametric(_face(axis, sign), u_resolution=1, v_resolution=1)
- return self
-
-
-def tesselate_surface(surface: Surface) -> Mesh:
- positions: list[float] = []
- normals: list[float] = []
- indices: list[int] = []
- vertex_offset = 0
-
- for patch in surface._patches:
- pos, nor, idx = tessellate_surface_patch(patch)
- positions.extend(pos)
- normals.extend(nor)
- indices.extend(i + vertex_offset for i in idx)
- vertex_offset += len(pos) // 3
-
- return build_surface(positions, normals, indices)
-
-
-def tessellate_surface_patch(
- patch: SurfacePatch,
-) -> tuple[list[float], list[float], list[int]]:
- u_res = patch.u_resolution
- v_res = patch.v_resolution
-
- u_vals = np.linspace(patch.u_range[0], patch.u_range[1], u_res + 1)
- v_vals = np.linspace(patch.v_range[0], patch.v_range[1], v_res + 1)
- u_grid, v_grid = np.meshgrid(u_vals, v_vals, indexing="ij")
-
- pos = np.stack(patch.func(u_grid, v_grid), axis=-1)
- eps = 1e-6
- du = (np.stack(patch.func(u_grid + eps, v_grid), axis=-1) - pos) / eps
- dv = (np.stack(patch.func(u_grid, v_grid + eps), axis=-1) - pos) / eps
- normals = np.cross(du, dv)
- norms = np.maximum(np.linalg.norm(normals, axis=-1, keepdims=True), 1e-10)
- normals = normals / norms
-
- positions = pos.reshape(-1).tolist()
- normals_flat = normals.reshape(-1).tolist()
-
- stride = v_res + 1
- ii, jj = np.meshgrid(range(u_res), range(v_res), indexing="ij")
- a = (ii * stride + jj).ravel()
- b = a + stride
- indices = np.column_stack([a, b, b + 1, a, b + 1, a + 1]).ravel().tolist()
-
- return positions, normals_flat, indices
diff --git a/src/manimgx/mobjects/bases/typst_mobject.py b/src/manimgx/mobjects/bases/typst_mobject.py
deleted file mode 100644
index 0c888bf9..00000000
--- a/src/manimgx/mobjects/bases/typst_mobject.py
+++ /dev/null
@@ -1,70 +0,0 @@
-import functools
-from abc import abstractmethod
-from dataclasses import dataclass
-
-import numpy as np
-import typst
-
-from manimgx.engine import Material, Mesh, Surface, tessellate_svg
-from manimgx.mobjects.bases.mobject import Mobject
-from manimgx.primitives.color import Color, parse_color
-
-
-def _get_typst_compiler() -> typst.Compiler:
- return typst.Compiler()
-
-
-DEFAULT_FONT_SIZE: int = 48
-
-_SVG_SCALE: float = 1.0 / 140.0
-
-
-@dataclass(kw_only=True, eq=False)
-class TypstMobject(Mobject):
- font_size: int = DEFAULT_FONT_SIZE
- color: Color = "white"
- opacity: float = 1.0
-
- @abstractmethod
- def _create_typst_source(self) -> str: ...
-
- def _init_mesh_instances(self) -> None:
- # TypstMobject uses child FillStrokeMobjects for glyphs,
- # so it only needs an anchor mesh instance.
- self._typst = self._add_direct_mesh_instance(Surface(Mesh.empty(), Material()))
-
- def __post_init__(self) -> None:
- super().__post_init__()
- s = _SVG_SCALE * float(self.font_size)
- self.scale_vec = np.array([s, s, 1.0])
- self._build_glyph_children()
-
- def _build_glyph_children(self) -> None:
- r, g, b = parse_color(self._resolved_fill_color)
- body = self._create_typst_source()
- source = (
- "#set page(width: auto, height: auto, margin: 0.5em, fill: none)\n"
- f"#set text(fill: rgb({r}, {g}, {b}))\n"
- f"{body}"
- )
- svg_bytes = _get_typst_compiler().compile(input=source.encode(), format="svg")
- if not isinstance(svg_bytes, bytes):
- msg = "Typst compilation returned no output"
- raise RuntimeError(msg)
-
- for glyph in tessellate_svg(svg_bytes):
- gr, gg, gb = glyph.color
- hex_color = f"#{gr:02x}{gg:02x}{gb:02x}"
- child = FillStrokeMobject(
- fill_color=hex_color,
- fill_opacity=self.fill_opacity,
- stroke_opacity=self.stroke_opacity,
- color=hex_color,
- )
- # Override tessellation with pre-computed glyph data
- child.__dict__["_tessellation"] = glyph
- child._direct_mesh_instances.clear()
- child._init_mesh_instances()
- self.add(child)
- child.scale_vec = self.scale_vec.copy()
diff --git a/src/manimgx/mobjects/circle.py b/src/manimgx/mobjects/circle.py
deleted file mode 100644
index 4054a580..00000000
--- a/src/manimgx/mobjects/circle.py
+++ /dev/null
@@ -1,16 +0,0 @@
-from dataclasses import dataclass
-
-from manimgx.mobjects.bases.planar_path import PlanarPath
-from manimgx.mobjects.bases.planar_path_mobject import PlanarPathMobject
-from manimgx.primitives.color import Opacity, StrokeWidth
-
-
-@dataclass(kw_only=True, eq=False)
-class Circle(PlanarPathMobject):
- radius: float = 1.0
- color: str = "#fc6255"
- fill_opacity: Opacity = 0.0
- stroke_width: StrokeWidth = 4.0
-
- def _create_planar_path(self, path: PlanarPath) -> None:
- path.circle(self.radius)
diff --git a/src/manimgx/mobjects/cone.py b/src/manimgx/mobjects/cone.py
deleted file mode 100644
index df4b5461..00000000
--- a/src/manimgx/mobjects/cone.py
+++ /dev/null
@@ -1,26 +0,0 @@
-from dataclasses import dataclass
-
-import numpy as np
-
-from manimgx.mobjects.bases.surface_mobject import Surface, SurfaceMobject
-
-
-@dataclass(kw_only=True, eq=False)
-class Cone(SurfaceMobject):
- base_radius: float = 1.0
- cone_height: float = 2.0
- u_resolution: int = 32
- v_resolution: int = 1
-
- def _create_surface(self, surface: Surface) -> None:
- base_radius = self.base_radius
- cone_height = self.cone_height
-
- def profile(v: np.ndarray) -> tuple[np.ndarray, np.ndarray]:
- return base_radius * (1.0 - v), v * cone_height - cone_height / 2
-
- surface.revolve(
- profile,
- u_resolution=self.u_resolution,
- v_resolution=self.v_resolution,
- )
diff --git a/src/manimgx/mobjects/cube.py b/src/manimgx/mobjects/cube.py
deleted file mode 100644
index de6fc0a5..00000000
--- a/src/manimgx/mobjects/cube.py
+++ /dev/null
@@ -1,12 +0,0 @@
-from dataclasses import dataclass
-
-from manimgx.mobjects.bases.surface_mobject import Surface, SurfaceMobject
-
-
-@dataclass(kw_only=True, eq=False)
-class Cube(SurfaceMobject):
- side_length: float = 2.0
-
- def _create_surface(self, surface: Surface) -> None:
- s = self.side_length
- surface.box(s, s, s)
diff --git a/src/manimgx/mobjects/cubic_bezier.py b/src/manimgx/mobjects/cubic_bezier.py
deleted file mode 100644
index 9bc7c5e9..00000000
--- a/src/manimgx/mobjects/cubic_bezier.py
+++ /dev/null
@@ -1,74 +0,0 @@
-import math
-from dataclasses import dataclass
-
-from manimgx.mobjects.bases.planar_path import PlanarPath
-from manimgx.mobjects.bases.planar_path_mobject import PlanarPathMobject
-
-
-def _eval_bezier(
- t: float,
- p0: tuple[float, float],
- p1: tuple[float, float],
- p2: tuple[float, float],
- p3: tuple[float, float],
-) -> tuple[float, float]:
-
- u = 1 - t
- x = u**3 * p0[0] + 3 * u**2 * t * p1[0] + 3 * u * t**2 * p2[0] + t**3 * p3[0]
- y = u**3 * p0[1] + 3 * u**2 * t * p1[1] + 3 * u * t**2 * p2[1] + t**3 * p3[1]
- return x, y
-
-
-def _eval_bezier_tangent(
- t: float,
- p0: tuple[float, float],
- p1: tuple[float, float],
- p2: tuple[float, float],
- p3: tuple[float, float],
-) -> tuple[float, float]:
-
- u = 1 - t
- tx = (
- 3 * u**2 * (p1[0] - p0[0])
- + 6 * u * t * (p2[0] - p1[0])
- + 3 * t**2 * (p3[0] - p2[0])
- )
- ty = (
- 3 * u**2 * (p1[1] - p0[1])
- + 6 * u * t * (p2[1] - p1[1])
- + 3 * t**2 * (p3[1] - p2[1])
- )
- return tx, ty
-
-
-@dataclass(kw_only=True, eq=False)
-class CubicBezier(PlanarPathMobject):
- p0: tuple[float, float] = (-1.0, 0.0)
- p1: tuple[float, float] = (-0.5, 1.0)
- p2: tuple[float, float] = (0.5, -1.0)
- p3: tuple[float, float] = (1.0, 0.0)
- thickness: float = 0.05
-
- def _create_planar_path(self, path: PlanarPath) -> None:
- hw = self.thickness / 2
- n_samples = 32
-
- samples: list[tuple[float, float, float, float]] = []
- for i in range(n_samples + 1):
- t = i / n_samples
- x, y = _eval_bezier(t, self.p0, self.p1, self.p2, self.p3)
- tx, ty = _eval_bezier_tangent(t, self.p0, self.p1, self.p2, self.p3)
- length = math.sqrt(tx * tx + ty * ty)
- if length > 0:
- nx, ny = -ty / length, tx / length
- else:
- nx, ny = 0.0, 1.0
- samples.append((x, y, nx, ny))
-
- x0, y0, nx0, ny0 = samples[0]
- path.move_to(x0 + hw * nx0, y0 + hw * ny0)
- for x, y, nx, ny in samples[1:]:
- path.line_to(x + hw * nx, y + hw * ny)
- for x, y, nx, ny in reversed(samples):
- path.line_to(x - hw * nx, y - hw * ny)
- path.close()
diff --git a/src/manimgx/mobjects/curved_arrow.py b/src/manimgx/mobjects/curved_arrow.py
deleted file mode 100644
index 53b33fbf..00000000
--- a/src/manimgx/mobjects/curved_arrow.py
+++ /dev/null
@@ -1,56 +0,0 @@
-import math
-from dataclasses import dataclass
-
-from manimgx.mobjects.bases.planar_path import PlanarPath
-from manimgx.mobjects.bases.planar_path_mobject import PlanarPathMobject
-from manimgx.primitives.units import Angle
-
-
-@dataclass(kw_only=True, eq=False)
-class CurvedArrow(PlanarPathMobject):
- radius: float = 1.0
- start_angle: Angle = 0.0
- angle: Angle = math.tau / 3
- shaft_width: float = 0.06
- tip_length: float = 0.2
- tip_width: float = 0.2
-
- def _create_planar_path(self, path: "PlanarPath") -> None:
- r = self.radius
- r_inner = r - self.shaft_width / 2
- r_outer = r + self.shaft_width / 2
- tip_angle = self.tip_length / r
-
- shaft_start = self.start_angle
- shaft_end = self.start_angle + self.angle - tip_angle
- shaft_arc = shaft_end - shaft_start
-
- arrow_tip_angle = self.start_angle + self.angle
-
- path.move_to(
- r_outer * math.cos(shaft_start),
- r_outer * math.sin(shaft_start),
- )
-
- path.arc_to(r_outer, shaft_start, shaft_arc)
-
- arrow_base_outer_r = r + self.tip_width / 2
- path.line_to(
- arrow_base_outer_r * math.cos(shaft_end),
- arrow_base_outer_r * math.sin(shaft_end),
- )
-
- path.line_to(
- r * math.cos(arrow_tip_angle),
- r * math.sin(arrow_tip_angle),
- )
-
- arrow_base_inner_r = r - self.tip_width / 2
- path.line_to(
- arrow_base_inner_r * math.cos(shaft_end),
- arrow_base_inner_r * math.sin(shaft_end),
- )
-
- path.arc_to(r_inner, shaft_end, -shaft_arc)
-
- path.close()
diff --git a/src/manimgx/mobjects/cylinder.py b/src/manimgx/mobjects/cylinder.py
deleted file mode 100644
index 06316662..00000000
--- a/src/manimgx/mobjects/cylinder.py
+++ /dev/null
@@ -1,26 +0,0 @@
-from dataclasses import dataclass
-
-import numpy as np
-
-from manimgx.mobjects.bases.surface_mobject import Surface, SurfaceMobject
-
-
-@dataclass(kw_only=True, eq=False)
-class Cylinder(SurfaceMobject):
- radius: float = 1.0
- cyl_height: float = 2.0
- u_resolution: int = 32
- v_resolution: int = 1
-
- def _create_surface(self, surface: Surface) -> None:
- radius = self.radius
- cyl_height = self.cyl_height
-
- def profile(v: np.ndarray) -> tuple[np.ndarray, np.ndarray]:
- return np.full_like(v, radius), (v - 0.5) * cyl_height
-
- surface.revolve(
- profile,
- u_resolution=self.u_resolution,
- v_resolution=self.v_resolution,
- )
diff --git a/src/manimgx/mobjects/dashed_line.py b/src/manimgx/mobjects/dashed_line.py
deleted file mode 100644
index 95f84468..00000000
--- a/src/manimgx/mobjects/dashed_line.py
+++ /dev/null
@@ -1,28 +0,0 @@
-from dataclasses import dataclass
-
-from manimgx.mobjects.bases.planar_path import PlanarPath
-from manimgx.mobjects.bases.planar_path_mobject import PlanarPathMobject
-from manimgx.primitives.units import Angle
-
-
-@dataclass(kw_only=True, eq=False)
-class DashedLine(PlanarPathMobject):
- length: float = 2.0
- thickness: float = 0.04
- dash_length: float = 0.15
- gap_length: float = 0.1
- angle: Angle = 0.0
-
- def _create_planar_path(self, path: PlanarPath) -> None:
- half_total = self.length / 2
- step = self.dash_length + self.gap_length
- pos = -half_total
-
- while pos + self.dash_length <= half_total + 1e-9:
- x1 = min(pos + self.dash_length, half_total)
- center_x = (pos + x1) / 2
- width = x1 - pos
- path.rectangle(width, self.thickness, x=center_x)
- pos += step
-
- path.rotate(self.angle)
diff --git a/src/manimgx/mobjects/dot.py b/src/manimgx/mobjects/dot.py
deleted file mode 100644
index f5f456ee..00000000
--- a/src/manimgx/mobjects/dot.py
+++ /dev/null
@@ -1,12 +0,0 @@
-from dataclasses import dataclass
-
-from manimgx.mobjects.circle import Circle
-from manimgx.primitives.color import Opacity, StrokeWidth
-
-
-@dataclass(kw_only=True, eq=False)
-class Dot(Circle):
- radius: float = 0.08
- color: str = "white"
- fill_opacity: Opacity = 1.0
- stroke_width: StrokeWidth = 0.0
diff --git a/src/manimgx/mobjects/double_arrow.py b/src/manimgx/mobjects/double_arrow.py
deleted file mode 100644
index f0929ed4..00000000
--- a/src/manimgx/mobjects/double_arrow.py
+++ /dev/null
@@ -1,29 +0,0 @@
-from dataclasses import dataclass
-
-from manimgx.mobjects.arrow import Arrow
-from manimgx.mobjects.bases.planar_path import PlanarPath
-
-
-@dataclass(kw_only=True, eq=False)
-class DoubleArrow(Arrow):
- def _create_planar_path(self, path: PlanarPath) -> None:
- hl = self.length / 2
- hw = self.shaft_width / 2
- tl = self.tip_length
- tw = self.tip_width / 2
-
- path.polygon(
- [
- (-hl, 0.0),
- (-(hl - tl), -tw),
- (-(hl - tl), -hw),
- (hl - tl, -hw),
- (hl - tl, -tw),
- (hl, 0.0),
- (hl - tl, tw),
- (hl - tl, hw),
- (-(hl - tl), hw),
- (-(hl - tl), tw),
- ]
- )
- path.rotate(self.angle)
diff --git a/src/manimgx/mobjects/ellipse.py b/src/manimgx/mobjects/ellipse.py
deleted file mode 100644
index 72c95f7a..00000000
--- a/src/manimgx/mobjects/ellipse.py
+++ /dev/null
@@ -1,16 +0,0 @@
-from dataclasses import dataclass
-
-from manimgx.mobjects.bases.planar_path import PlanarPath
-from manimgx.mobjects.bases.planar_path_mobject import PlanarPathMobject
-from manimgx.primitives.color import Opacity, StrokeWidth
-
-
-@dataclass(kw_only=True, eq=False)
-class Ellipse(PlanarPathMobject):
- width: float = 2.0
- height: float = 1.0
- fill_opacity: Opacity = 0.0
- stroke_width: StrokeWidth = 4.0
-
- def _create_planar_path(self, path: PlanarPath) -> None:
- path.ellipse(self.width / 2, self.height / 2)
diff --git a/src/manimgx/mobjects/graph.py b/src/manimgx/mobjects/graph.py
index 9b5534d0..5268977b 100644
--- a/src/manimgx/mobjects/graph.py
+++ b/src/manimgx/mobjects/graph.py
@@ -287,9 +287,9 @@ def _layout(name: LayoutName) -> LayoutFunction[Hashable]:
}[name]
-type Layout[V] = LayoutName | str | Positions[V] | LayoutFunction[
- V
-] # a layout's name, checked when used
+type Layout[V] = (
+ LayoutName | str | Positions[V] | LayoutFunction[V]
+) # a layout's name, checked when used
"""Where a graph's vertices go: a layout's name, the vertices' positions (a dictionary
from each vertex to its point), or a layout function."""
@@ -417,10 +417,6 @@ class GenericGraph[V: Hashable = Hashable](VMobject):
or by a function of one's own. It spans about `layout_scale` from the center, the
center at the scene's origin; points of two coordinates lie in the plane z = 0.
- Construction places vertices before creating edges, without calling an overridden
- `change_layout`. The `_empty_networkx_graph` factory runs after vertex creation for
- named or custom layouts; a position mapping does not call it.
-
Args:
vertices: The vertices: hashable values, each a vertex's name.
edges: The edges, each a pair of vertices.
@@ -789,7 +785,7 @@ class GenericGraph[V: Hashable = Hashable](VMobject):
Args:
nxgraph: The NetworkX graph (a `Graph`, or a `DiGraph`).
- **kwargs: [Graph keywords][manimgx.mobjects.graph.GraphOptions]: `layout`,
+ **kwargs: [Graph keywords][manimgx.Graph]: `layout`,
`labels`, `vertex_config`, ….
Returns:
diff --git a/src/manimgx/mobjects/grid.py b/src/manimgx/mobjects/grid.py
index 72ea5a08..4860206d 100644
--- a/src/manimgx/mobjects/grid.py
+++ b/src/manimgx/mobjects/grid.py
@@ -90,7 +90,7 @@ class MatrixOptions(Style, total=False):
"""Whether the brackets are stretched to the entries' height, and `bracket_v_buff`
beyond (default True)."""
bracket_config: MathTexOptions | None
- """[Math keywords][manimgx.mobjects.text.MathTexOptions] for the
+ """[Math keywords][manimgx.MathTex] for the
brackets: their `color`, … (default None: none)."""
element_to_mobject: ElementFactory
@@ -275,7 +275,7 @@ class Matrix(_Grid, VMobject):
right_bracket: The right bracket, as a LaTeX delimiter.
stretch_brackets: Whether the brackets are stretched to the entries' height,
and `bracket_v_buff` beyond.
- bracket_config: [Math keywords][manimgx.mobjects.text.MathTexOptions]
+ bracket_config: [Math keywords][manimgx.MathTex]
for the brackets: their `color`, …; None for none.
**kwargs: [Style keywords][manimgx.drawing.paint.Style] of the matrix itself: as it
has no points, they do not restyle its entries or its brackets.
@@ -417,7 +417,7 @@ class DecimalMatrix(Matrix):
It takes a [Matrix][manimgx.Matrix]'s arguments; its entries are numbers, and its
`element_to_mobject_config` gives the numbers'
- [keywords][manimgx.mobjects.numbers.DecimalNumberOptions], in place of
+ [keywords][manimgx.DecimalNumber], in place of
`{"num_decimal_places": 1}`.
Examples:
@@ -448,7 +448,7 @@ class IntegerMatrix(Matrix):
It takes a [Matrix][manimgx.Matrix]'s arguments; its entries are numbers, and its
`element_to_mobject_config` gives the numbers'
- [keywords][manimgx.mobjects.numbers.DecimalNumberOptions].
+ [keywords][manimgx.DecimalNumber].
Examples:
```python
@@ -540,10 +540,10 @@ class Table(_Grid, VGroup):
(Paragraph, for a Table).
element_to_mobject_config: Keywords for `element_to_mobject`; None for the
class's own (none, for a Table).
- arrange_in_grid_config: [Grid keywords][manimgx.mobject.GridArrangement]
+ arrange_in_grid_config: [Grid keywords][manimgx.Mobject.arrange_in_grid]
for laying out the cells, over the table's own rows, columns and gaps:
`cell_alignment`, `col_alignments`, …; None for none.
- line_config: [Line keywords][manimgx.mobjects.shapes.LineOptions] for the
+ line_config: [Line keywords][manimgx.Line] for the
lines: their `color`, `stroke_width`, …; None for none.
**kwargs: [Style keywords][manimgx.drawing.paint.Style] of the table itself: as it
has no points, they do not restyle its entries or its lines.
@@ -891,14 +891,16 @@ class Table(_Grid, VGroup):
"""
row = list(self.cells[pos[0] - 1])
col = [row[pos[1] - 1] for row in self.cells]
- box = _family_box(_family(col))
- left = (np.float64(0) if box is None else box[0, 0]) - self.h_buff / 2
- box = _family_box(_family(col))
- right = (np.float64(0) if box is None else box[1, 0]) + self.h_buff / 2
- box = _family_box(_family(row))
- bottom = (np.float64(0) if box is None else box[0, 1]) - self.v_buff / 2
- box = _family_box(_family(row))
- top = (np.float64(0) if box is None else box[1, 1]) + self.v_buff / 2
+ across = _family_box(_family(col)) # (the column's box: the cell's sides)
+ down = _family_box(_family(row)) # (the row's box: its top and bottom)
+ if across is None:
+ across = np.zeros((2, 3))
+ if down is None:
+ down = np.zeros((2, 3))
+ left = across[0, 0] - self.h_buff / 2
+ right = across[1, 0] + self.h_buff / 2
+ bottom = down[0, 1] - self.v_buff / 2
+ top = down[1, 1] + self.v_buff / 2
return Polygon(
[left, top, 0],
[right, top, 0],
@@ -1044,7 +1046,7 @@ class MathTable(Table):
It takes a [Table][manimgx.Table]'s arguments; its entries are strings of math, or
numbers, and its `element_to_mobject_config` gives their
- [math keywords][manimgx.mobjects.text.MathTexOptions].
+ [math keywords][manimgx.MathTex].
Examples:
```python
@@ -1100,7 +1102,7 @@ class IntegerTable(Table):
It takes a [Table][manimgx.Table]'s arguments; its entries are numbers, and its
`element_to_mobject_config` gives their
- [number keywords][manimgx.mobjects.numbers.DecimalNumberOptions].
+ [number keywords][manimgx.DecimalNumber].
Examples:
```python
@@ -1128,7 +1130,7 @@ class DecimalTable(Table):
It takes a [Table][manimgx.Table]'s arguments; its entries are numbers, and its
`element_to_mobject_config` gives their
- [number keywords][manimgx.mobjects.numbers.DecimalNumberOptions], in place of
+ [number keywords][manimgx.DecimalNumber], in place of
`{"num_decimal_places": 1}`.
Examples:
diff --git a/src/manimgx/mobjects/group.py b/src/manimgx/mobjects/group.py
deleted file mode 100644
index 112a4b29..00000000
--- a/src/manimgx/mobjects/group.py
+++ /dev/null
@@ -1,12 +0,0 @@
-from dataclasses import dataclass
-
-from manimgx.engine import Material, Mesh, Surface
-from manimgx.mobjects.bases.mobject import Mobject
-
-
-@dataclass(kw_only=True, init=False, eq=False)
-class Group(Mobject):
- def __init__(self, *mobjects: Mobject) -> None:
- super().__init__()
- self._group = self._add_direct_mesh_instance(Surface(Mesh.empty(), Material()))
- self.add(*mobjects)
diff --git a/src/manimgx/mobjects/hexagon.py b/src/manimgx/mobjects/hexagon.py
deleted file mode 100644
index e362c693..00000000
--- a/src/manimgx/mobjects/hexagon.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from dataclasses import dataclass
-
-from manimgx.mobjects.regular_polygon import RegularPolygon
-
-
-@dataclass(kw_only=True, eq=False)
-class Hexagon(RegularPolygon):
- n: int = 6
diff --git a/src/manimgx/mobjects/image.py b/src/manimgx/mobjects/image.py
deleted file mode 100644
index 84d5a70b..00000000
--- a/src/manimgx/mobjects/image.py
+++ /dev/null
@@ -1,58 +0,0 @@
-import functools
-import pathlib
-from dataclasses import dataclass
-
-import numpy as np
-from PIL import Image as PILImage
-
-from manimgx.engine import Material, Mesh, Surface, Texture, build_textured_quad
-from manimgx.mobjects.bases.mobject import Mobject
-from manimgx.primitives.color import Opacity
-
-
-@dataclass(kw_only=True, eq=False)
-class Image(Mobject):
- path: str | pathlib.Path
- height: float | None = None
- width: float | None = None
- opacity: Opacity = 1.0
-
- def __post_init__(self) -> None:
- super().__post_init__()
- _, pw, ph = self._image_data
- aspect = pw / ph
- if self.width is not None and self.height is not None:
- w, h = self.width, self.height
- elif self.width is not None:
- w, h = self.width, self.width / aspect
- elif self.height is not None:
- w, h = self.height * aspect, self.height
- else:
- w, h = 2.0 * aspect, 2.0
- self.scale_vec = np.array([w, h, 1.0])
- self._init_mesh_instances()
-
- def _init_mesh_instances(self) -> None:
- mesh, texture = self._image_mesh
- self._image = self._add_direct_mesh_instance(
- Surface(mesh, Material(texture=texture))
- )
- self._image.material.opacity = max(0.0, min(1.0, self.opacity))
-
- @functools.cached_property
- def _image_data(self) -> tuple[list[bytes], int, int]:
- img = PILImage.open(self.path)
- pw, ph = img.size
- n_frames = getattr(img, "n_frames", 1)
- frames: list[bytes] = []
- for i in range(n_frames):
- img.seek(i)
- frame = img.convert("RGBA")
- frame = frame.transpose(PILImage.Transpose.FLIP_TOP_BOTTOM)
- frames.append(frame.tobytes())
- return frames, pw, ph
-
- @functools.cached_property
- def _image_mesh(self) -> tuple[Mesh, Texture]:
- frames, pw, ph = self._image_data
- return build_textured_quad(frames, pw, ph)
diff --git a/src/manimgx/mobjects/line.py b/src/manimgx/mobjects/line.py
deleted file mode 100644
index 7768bb63..00000000
--- a/src/manimgx/mobjects/line.py
+++ /dev/null
@@ -1,16 +0,0 @@
-from dataclasses import dataclass
-
-from manimgx.mobjects.bases.planar_path import PlanarPath
-from manimgx.mobjects.bases.planar_path_mobject import PlanarPathMobject
-from manimgx.primitives.units import Angle
-
-
-@dataclass(kw_only=True, eq=False)
-class Line(PlanarPathMobject):
- length: float = 2.0
- thickness: float = 0.04
- angle: Angle = 0.0
-
- def _create_planar_path(self, path: "PlanarPath") -> None:
- path.rectangle(self.length, self.thickness)
- path.rotate(self.angle)
diff --git a/src/manimgx/mobjects/math_tex.py b/src/manimgx/mobjects/math_tex.py
deleted file mode 100644
index 6a71a790..00000000
--- a/src/manimgx/mobjects/math_tex.py
+++ /dev/null
@@ -1,24 +0,0 @@
-from dataclasses import dataclass
-
-from manimgx.mobjects.bases.typst_mobject import DEFAULT_FONT_SIZE
-from manimgx.mobjects.tex import Tex
-from manimgx.primitives.color import Color
-
-
-@dataclass(kw_only=True, init=False, eq=False)
-class MathTex(Tex):
- def __init__(
- self,
- *tex_strings: str,
- color: Color = "white",
- fill_color: Color | None = None,
- font_size: int = DEFAULT_FONT_SIZE,
- ) -> None:
- super().__init__(
- *tex_strings,
- arg_separator=" ",
- color=color,
- fill_color=fill_color,
- font_size=font_size,
- stroke_opacity=0.0,
- )
diff --git a/src/manimgx/mobjects/pentagon.py b/src/manimgx/mobjects/pentagon.py
deleted file mode 100644
index 575e5bd5..00000000
--- a/src/manimgx/mobjects/pentagon.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from dataclasses import dataclass
-
-from manimgx.mobjects.regular_polygon import RegularPolygon
-
-
-@dataclass(kw_only=True, eq=False)
-class Pentagon(RegularPolygon):
- n: int = 5
diff --git a/src/manimgx/mobjects/polygon.py b/src/manimgx/mobjects/polygon.py
deleted file mode 100644
index 14189808..00000000
--- a/src/manimgx/mobjects/polygon.py
+++ /dev/null
@@ -1,22 +0,0 @@
-from dataclasses import dataclass
-
-from manimgx.mobjects.bases.planar_path import PlanarPath
-from manimgx.mobjects.bases.planar_path_mobject import PlanarPathMobject
-from manimgx.primitives.color import Color, Opacity
-
-
-@dataclass(kw_only=True, init=False, eq=False)
-class Polygon(PlanarPathMobject):
- vertices: tuple[tuple[float, float], ...]
-
- def __init__(
- self,
- *vertices: tuple[float, float],
- color: Color = "white",
- fill_opacity: Opacity = 1.0,
- ) -> None:
- self.vertices = vertices
- super().__init__(color=color, fill_opacity=fill_opacity)
-
- def _create_planar_path(self, path: PlanarPath) -> None:
- path.polygon(self.vertices)
diff --git a/src/manimgx/mobjects/rectangle.py b/src/manimgx/mobjects/rectangle.py
deleted file mode 100644
index a5284eb6..00000000
--- a/src/manimgx/mobjects/rectangle.py
+++ /dev/null
@@ -1,16 +0,0 @@
-from dataclasses import dataclass
-
-from manimgx.mobjects.bases.planar_path import PlanarPath
-from manimgx.mobjects.bases.planar_path_mobject import PlanarPathMobject
-from manimgx.primitives.color import Opacity, StrokeWidth
-
-
-@dataclass(kw_only=True, eq=False)
-class Rectangle(PlanarPathMobject):
- width: float = 4.0
- height: float = 2.0
- fill_opacity: Opacity = 0.0
- stroke_width: StrokeWidth = 4.0
-
- def _create_planar_path(self, path: PlanarPath) -> None:
- path.rectangle(self.width, self.height)
diff --git a/src/manimgx/mobjects/regular_polygon.py b/src/manimgx/mobjects/regular_polygon.py
deleted file mode 100644
index 44787d31..00000000
--- a/src/manimgx/mobjects/regular_polygon.py
+++ /dev/null
@@ -1,17 +0,0 @@
-from dataclasses import dataclass
-
-from manimgx.mobjects.bases.planar_path import PlanarPath
-from manimgx.mobjects.bases.planar_path_mobject import PlanarPathMobject
-from manimgx.primitives.color import Opacity, StrokeWidth
-
-
-@dataclass(kw_only=True, eq=False)
-class RegularPolygon(PlanarPathMobject):
- n: int = 5
- radius: float = 1.0
- color: str = "#58c4dd"
- fill_opacity: Opacity = 0.0
- stroke_width: StrokeWidth = 4.0
-
- def _create_planar_path(self, path: PlanarPath) -> None:
- path.regular_polygon(self.radius, self.n)
diff --git a/src/manimgx/mobjects/rounded_rectangle.py b/src/manimgx/mobjects/rounded_rectangle.py
deleted file mode 100644
index 6b6354ad..00000000
--- a/src/manimgx/mobjects/rounded_rectangle.py
+++ /dev/null
@@ -1,12 +0,0 @@
-from dataclasses import dataclass
-
-from manimgx.mobjects.bases.planar_path import PlanarPath
-from manimgx.mobjects.rectangle import Rectangle
-
-
-@dataclass(kw_only=True, eq=False)
-class RoundedRectangle(Rectangle):
- corner_radius: float = 0.25
-
- def _create_planar_path(self, path: PlanarPath) -> None:
- path.rounded_rectangle(self.width, self.height, self.corner_radius)
diff --git a/src/manimgx/mobjects/sector.py b/src/manimgx/mobjects/sector.py
deleted file mode 100644
index 5f375ab7..00000000
--- a/src/manimgx/mobjects/sector.py
+++ /dev/null
@@ -1,34 +0,0 @@
-import math
-from dataclasses import dataclass
-
-from manimgx.mobjects.bases.planar_path import PlanarPath
-from manimgx.mobjects.bases.planar_path_mobject import PlanarPathMobject
-from manimgx.primitives.units import Angle
-
-
-@dataclass(kw_only=True, eq=False)
-class AnnularSector(PlanarPathMobject):
- inner_radius: float = 0.5
- outer_radius: float = 1.0
- start_angle: Angle = 0.0
- angle: Angle = math.tau / 4
-
- def _create_planar_path(self, path: "PlanarPath") -> None:
- end_angle = self.start_angle + self.angle
-
- path.move_to(
- self.inner_radius * math.cos(self.start_angle),
- self.inner_radius * math.sin(self.start_angle),
- )
-
- if self.inner_radius > 1e-12:
- path.arc_to(self.inner_radius, self.start_angle, self.angle)
-
- path.line_to(
- self.outer_radius * math.cos(end_angle),
- self.outer_radius * math.sin(end_angle),
- )
-
- path.arc_to(self.outer_radius, end_angle, -self.angle)
-
- path.close()
diff --git a/src/manimgx/mobjects/sphere.py b/src/manimgx/mobjects/sphere.py
deleted file mode 100644
index a68cc477..00000000
--- a/src/manimgx/mobjects/sphere.py
+++ /dev/null
@@ -1,26 +0,0 @@
-import math
-from dataclasses import dataclass
-
-import numpy as np
-
-from manimgx.mobjects.bases.surface_mobject import Surface, SurfaceMobject
-
-
-@dataclass(kw_only=True, eq=False)
-class Sphere(SurfaceMobject):
- radius: float = 1.0
- u_resolution: int = 32
- v_resolution: int = 32
-
- def _create_surface(self, surface: Surface) -> None:
- radius = self.radius
-
- def profile(v: np.ndarray) -> tuple[np.ndarray, np.ndarray]:
- phi = v * math.pi
- return radius * np.sin(phi), radius * np.cos(phi)
-
- surface.revolve(
- profile,
- u_resolution=self.u_resolution,
- v_resolution=self.v_resolution,
- )
diff --git a/src/manimgx/mobjects/square.py b/src/manimgx/mobjects/square.py
deleted file mode 100644
index b57c9f77..00000000
--- a/src/manimgx/mobjects/square.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from dataclasses import dataclass
-
-from manimgx.mobjects.rectangle import Rectangle
-
-
-@dataclass(kw_only=True, eq=False)
-class Square(Rectangle):
- side_length: float = 2.0
-
- def __post_init__(self) -> None:
- self.width = self.side_length
- self.height = self.side_length
- super().__post_init__()
diff --git a/src/manimgx/mobjects/star.py b/src/manimgx/mobjects/star.py
deleted file mode 100644
index 476ce9fb..00000000
--- a/src/manimgx/mobjects/star.py
+++ /dev/null
@@ -1,57 +0,0 @@
-import math
-from dataclasses import dataclass
-
-from manimgx.mobjects.bases.planar_path import PlanarPath
-from manimgx.mobjects.bases.planar_path_mobject import PlanarPathMobject
-
-
-@dataclass(kw_only=True, eq=False)
-class Star(PlanarPathMobject):
- n: int = 5
- outer_radius: float = 1.0
- inner_radius: float | None = None
- density: int = 2
- start_angle: float = math.tau / 4
-
- def __post_init__(self) -> None:
- super().__post_init__()
- self.n = max(2, self.n)
- if self.inner_radius is None:
- self.density = max(1, min((self.n - 1) // 2, self.density))
-
- def _compute_inner_radius(self) -> float:
-
- inner_angle = math.tau / (2 * self.n)
- outer_angle = math.tau * self.density / self.n
- inverse_x = 1 - math.tan(inner_angle) * (
- (math.cos(outer_angle) - 1) / math.sin(outer_angle)
- )
- return self.outer_radius / (math.cos(inner_angle) * inverse_x)
-
- def _create_planar_path(self, path: "PlanarPath") -> None:
- inner_r = (
- self.inner_radius
- if self.inner_radius is not None
- else self._compute_inner_radius()
- )
- angle_step = math.tau / self.n
- half_step = angle_step / 2
-
- vertices: list[tuple[float, float]] = []
- for i in range(self.n):
- outer_angle = self.start_angle + angle_step * i
- vertices.append(
- (
- self.outer_radius * math.cos(outer_angle),
- self.outer_radius * math.sin(outer_angle),
- )
- )
- inner_angle = self.start_angle + angle_step * i + half_step
- vertices.append(
- (
- inner_r * math.cos(inner_angle),
- inner_r * math.sin(inner_angle),
- )
- )
-
- path.polygon(vertices)
diff --git a/src/manimgx/mobjects/tex.py b/src/manimgx/mobjects/tex.py
deleted file mode 100644
index 171327bc..00000000
--- a/src/manimgx/mobjects/tex.py
+++ /dev/null
@@ -1,36 +0,0 @@
-from dataclasses import dataclass
-
-from manimgx.mobjects.bases.typst_mobject import DEFAULT_FONT_SIZE, TypstMobject
-from manimgx.primitives.color import Color, Opacity
-
-
-@dataclass(kw_only=True, init=False, eq=False)
-class Tex(TypstMobject):
- tex_strings: tuple[str, ...]
- arg_separator: str = ""
-
- def __init__(
- self,
- *tex_strings: str,
- arg_separator: str = "",
- color: Color = "white",
- fill_color: Color | None = None,
- font_size: int = DEFAULT_FONT_SIZE,
- stroke_opacity: Opacity = 1.0,
- ) -> None:
- self.tex_strings = tex_strings
- self.arg_separator = arg_separator
- super().__init__(
- color=color,
- fill_color=fill_color,
- font_size=font_size,
- stroke_opacity=stroke_opacity,
- )
-
- def _create_typst_source(self) -> str:
- formula = self.arg_separator.join(self.tex_strings)
- return (
- '#import "@preview/mitex:0.2.4": *\n'
- '#show math.equation: set text(weight: "regular")\n'
- f"\n#mitex(`{formula}`)\n"
- )
diff --git a/src/manimgx/mobjects/torus.py b/src/manimgx/mobjects/torus.py
deleted file mode 100644
index a3b71442..00000000
--- a/src/manimgx/mobjects/torus.py
+++ /dev/null
@@ -1,28 +0,0 @@
-import math
-from dataclasses import dataclass
-
-import numpy as np
-
-from manimgx.mobjects.bases.surface_mobject import Surface, SurfaceMobject
-
-
-@dataclass(kw_only=True, eq=False)
-class Torus(SurfaceMobject):
- major_radius: float = 1.0
- minor_radius: float = 0.3
- u_resolution: int = 48
- v_resolution: int = 24
-
- def _create_surface(self, surface: Surface) -> None:
- major_radius = self.major_radius
- minor_radius = self.minor_radius
-
- def profile(v: np.ndarray) -> tuple[np.ndarray, np.ndarray]:
- phi = v * 2 * math.pi
- return major_radius + minor_radius * np.cos(phi), minor_radius * np.sin(phi)
-
- surface.revolve(
- profile,
- u_resolution=self.u_resolution,
- v_resolution=self.v_resolution,
- )
diff --git a/src/manimgx/mobjects/triangle.py b/src/manimgx/mobjects/triangle.py
deleted file mode 100644
index 99b32d08..00000000
--- a/src/manimgx/mobjects/triangle.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from dataclasses import dataclass
-
-from manimgx.mobjects.regular_polygon import RegularPolygon
-
-
-@dataclass(kw_only=True, eq=False)
-class Triangle(RegularPolygon):
- n: int = 3
diff --git a/src/manimgx/mobjects/typst.py b/src/manimgx/mobjects/typst.py
deleted file mode 100644
index 30badf8d..00000000
--- a/src/manimgx/mobjects/typst.py
+++ /dev/null
@@ -1,29 +0,0 @@
-from dataclasses import dataclass
-
-from manimgx.mobjects.bases.typst_mobject import DEFAULT_FONT_SIZE, TypstMobject
-from manimgx.primitives.color import Color, Opacity
-
-
-@dataclass(kw_only=True, init=False, eq=False)
-class Typst(TypstMobject):
- formula: str
-
- def __init__(
- self,
- formula: str,
- *,
- color: Color = "white",
- fill_color: Color | None = None,
- font_size: int = DEFAULT_FONT_SIZE,
- stroke_opacity: Opacity = 1.0,
- ) -> None:
- self.formula = formula
- super().__init__(
- color=color,
- fill_color=fill_color,
- font_size=font_size,
- stroke_opacity=stroke_opacity,
- )
-
- def _create_typst_source(self) -> str:
- return self.formula
diff --git a/src/manimgx/mobjects/value_tracker.py b/src/manimgx/mobjects/value_tracker.py
deleted file mode 100644
index 2cf5dd97..00000000
--- a/src/manimgx/mobjects/value_tracker.py
+++ /dev/null
@@ -1,46 +0,0 @@
-from collections.abc import Callable
-from dataclasses import dataclass, field
-
-
-@dataclass(kw_only=True, eq=False)
-class ValueTracker:
- """A non-visible animatable float holder.
-
- Other Mobjects read the value via updaters::
-
- tracker = ValueTracker(value=0)
- circle.add_updater(lambda m, t: m.shift_to_x(tracker.value))
- self.play(Tween(tracker, value=5.0))
-
- ValueTracker is intentionally *not* a Mobject. It carries no geometry,
- no position, no material -- only a scalar ``value`` that can be tweened
- and read by updaters on real Mobjects.
-
- Register it with ``scene.add(tracker)`` so its own updaters (if any) are
- called each frame.
- """
-
- value: float = 0.0
- _updaters: "list[Callable[[ValueTracker, float], None]]" = field(
- default_factory=list, init=False, repr=False
- )
-
- def add_updater(
- self, func: "Callable[[ValueTracker, float], None]"
- ) -> "ValueTracker":
- self._updaters.append(func)
- return self
-
- def remove_updater(
- self, func: "Callable[[ValueTracker, float], None]"
- ) -> "ValueTracker":
- self._updaters = [u for u in self._updaters if u is not func]
- return self
-
- def clear_updaters(self) -> "ValueTracker":
- self._updaters.clear()
- return self
-
- @property
- def updaters(self) -> "list[Callable[[ValueTracker, float], None]]":
- return list(self._updaters)
diff --git a/src/manimgx/mobjects/vector.py b/src/manimgx/mobjects/vector.py
deleted file mode 100644
index 98e20d9e..00000000
--- a/src/manimgx/mobjects/vector.py
+++ /dev/null
@@ -1,38 +0,0 @@
-import math
-from dataclasses import dataclass
-
-from manimgx.mobjects.bases.planar_path import PlanarPath
-from manimgx.mobjects.bases.planar_path_mobject import PlanarPathMobject
-
-
-@dataclass(kw_only=True, eq=False)
-class Vector(PlanarPathMobject):
- dx: float = 1.0
- dy: float = 0.0
- shaft_width: float = 0.06
- tip_length: float = 0.25
- tip_width: float = 0.2
-
- def _create_planar_path(self, path: PlanarPath) -> None:
- length = math.sqrt(self.dx**2 + self.dy**2)
- if length < 1e-9:
- return
-
- angle = math.atan2(self.dy, self.dx)
- hw = self.shaft_width / 2
- tl = min(self.tip_length, length * 0.5)
- tw = self.tip_width / 2
- shaft_end = length - tl
-
- path.polygon(
- [
- (0, -hw),
- (shaft_end, -hw),
- (shaft_end, -tw),
- (length, 0),
- (shaft_end, tw),
- (shaft_end, hw),
- (0, hw),
- ]
- )
- path.rotate(angle)
diff --git a/src/manimgx/primitives/__init__.py b/src/manimgx/primitives/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/manimgx/primitives/axis.py b/src/manimgx/primitives/axis.py
deleted file mode 100644
index 6f76dc82..00000000
--- a/src/manimgx/primitives/axis.py
+++ /dev/null
@@ -1,7 +0,0 @@
-from enum import IntEnum
-
-
-class Axis(IntEnum):
- X = 0
- Y = 1
- Z = 2
diff --git a/src/manimgx/primitives/color.py b/src/manimgx/primitives/color.py
deleted file mode 100644
index 012f13d2..00000000
--- a/src/manimgx/primitives/color.py
+++ /dev/null
@@ -1,418 +0,0 @@
-import functools
-import re
-from colorsys import hls_to_rgb
-from math import pi as _PI
-from typing import Literal
-
-
[email protected]_cache(maxsize=256)
-def parse_color(color: str) -> tuple[int, int, int]:
- return _parse_str(color)
-
-
-_RADS = 2 * _PI
-
-_r_255 = r"(\d{1,3}(?:\.\d+)?)"
-_r_comma = r"\s*,\s*"
-_r_alpha = r"(?:\d(?:\.\d+)?|\.\d+|\d{1,2}%)"
-_r_h = r"(-?\d+(?:\.\d+)?|-?\.\d+)(deg|rad|turn)?"
-_r_sl = r"(\d{1,3}(?:\.\d+)?)%"
-
-_RE_HEX_SHORT = re.compile(
- r"\s*(?:#|0x)?([0-9a-f])([0-9a-f])([0-9a-f])(?:[0-9a-f])?\s*"
-)
-_RE_HEX_LONG = re.compile(
- r"\s*(?:#|0x)?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})(?:[0-9a-f]{2})?\s*"
-)
-_RE_RGB = re.compile(
- rf"\s*rgba?\(\s*{_r_255}{_r_comma}{_r_255}{_r_comma}{_r_255}"
- rf"(?:{_r_comma}{_r_alpha})?\s*\)\s*"
-)
-_RE_HSL = re.compile(
- rf"\s*hsla?\(\s*{_r_h}{_r_comma}{_r_sl}{_r_comma}{_r_sl}"
- rf"(?:{_r_comma}{_r_alpha})?\s*\)\s*"
-)
-_RE_RGB_V4 = re.compile(
- rf"\s*rgba?\(\s*{_r_255}\s+{_r_255}\s+{_r_255}" rf"(?:\s*/\s*{_r_alpha})?\s*\)\s*"
-)
-_RE_HSL_V4 = re.compile(
- rf"\s*hsla?\(\s*{_r_h}\s+{_r_sl}\s+{_r_sl}" rf"(?:\s*/\s*{_r_alpha})?\s*\)\s*"
-)
-
-
-def _parse_str(value: str) -> tuple[int, int, int]:
- s = value.strip().lower()
-
- if s in _COLORS_BY_NAME:
- return _COLORS_BY_NAME[s]
-
- if s == "transparent":
- return (0, 0, 0)
-
- m = _RE_HEX_SHORT.fullmatch(s)
- if m:
- r, g, b = m.groups()
- return (int(r * 2, 16), int(g * 2, 16), int(b * 2, 16))
-
- m = _RE_HEX_LONG.fullmatch(s)
- if m:
- r, g, b = m.groups()
- return (int(r, 16), int(g, 16), int(b, 16))
-
- m = _RE_RGB.fullmatch(s) or _RE_RGB_V4.fullmatch(s)
- if m:
- return _parse_rgb(m.group(1), m.group(2), m.group(3))
-
- m = _RE_HSL.fullmatch(s) or _RE_HSL_V4.fullmatch(s)
- if m:
- return _parse_hsl(m.group(1), m.group(2), m.group(3), m.group(4))
-
- msg = f"Invalid color string: {value!r}"
- raise ValueError(msg)
-
-
-def _parse_rgb(r_s: str, g_s: str, b_s: str) -> tuple[int, int, int]:
- return (
- _parse_channel(float(r_s)),
- _parse_channel(float(g_s)),
- _parse_channel(float(b_s)),
- )
-
-
-def _parse_channel(v: float) -> int:
- return max(0, min(255, round(v)))
-
-
-def _parse_hsl(
- h_s: str, h_units: str | None, sat_s: str, light_s: str
-) -> tuple[int, int, int]:
- h = float(h_s)
-
- if h_units in {None, "deg"}:
- h = h % 360 / 360
- elif h_units == "rad":
- h = h % _RADS / _RADS
- else:
- h %= 1
-
- s = max(0.0, min(1.0, float(sat_s) / 100))
- li = max(0.0, min(1.0, float(light_s) / 100))
-
- r_f, g_f, b_f = hls_to_rgb(h, li, s)
- return (round(r_f * 255), round(g_f * 255), round(b_f * 255))
-
-
-_COLORS_BY_NAME: dict[str, tuple[int, int, int]] = {
- "aliceblue": (240, 248, 255),
- "antiquewhite": (250, 235, 215),
- "aqua": (0, 255, 255),
- "aquamarine": (127, 255, 212),
- "azure": (240, 255, 255),
- "beige": (245, 245, 220),
- "bisque": (255, 228, 196),
- "black": (0, 0, 0),
- "blanchedalmond": (255, 235, 205),
- "blue": (0, 0, 255),
- "blueviolet": (138, 43, 226),
- "brown": (165, 42, 42),
- "burlywood": (222, 184, 135),
- "cadetblue": (95, 158, 160),
- "chartreuse": (127, 255, 0),
- "chocolate": (210, 105, 30),
- "coral": (255, 127, 80),
- "cornflowerblue": (100, 149, 237),
- "cornsilk": (255, 248, 220),
- "crimson": (220, 20, 60),
- "cyan": (0, 255, 255),
- "darkblue": (0, 0, 139),
- "darkcyan": (0, 139, 139),
- "darkgoldenrod": (184, 134, 11),
- "darkgray": (169, 169, 169),
- "darkgreen": (0, 100, 0),
- "darkgrey": (169, 169, 169),
- "darkkhaki": (189, 183, 107),
- "darkmagenta": (139, 0, 139),
- "darkolivegreen": (85, 107, 47),
- "darkorange": (255, 140, 0),
- "darkorchid": (153, 50, 204),
- "darkred": (139, 0, 0),
- "darksalmon": (233, 150, 122),
- "darkseagreen": (143, 188, 143),
- "darkslateblue": (72, 61, 139),
- "darkslategray": (47, 79, 79),
- "darkslategrey": (47, 79, 79),
- "darkturquoise": (0, 206, 209),
- "darkviolet": (148, 0, 211),
- "deeppink": (255, 20, 147),
- "deepskyblue": (0, 191, 255),
- "dimgray": (105, 105, 105),
- "dimgrey": (105, 105, 105),
- "dodgerblue": (30, 144, 255),
- "firebrick": (178, 34, 34),
- "floralwhite": (255, 250, 240),
- "forestgreen": (34, 139, 34),
- "fuchsia": (255, 0, 255),
- "gainsboro": (220, 220, 220),
- "ghostwhite": (248, 248, 255),
- "gold": (255, 215, 0),
- "goldenrod": (218, 165, 32),
- "gray": (128, 128, 128),
- "green": (0, 128, 0),
- "greenyellow": (173, 255, 47),
- "grey": (128, 128, 128),
- "honeydew": (240, 255, 240),
- "hotpink": (255, 105, 180),
- "indianred": (205, 92, 92),
- "indigo": (75, 0, 130),
- "ivory": (255, 255, 240),
- "khaki": (240, 230, 140),
- "lavender": (230, 230, 250),
- "lavenderblush": (255, 240, 245),
- "lawngreen": (124, 252, 0),
- "lemonchiffon": (255, 250, 205),
- "lightblue": (173, 216, 230),
- "lightcoral": (240, 128, 128),
- "lightcyan": (224, 255, 255),
- "lightgoldenrodyellow": (250, 250, 210),
- "lightgray": (211, 211, 211),
- "lightgreen": (144, 238, 144),
- "lightgrey": (211, 211, 211),
- "lightpink": (255, 182, 193),
- "lightsalmon": (255, 160, 122),
- "lightseagreen": (32, 178, 170),
- "lightskyblue": (135, 206, 250),
- "lightslategray": (119, 136, 153),
- "lightslategrey": (119, 136, 153),
- "lightsteelblue": (176, 196, 222),
- "lightyellow": (255, 255, 224),
- "lime": (0, 255, 0),
- "limegreen": (50, 205, 50),
- "linen": (250, 240, 230),
- "magenta": (255, 0, 255),
- "maroon": (128, 0, 0),
- "mediumaquamarine": (102, 205, 170),
- "mediumblue": (0, 0, 205),
- "mediumorchid": (186, 85, 211),
- "mediumpurple": (147, 112, 219),
- "mediumseagreen": (60, 179, 113),
- "mediumslateblue": (123, 104, 238),
- "mediumspringgreen": (0, 250, 154),
- "mediumturquoise": (72, 209, 204),
- "mediumvioletred": (199, 21, 133),
- "midnightblue": (25, 25, 112),
- "mintcream": (245, 255, 250),
- "mistyrose": (255, 228, 225),
- "moccasin": (255, 228, 181),
- "navajowhite": (255, 222, 173),
- "navy": (0, 0, 128),
- "oldlace": (253, 245, 230),
- "olive": (128, 128, 0),
- "olivedrab": (107, 142, 35),
- "orange": (255, 165, 0),
- "orangered": (255, 69, 0),
- "orchid": (218, 112, 214),
- "palegoldenrod": (238, 232, 170),
- "palegreen": (152, 251, 152),
- "paleturquoise": (175, 238, 238),
- "palevioletred": (219, 112, 147),
- "papayawhip": (255, 239, 213),
- "peachpuff": (255, 218, 185),
- "peru": (205, 133, 63),
- "pink": (255, 192, 203),
- "plum": (221, 160, 221),
- "powderblue": (176, 224, 230),
- "purple": (128, 0, 128),
- "red": (255, 0, 0),
- "rosybrown": (188, 143, 143),
- "royalblue": (65, 105, 225),
- "saddlebrown": (139, 69, 19),
- "salmon": (250, 128, 114),
- "sandybrown": (244, 164, 96),
- "seagreen": (46, 139, 87),
- "seashell": (255, 245, 238),
- "sienna": (160, 82, 45),
- "silver": (192, 192, 192),
- "skyblue": (135, 206, 235),
- "slateblue": (106, 90, 205),
- "slategray": (112, 128, 144),
- "slategrey": (112, 128, 144),
- "snow": (255, 250, 250),
- "springgreen": (0, 255, 127),
- "steelblue": (70, 130, 180),
- "tan": (210, 180, 140),
- "teal": (0, 128, 128),
- "thistle": (216, 191, 216),
- "tomato": (255, 99, 71),
- "turquoise": (64, 224, 208),
- "violet": (238, 130, 238),
- "wheat": (245, 222, 179),
- "white": (255, 255, 255),
- "whitesmoke": (245, 245, 245),
- "yellow": (255, 255, 0),
- "yellowgreen": (154, 205, 50),
-}
-
-type Color = (
- Literal[
- "aliceblue",
- "antiquewhite",
- "aqua",
- "aquamarine",
- "azure",
- "beige",
- "bisque",
- "black",
- "blanchedalmond",
- "blue",
- "blueviolet",
- "brown",
- "burlywood",
- "cadetblue",
- "chartreuse",
- "chocolate",
- "coral",
- "cornflowerblue",
- "cornsilk",
- "crimson",
- "cyan",
- "darkblue",
- "darkcyan",
- "darkgoldenrod",
- "darkgray",
- "darkgreen",
- "darkgrey",
- "darkkhaki",
- "darkmagenta",
- "darkolivegreen",
- "darkorange",
- "darkorchid",
- "darkred",
- "darksalmon",
- "darkseagreen",
- "darkslateblue",
- "darkslategray",
- "darkslategrey",
- "darkturquoise",
- "darkviolet",
- "deeppink",
- "deepskyblue",
- "dimgray",
- "dimgrey",
- "dodgerblue",
- "firebrick",
- "floralwhite",
- "forestgreen",
- "fuchsia",
- "gainsboro",
- "ghostwhite",
- "gold",
- "goldenrod",
- "gray",
- "green",
- "greenyellow",
- "grey",
- "honeydew",
- "hotpink",
- "indianred",
- "indigo",
- "ivory",
- "khaki",
- "lavender",
- "lavenderblush",
- "lawngreen",
- "lemonchiffon",
- "lightblue",
- "lightcoral",
- "lightcyan",
- "lightgoldenrodyellow",
- "lightgray",
- "lightgreen",
- "lightgrey",
- "lightpink",
- "lightsalmon",
- "lightseagreen",
- "lightskyblue",
- "lightslategray",
- "lightslategrey",
- "lightsteelblue",
- "lightyellow",
- "lime",
- "limegreen",
- "linen",
- "magenta",
- "maroon",
- "mediumaquamarine",
- "mediumblue",
- "mediumorchid",
- "mediumpurple",
- "mediumseagreen",
- "mediumslateblue",
- "mediumspringgreen",
- "mediumturquoise",
- "mediumvioletred",
- "midnightblue",
- "mintcream",
- "mistyrose",
- "moccasin",
- "navajowhite",
- "navy",
- "oldlace",
- "olive",
- "olivedrab",
- "orange",
- "orangered",
- "orchid",
- "palegoldenrod",
- "palegreen",
- "paleturquoise",
- "palevioletred",
- "papayawhip",
- "peachpuff",
- "peru",
- "pink",
- "plum",
- "powderblue",
- "purple",
- "red",
- "rosybrown",
- "royalblue",
- "saddlebrown",
- "salmon",
- "sandybrown",
- "seagreen",
- "seashell",
- "sienna",
- "silver",
- "skyblue",
- "slateblue",
- "slategray",
- "slategrey",
- "snow",
- "springgreen",
- "steelblue",
- "tan",
- "teal",
- "thistle",
- "tomato",
- "turquoise",
- "transparent",
- "violet",
- "wheat",
- "white",
- "whitesmoke",
- "yellow",
- "yellowgreen",
- ]
- | str
-)
-"""A CSS3 color string.
-
-Accepts named colors (``red``, ``blue``), hex (``#rgb``, ``#rrggbb``),
-``rgb()``, ``rgba()``, ``hsl()``, ``hsla()``, and ``transparent``.
-
-See the `CSS Color Module Level 3 <http://www.w3.org/TR/css3-color/#svg-color>`_
-specification.
-"""
-
-type Opacity = float
-type StrokeWidth = float
diff --git a/src/manimgx/primitives/manim_colors.py b/src/manimgx/primitives/manim_colors.py
deleted file mode 100644
index a6e5e798..00000000
--- a/src/manimgx/primitives/manim_colors.py
+++ /dev/null
@@ -1,89 +0,0 @@
-WHITE = "#ffffff"
-GRAY_A = "#dddddd"
-GREY_A = GRAY_A
-GRAY_B = "#bbbbbb"
-GREY_B = GRAY_B
-GRAY_C = "#888888"
-GREY_C = GRAY_C
-GRAY_D = "#444444"
-GREY_D = GRAY_D
-GRAY_E = "#222222"
-GREY_E = GRAY_E
-BLACK = "#000000"
-
-
-BLUE_A = "#c7e9f1"
-BLUE_B = "#9cdceb"
-BLUE_C = "#58c4dd"
-BLUE_D = "#29abca"
-BLUE_E = "#236b8e"
-BLUE = BLUE_C
-
-
-TEAL_A = "#acead7"
-TEAL_B = "#76ddc0"
-TEAL_C = "#5cd0b3"
-TEAL_D = "#55c1a7"
-TEAL_E = "#49a88f"
-TEAL = TEAL_C
-
-
-GREEN_A = "#c9e2ae"
-GREEN_B = "#a6cf8c"
-GREEN_C = "#83c167"
-GREEN_D = "#77b05d"
-GREEN_E = "#699c52"
-GREEN = GREEN_C
-
-
-YELLOW_A = "#fff1b6"
-YELLOW_B = "#ffea94"
-YELLOW_C = "#f7d96f"
-YELLOW_D = "#f4d345"
-YELLOW_E = "#e8c11c"
-YELLOW = YELLOW_C
-
-
-GOLD_A = "#f7c797"
-GOLD_B = "#f9b775"
-GOLD_C = "#f0ac5f"
-GOLD_D = "#e1a158"
-GOLD_E = "#c78d46"
-GOLD = GOLD_C
-
-
-RED_A = "#f7a1a3"
-RED_B = "#ff8080"
-RED_C = "#fc6255"
-RED_D = "#e65a4c"
-RED_E = "#cf5044"
-RED = RED_C
-
-
-MAROON_A = "#ecabc1"
-MAROON_B = "#ec92ab"
-MAROON_C = "#c55f73"
-MAROON_D = "#a24d61"
-MAROON_E = "#94424f"
-MAROON = MAROON_C
-
-
-PURPLE_A = "#caa3e8"
-PURPLE_B = "#b189c6"
-PURPLE_C = "#9a72ac"
-PURPLE_D = "#715582"
-PURPLE_E = "#644172"
-PURPLE = PURPLE_C
-
-
-PINK = "#d147bd"
-LIGHT_PINK = "#dc75cd"
-ORANGE = "#ff862f"
-LIGHT_BROWN = "#cd853f"
-DARK_BROWN = "#8b4513"
-DARK_BLUE = "#236b8e"
-
-
-PURE_RED = "#ff0000"
-PURE_GREEN = "#00ff00"
-PURE_BLUE = "#0000ff"
diff --git a/src/manimgx/primitives/quaternion.py b/src/manimgx/primitives/quaternion.py
deleted file mode 100644
index 9d05e259..00000000
--- a/src/manimgx/primitives/quaternion.py
+++ /dev/null
@@ -1,44 +0,0 @@
-import numpy as np
-
-from manimgx.primitives.vector import Vec3, Vec3DArray, Vec4
-
-IDENTITY_QUAT: Vec4 = np.array([0.0, 0.0, 0.0, 1.0])
-IDENTITY_QUAT.flags.writeable = False
-
-
-def quat_from_angle_axis(angle: float, axis: Vec3) -> Vec4:
-
- norm = float(np.linalg.norm(axis))
- if norm == 0.0:
- return IDENTITY_QUAT.copy()
- normalized = axis / norm
- half = angle / 2.0
- sin_half = np.sin(half)
- return np.array([*(sin_half * normalized), np.cos(half)])
-
-
-def quat_multiply(q1: Vec4, q2: Vec4) -> Vec4:
-
- x1, y1, z1, w1 = q1
- x2, y2, z2, w2 = q2
- return np.array(
- [
- w1 * x2 + x1 * w2 + y1 * z2 - z1 * y2,
- w1 * y2 - x1 * z2 + y1 * w2 + z1 * x2,
- w1 * z2 + x1 * y2 - y1 * x2 + z1 * w2,
- w1 * w2 - x1 * x2 - y1 * y2 - z1 * z2,
- ]
- )
-
-
-def quat_conjugate(q: Vec4) -> Vec4:
- """Return the conjugate (inverse for unit quaternions)."""
- return np.array([-q[0], -q[1], -q[2], q[3]])
-
-
-def quat_rotate_vectors(q: Vec4, vs: Vec3DArray) -> Vec3DArray:
-
- qv = q[:3]
- qw = q[3]
- t = 2.0 * np.cross(qv, vs)
- return vs + qw * t + np.cross(qv, t)
diff --git a/src/manimgx/primitives/rate_functions.py b/src/manimgx/primitives/rate_functions.py
deleted file mode 100644
index bbb2ae24..00000000
--- a/src/manimgx/primitives/rate_functions.py
+++ /dev/null
@@ -1,316 +0,0 @@
-"""Rate functions for animation easing.
-
-Every rate function maps [0, 1] -> [0, 1] and is pure Python (no numpy).
-
-There are three kinds of public symbols:
-
-* **Rate functions** — ``(float) -> float``, usable directly as ``rate_func=...``.
-* **Combinators** — take a rate function (and parameters) and *return* a new rate
- function. ``scaled_func``, ``squished_func``.
-* **The type alias** ``RateFunc = Callable[[float], float]``.
-"""
-
-import math
-from collections.abc import Callable
-
-type RateFunc = Callable[[float], float]
-
-
-# ── Helpers ───────────────────────────────────────────────────────────
-
-
-def _sigmoid(x: float) -> float:
- if x >= 0:
- z = math.exp(-x)
- return 1.0 / (1.0 + z)
- z = math.exp(x)
- return z / (1.0 + z)
-
-
-def _smooth_with_inflection(t: float, inflection: float) -> float:
- error = _sigmoid(-inflection / 2)
- return min(max((_sigmoid(inflection * (t - 0.5)) - error) / (1 - 2 * error), 0), 1)
-
-
-def _bounce_out(t: float) -> float:
- if t < 4 / 11:
- return 121 * t * t / 16
- if t < 8 / 11:
- return (363 / 40) * t * t - (99 / 10) * t + 17 / 5
- if t < 9 / 10:
- return (4356 / 361) * t * t - (35442 / 1805) * t + 16061 / 1805
- return (54 / 5) * t * t - (513 / 25) * t + 268 / 25
-
-
-# ── Core ──────────────────────────────────────────────────────────────
-
-
-def linear(t: float) -> float:
- return t
-
-
-def smooth(t: float) -> float:
- return _smooth_with_inflection(t, 10.0)
-
-
-def smoothstep(t: float) -> float:
- t = max(0.0, min(1.0, t))
- return 3 * t**2 - 2 * t**3
-
-
-def smootherstep(t: float) -> float:
- t = max(0.0, min(1.0, t))
- return 6 * t**5 - 15 * t**4 + 10 * t**3
-
-
-# ── Utility ───────────────────────────────────────────────────────────
-
-
-def rush_into(t: float) -> float:
- return 2 * _smooth_with_inflection(t / 2.0, 10.0)
-
-
-def rush_from(t: float) -> float:
- return 2 * _smooth_with_inflection(t / 2.0 + 0.5, 10.0) - 1
-
-
-def slow_into(t: float) -> float:
- return (1 - (1 - t) * (1 - t)) ** 0.5
-
-
-def double_smooth(t: float) -> float:
- if t < 0.5:
- return 0.5 * smooth(2 * t)
- return 0.5 * (1 + smooth(2 * t - 1))
-
-
-# ── Oscillating ───────────────────────────────────────────────────────
-
-
-def there_and_back(t: float) -> float:
- new_t = 2 * t if t < 0.5 else 2 * (1 - t)
- return smooth(new_t)
-
-
-def there_and_back_with_pause(t: float, pause_ratio: float = 1.0 / 3) -> float:
- a = (1.0 - pause_ratio) / 2.0
- if t < a:
- return smooth(t / a)
- if t < 1 - a:
- return 1.0
- return smooth((1 - t) / a)
-
-
-def wiggle(t: float, wiggles: float = 2.0) -> float:
- return there_and_back(t) * math.sin(wiggles * math.pi * t)
-
-
-# ── Special ───────────────────────────────────────────────────────────
-
-
-def running_start(t: float, pull_factor: float = -0.5) -> float:
- return (1 - t) * pull_factor * t + t * (1 - (1 - t) * pull_factor) * t
-
-
-def lingering(t: float) -> float:
- return smooth(1 - (1 - t) ** 3)
-
-
-def exponential_decay(t: float, half_life: float = 0.1) -> float:
- return 1 - 2 ** (-t / half_life)
-
-
-# ── Combinators ──────────────────────────────────────────────────────
-#
-# These are NOT rate functions themselves — they take a rate function (and
-# parameters) and *return* a new rate function.
-
-
-def scaled_func(func: RateFunc = smooth, proportion: float = 0.7) -> RateFunc:
- def result(t: float) -> float:
- return proportion * func(t)
-
- return result
-
-
-def squished_func(func: RateFunc, a: float = 0.4, b: float = 0.6) -> RateFunc:
- def result(t: float) -> float:
- if a == b:
- return a
- if t < a:
- return func(0)
- if t > b:
- return func(1)
- return func((t - a) / (b - a))
-
- return result
-
-
-# ── Standard easings ─────────────────────────────────────────────────
-
-
-def ease_in_sine(t: float) -> float:
- return 1 - math.cos(t * math.pi / 2)
-
-
-def ease_out_sine(t: float) -> float:
- return math.sin(t * math.pi / 2)
-
-
-def ease_in_out_sine(t: float) -> float:
- return -(math.cos(math.pi * t) - 1) / 2
-
-
-def ease_in_quad(t: float) -> float:
- return t * t
-
-
-def ease_out_quad(t: float) -> float:
- return 1 - (1 - t) ** 2
-
-
-def ease_in_out_quad(t: float) -> float:
- if t < 0.5:
- return 2 * t * t
- return 1 - (-2 * t + 2) ** 2 / 2
-
-
-def ease_in_cubic(t: float) -> float:
- return t**3
-
-
-def ease_out_cubic(t: float) -> float:
- return 1 - (1 - t) ** 3
-
-
-def ease_in_out_cubic(t: float) -> float:
- if t < 0.5:
- return 4 * t**3
- return 1 - (-2 * t + 2) ** 3 / 2
-
-
-def ease_in_quart(t: float) -> float:
- return t**4
-
-
-def ease_out_quart(t: float) -> float:
- return 1 - (1 - t) ** 4
-
-
-def ease_in_out_quart(t: float) -> float:
- if t < 0.5:
- return 8 * t**4
- return 1 - (-2 * t + 2) ** 4 / 2
-
-
-def ease_in_quint(t: float) -> float:
- return t**5
-
-
-def ease_out_quint(t: float) -> float:
- return 1 - (1 - t) ** 5
-
-
-def ease_in_out_quint(t: float) -> float:
- if t < 0.5:
- return 16 * t**5
- return 1 - (-2 * t + 2) ** 5 / 2
-
-
-def ease_in_expo(t: float) -> float:
- if t == 0:
- return 0.0
- return 2.0 ** (10 * t - 10)
-
-
-def ease_out_expo(t: float) -> float:
- if t == 1:
- return 1.0
- return 1 - 2.0 ** (-10 * t)
-
-
-def ease_in_out_expo(t: float) -> float:
- if t == 0:
- return 0.0
- if t == 1:
- return 1.0
- if t < 0.5:
- return 2.0 ** (20 * t - 10) / 2
- return (2 - 2.0 ** (-20 * t + 10)) / 2
-
-
-def ease_in_circ(t: float) -> float:
- return 1 - math.sqrt(1 - t * t)
-
-
-def ease_out_circ(t: float) -> float:
- return math.sqrt(1 - (t - 1) ** 2)
-
-
-def ease_in_out_circ(t: float) -> float:
- if t < 0.5:
- return (1 - math.sqrt(1 - (2 * t) ** 2)) / 2
- return (math.sqrt(1 - (-2 * t + 2) ** 2) + 1) / 2
-
-
-def ease_in_back(t: float) -> float:
- c1 = 1.70158
- c3 = c1 + 1
- return c3 * t**3 - c1 * t**2
-
-
-def ease_out_back(t: float) -> float:
- c1 = 1.70158
- c3 = c1 + 1
- return 1 + c3 * (t - 1) ** 3 + c1 * (t - 1) ** 2
-
-
-def ease_in_out_back(t: float) -> float:
- c1 = 1.70158
- c2 = c1 * 1.525
- if t < 0.5:
- return ((2 * t) ** 2 * ((c2 + 1) * 2 * t - c2)) / 2
- return ((2 * t - 2) ** 2 * ((c2 + 1) * (2 * t - 2) + c2) + 2) / 2
-
-
-def ease_in_elastic(t: float) -> float:
- if t == 0:
- return 0.0
- if t == 1:
- return 1.0
- c4 = (2 * math.pi) / 3
- return -(2.0 ** (10 * t - 10)) * math.sin((t * 10 - 10.75) * c4)
-
-
-def ease_out_elastic(t: float) -> float:
- if t == 0:
- return 0.0
- if t == 1:
- return 1.0
- c4 = (2 * math.pi) / 3
- return 2.0 ** (-10 * t) * math.sin((t * 10 - 0.75) * c4) + 1
-
-
-def ease_in_out_elastic(t: float) -> float:
- if t == 0:
- return 0.0
- if t == 1:
- return 1.0
- c5 = (2 * math.pi) / 4.5
- if t < 0.5:
- return -(2.0 ** (20 * t - 10) * math.sin((20 * t - 11.125) * c5)) / 2
- return (2.0 ** (-20 * t + 10) * math.sin((20 * t - 11.125) * c5)) / 2 + 1
-
-
-def ease_in_bounce(t: float) -> float:
- return 1 - _bounce_out(1 - t)
-
-
-def ease_out_bounce(t: float) -> float:
- return _bounce_out(t)
-
-
-def ease_in_out_bounce(t: float) -> float:
- if t < 0.5:
- return (1 - _bounce_out(1 - 2 * t)) / 2
- return (1 + _bounce_out(2 * t - 1)) / 2
diff --git a/src/manimgx/primitives/units.py b/src/manimgx/primitives/units.py
deleted file mode 100644
index 53645f5e..00000000
--- a/src/manimgx/primitives/units.py
+++ /dev/null
@@ -1,9 +0,0 @@
-import math
-
-type Angle = float
-"""An angle in radians."""
-
-type RunTime = float
-"""A run time in seconds. Must be positive."""
-
-PI = math.pi
diff --git a/src/manimgx/primitives/vector.py b/src/manimgx/primitives/vector.py
deleted file mode 100644
index 3d68a070..00000000
--- a/src/manimgx/primitives/vector.py
+++ /dev/null
@@ -1,22 +0,0 @@
-from typing import Any, Final, Literal
-
-import numpy as np
-
-type Vec3 = np.ndarray[tuple[Literal[3]], np.dtype[np.floating]]
-type Vec4 = np.ndarray[tuple[Literal[4]], np.dtype[np.floating]]
-
-type Vec3DArray = np.ndarray[tuple[int, int], np.dtype[np.floating[Any]]]
-
-
-def freeze_numpy_array(arr: Vec3) -> Vec3:
- arr.flags.writeable = False
- return arr
-
-
-LEFT: Final[Vec3] = freeze_numpy_array(np.array([-1.0, 0.0, 0.0]))
-RIGHT: Final[Vec3] = freeze_numpy_array(np.array([1.0, 0.0, 0.0]))
-UP: Final[Vec3] = freeze_numpy_array(np.array([0.0, 1.0, 0.0]))
-DOWN: Final[Vec3] = freeze_numpy_array(np.array([0.0, -1.0, 0.0]))
-OUT: Final[Vec3] = freeze_numpy_array(np.array([0.0, 0.0, 1.0]))
-IN: Final[Vec3] = freeze_numpy_array(np.array([0.0, 0.0, -1.0]))
-ORIGIN: Final[Vec3] = freeze_numpy_array(np.array([0.0, 0.0, 0.0]))