Skip to content

Commit

Permalink
Add setup function to make it easier to use
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonGrace2282 committed Jan 16, 2025
1 parent 0a9626d commit 9c12f87
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 17 deletions.
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ name = "manimforge"
crate-type = ["cdylib"]

[dependencies]
num-traits = "0.2.19"
numpy = "0.21.0"
pyo3 = "0.21.1"
17 changes: 7 additions & 10 deletions examples/circle.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
from manimforge.cairo import CairoCamera
import manimforge as mf
from manim import *

def set_cairo_context_path(self, ctx, vmobject):
points = self.transform_points_pre_display(vmobject, vmobject.points)
if len(points) == 0:
return
CairoCamera().set_cairo_context_path(ctx, vmobject, np.asarray(points, dtype=np.float64))
return self

# Monkeypatch the method
Camera.set_cairo_context_path = set_cairo_context_path

mf.setup()

# Example Scene
class Test(Scene):
def construct(self):
circle = Circle()
self.play(Create(circle))

if __name__ == "__main__":
config.preview = True
config.disable_caching = True
Test().render()
5 changes: 3 additions & 2 deletions manimforge/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from .manimforge import *

__doc__ = manimforge.__doc__
if hasattr(manimforge, "__all__"):
__all__ = manimforge.__all__


from ._setup import setup as setup
17 changes: 17 additions & 0 deletions manimforge/_setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import numpy as np
from manim import Camera

from . import cairo


def setup():
def set_cairo_context_path(self, ctx, vmobject):
points = self.transform_points_pre_display(vmobject, vmobject.points)
if len(points) == 0:
return
cairo.CairoCamera().set_cairo_context_path(ctx, vmobject, np.asarray(points, dtype=np.float64))
return self

# Monkeypatch the method
Camera.set_cairo_context_path = set_cairo_context_path

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ classifiers = [
"Programming Language :: Python :: Implementation :: PyPy",
]
dynamic = ["version"]
dependencies = []
dependencies = ["manim>0.18.0"]

[project.urls]
documentation="https://docs.manim.community/"
homepage="https://www.manim.community/"
repository = "https://github.com/ManimCommunity/manim-forge"

[dependency-groups]
dev = ["manim>0.18.0", "maturin>=1.8.0"]
dev = ["maturin>=1.8.0"]

[tool.maturin]
features = ["pyo3/extension-module"]

0 comments on commit 9c12f87

Please sign in to comment.