Math formulas: TeX subset in pixel style, with write-on and morph animations #18

Closed
opened 2026-11-01 23:22:49 +00:00 by Weissstreifen · 1 comment

Math formulas in the scenes, drawn in the daviz look (pixel glyphs, thick outlines, theme colors), and animated.

Syntax: a TeX subset, so formulas can be pasted from papers and Wikipedia:

beat 2.0 formula "E = mc^2" at=center size=3
beat 3.0 formula "\int_0^\infty e^{-x^2}\,dx = \frac{\sqrt{\pi}}{2}" write=0.8
beat 5.0 highlight formula "\sqrt{\pi}"

Layout engine (source/math/), our own and small, not a full TeX:

  • Superscripts and subscripts, \frac, \sqrt (and \sqrt[n]), sums, products and integrals with limits, \lim, brackets that grow with their content (\left( ... \right)), matrices and vectors (\begin{pmatrix}), \vec, \hat, \bar, \dot, text in formulas (\text{}), spacing (\,, \quad), aligned equations over several lines (&, \\).
  • Greek letters and the common operators and relations (\pm \times \cdot \leq \geq \neq \approx \infty \partial \nabla \in \rightarrow ...).
  • Box layout like TeX (every part is a box with width, height above and depth below the baseline), with sizes snapped to the art pixel grid so the strokes stay crisp: fraction bars, root signs and big brackets are drawn as pixel shapes with the theme's thickness, not as scaled glyphs.

Font: a pixel font with Latin, digits, Greek and the math symbols in two sizes (normal and script for exponents and limits). Check the fonts from the theme issue (#3) cover them, or draw the missing glyphs.

Animation (every glyph and stroke is its own drawable element):

  • Write-on: glyphs appear from left to right (pop with overshoot), fraction bars and root signs draw themselves along their length.
  • Highlight a part of the formula: a colored box or color change on a sub-expression, chosen by its TeX text.
  • Change: one formula turns into the next, with glyphs that both formulas share moving to their new place and the rest fading in or out (simple matching by symbol, left to right).
  • Color parts with \color{2}{x} (series colors of the theme).

Fallback (optional, later): for formulas the subset can't handle, formula-tex "..." renders with an installed LaTeX (latex + dvipng) at canvas size, thresholds it to hard pixels and outlines it. It has no glyph animation, only whole-formula entries.

Done when: a scene writes on the quadratic formula, the Gaussian integral and a 2x2 matrix, crisp at x1 and x3, highlights one term, and morphs a^2 + b^2 = c^2 into c = \sqrt{a^2 + b^2}.

Math formulas in the scenes, drawn in the daviz look (pixel glyphs, thick outlines, theme colors), and animated. **Syntax:** a TeX subset, so formulas can be pasted from papers and Wikipedia: ``` beat 2.0 formula "E = mc^2" at=center size=3 beat 3.0 formula "\int_0^\infty e^{-x^2}\,dx = \frac{\sqrt{\pi}}{2}" write=0.8 beat 5.0 highlight formula "\sqrt{\pi}" ``` **Layout engine** (`source/math/`), our own and small, not a full TeX: - Superscripts and subscripts, `\frac`, `\sqrt` (and `\sqrt[n]`), sums, products and integrals with limits, `\lim`, brackets that grow with their content (`\left( ... \right)`), matrices and vectors (`\begin{pmatrix}`), `\vec`, `\hat`, `\bar`, `\dot`, text in formulas (`\text{}`), spacing (`\,`, `\quad`), aligned equations over several lines (`&`, `\\`). - Greek letters and the common operators and relations (`\pm \times \cdot \leq \geq \neq \approx \infty \partial \nabla \in \rightarrow ...`). - Box layout like TeX (every part is a box with width, height above and depth below the baseline), with sizes snapped to the art pixel grid so the strokes stay crisp: fraction bars, root signs and big brackets are drawn as pixel shapes with the theme's thickness, not as scaled glyphs. **Font:** a pixel font with Latin, digits, Greek and the math symbols in two sizes (normal and script for exponents and limits). Check the fonts from the theme issue (#3) cover them, or draw the missing glyphs. **Animation** (every glyph and stroke is its own drawable element): - Write-on: glyphs appear from left to right (pop with overshoot), fraction bars and root signs draw themselves along their length. - Highlight a part of the formula: a colored box or color change on a sub-expression, chosen by its TeX text. - Change: one formula turns into the next, with glyphs that both formulas share moving to their new place and the rest fading in or out (simple matching by symbol, left to right). - Color parts with `\color{2}{x}` (series colors of the theme). **Fallback (optional, later):** for formulas the subset can't handle, `formula-tex "..."` renders with an installed LaTeX (`latex` + `dvipng`) at canvas size, thresholds it to hard pixels and outlines it. It has no glyph animation, only whole-formula entries. **Done when:** a scene writes on the quadratic formula, the Gaussian integral and a 2x2 matrix, crisp at x1 and x3, highlights one term, and morphs `a^2 + b^2 = c^2` into `c = \sqrt{a^2 + b^2}`.
Weissstreifen added this to the M2 Charts milestone 2026-11-01 23:22:49 +00:00
Author
Owner

The glyphs come from #20 (Monocraft-based bitmap font): Greek and most operators exist, the missing ones are drawn there. Needs a script-size font for exponents and limits.

The glyphs come from #20 (Monocraft-based bitmap font): Greek and most operators exist, the missing ones are drawn there. Needs a script-size font for exponents and limits.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Weissstreifen/daviz#18
No description provided.