JMathAnim
JMathAnim renders animations to MP4 from Java code (Scene2D, play.*). This skill targets 1.5.1. Every rule here was checked by rendering, and the examples in examples/ prove each one.
Before writing a scene
- Read the rule files for what the scene uses (table below). Always read
rules/known-bugs.md. - Extend
starter/StarterScene.java(copy it into the project) and callconfigure(dark)insetupSketch(). - Plan in beats: one idea per beat, each with its own narration line. Read
rules/motion-design.mdfor what makes a beat watchable.
Preserve the user's edits. If a scene file changed since you last read it, assume the change is intentional: re-read it and build on it. Never overwrite it with your earlier version. Ask if a change looks like a mistake.
The ten rules that matter most
- One focal point per beat, revealed in narration order. Nothing appears before it is mentioned. Dim or remove what is no longer discussed.
- Keep content inside the safe area: x within ±1.96, y between −0.97 and 1.075. The view is 4 × 2.25. Run with
-Daudit=trueto list violations. - Position relative to things:
stack().toObject(),align(), groups withsetLayout(). Never place by typed coordinates. - Plain text is
TextMathObjectwith a real font ("Arial"); LaTeX only for math. Body height 0.058, never below 0.050. Predict widths (chars × height × 0.45), and wrap rather than shrink. - End every beat with
endBeat()afterbeat(clipSeconds). Never hand-sum runtimes; they round down per frame. - To show things together, put them in one
play.run(...). Separate calls run one after another. setArrowThickness(5)on every arrow and connector. The default head is huge.- Rounded boxes come from
roundedRectangle(), neverOvalBox.make. - Images enter with
fadeIn, nevershowCreation; it silently adds nothing. - Read the render log for
ERROR. Several failures don't crash: they just leave something out.
Rule files
| topic | file |
|---|---|
| Maven, scene lifecycle, configs, resolution | rules/setup.md |
| coordinates, view size, safe area | rules/coordinates-and-safe-area.md |
| text, LaTeX, sizes, width estimate, wrapping | rules/text.md |
| shapes, colours, setXxx API, fills, layers, shadows | rules/shapes-and-styling.md |
| stack, align, groups, tables | rules/layout.md |
| play.*, Commands, parallel, stagger, morph | rules/animation.md |
| beats, narration sync, pacing | rules/timing-and-beats.md |
| design rules, easing, focus, annotations, camera zoom, scene transitions | rules/motion-design.md |
| arrows, connectors, elbows, braces | rules/arrows-and-connectors.md |
| bitmaps, SVG | rules/images-and-svg.md |
| silent failures and workarounds | rules/known-bugs.md |
After writing a scene
- Compile with
-Xlint:deprecation,rawtypesand fix every warning. - Render at preview size (
-Dpreview=true -Daudit=true) and fix anyAUDITorERRORline. - Look at the video, or grab frames with ffmpeg (
ffmpeg -sseof -0.3 -i media/X_360.mp4 -frames:v 1 last.png). Check for overlaps, clipped text and anything missing. - Render at production size only when the preview is right.