Skip to content

Commit

Permalink
Add instructions for usage
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonGrace2282 committed Jan 16, 2025
1 parent 5f3c818 commit da07cd1
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@ Some parts of the python library [Manim](https://www.manim.community) need
to be executed fast. This library contains code
for these computations, but written in Rust
to improve speed.

## Testing
1. Clone the repo
2. Create a virtual environment using something like [`uv`](https://docs.astral.sh/uv/) (`uv venv`)
3. Install dev dependencies (`uv sync`)
4. Build the library (`uv run maturin develop --uv`)
5. Run the example (`uv run manim -p examples/circle.py --disable_caching`)
19 changes: 19 additions & 0 deletions examples/circle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from manimforge.cairo import CairoCamera
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


# Example Scene
class Test(Scene):
def construct(self):
circle = Circle()
self.play(Create(circle))
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ build-backend = "maturin"
[project]
name = "manimforge"
description = "Rust parts of the Animation Library Manim"
version = "0.1.1"
readme = "README.md"
license = "MIT"
requires-python = ">=3.9,<3.13"
Expand All @@ -22,5 +21,8 @@ documentation="https://docs.manim.community/"
homepage="https://www.manim.community/"
repository = "https://github.com/ManimCommunity/manim-forge"

[dependency-groups]
dev = ["manim>0.18.0,<0.20.0", "maturin==1.8.*"]

[tool.maturin]
features = ["pyo3/extension-module"]
2 changes: 1 addition & 1 deletion src/cairo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn consider_points_equal_2d(p1: ArrayView1<f64>, p2: ArrayView1<f64>) -> bool {
let rtol = 1e-5;
let atol = 1e-6; // TODO make this based off vmobject
((p1[0] - p2[0]).abs() <= atol + rtol * p1[0].abs())
& ((p1[1] - p2[1]).abs() <= atol + rtol * p1[1].abs())
&& ((p1[1] - p2[1]).abs() <= atol + rtol * p1[1].abs())
}


Expand Down
1 change: 0 additions & 1 deletion test.py

This file was deleted.

0 comments on commit da07cd1

Please sign in to comment.