Skip to content

feat: animate mobjects to a target state with animate - #18

Merged
simonhdickson merged 1 commit into
mainfrom
feature/animate-target-state
Nov 17, 2026
Merged

simonhdickson merged 1 commit into
mainfrom
feature/animate-target-state

Conversation

@simonhdickson

Copy link
Copy Markdown
Owner

Summary

  • Adds animate(m, f) in core, Rhai and Python. It morphs a mobject from its state when played to f of that state, moving geometry and style together (manim's .animate, MoveToTarget and animated become).
  • The target is computed when the animation starts playing, so steps in a sequence each begin where the previous one ended. Previously Python's .animate computed its target at build time, so two shift(RIGHT) steps in a sequence ended at x=1 instead of x=2.
  • Text and groups are passed to f as a group of their shapes. Groups gain fill, stroke, color, opacity, fill_opacity and stroke_opacity. Shapes gain color and opacity. The Python .animate chain gains color, opacity, fill_opacity and stroke_opacity.
  • An instant become is animate(...).run_time(0.0).
  • Ports MovingAround to Rhai and Python, with a test that checks both produce the same frames. BooleanOperations now uses animate in place of its four transforms to hand-built targets.
  • Updates docs/ROADMAP.md (item 4 marked done), the animations and gotchas pages of the book, and the hand-maintained reference.md and _native.pyi stubs.
  • Note: as in manim, a rotation inside animate moves each point in a straight line, so a large angle shrinks the shape on the way. The docs point to rotate(m, angle) for a rigid turn.

Testing

  • cargo test for fastanim-core: new tests cover sequenced animate steps planning from the last state, style blending, group animation about a joint center, and run_time(0.0) acting as an instant become.
  • cargo test -p fastanim-script: new tests cover animate from the start state, groups, and the MovingAround port.
  • cargo test -p fastanim-py: 25 passed. This includes MovingAround and BooleanOperations matching their Rhai versions frame by frame, a stub check, and parity tests for the chained .animate methods and animate.
  • cargo fmt --all and cargo clippy --all-targets on core, script and py: clean.
  • Not run: CI. The local environment lacked mold and some ALSA/udev dev packages, so the build used lld and system library paths set through environment variables only. No repo config was changed.

- Add `animate(m, f)` (Rust `fastanim_core::animate`/`animate_group`) that morphs a mobject from its state at play time to `f` of that state, path and style together
- The target is computed at plan time, so steps in a `sequence` start where the last one ended
- Python `m.animate` now chains on shapes and groups, adding `color`, `opacity`, `fill_opacity` and `stroke_opacity`
- Groups gain `fill`, `stroke`, `color`, `opacity` and the opacity setters; `VState::opacity` is added
- Port manim's MovingAround and switch BooleanOperations from `transform` to `animate`
- Update the book, reference and roadmap to match
@simonhdickson
simonhdickson merged commit 8a33391 into main Nov 17, 2026
8 checks passed
@simonhdickson
simonhdickson deleted the feature/animate-target-state branch November 17, 2026 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant