A mathematical animation engine kernel: bezier geometry, mobject scene graph, typed animation combinators and an SVG backend.
当前版本 v0.2.1:69 个测试全过、全目标 check 零警告,示例与浏览器 playground 可运行。目标规模与边界见下文「功能边界」一节。
# 安装 MoonBit 工具链(https://www.moonbitlang.com/download)
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash
moon check --target all # 检查(全目标)
moon test # 运行测试(69 个用例)
moon run examples/morph # 示例一:圆变方动画,输出 SVG 帧序列
moon run examples/formula # 示例二:排版 \frac{x^2}{2} 并输出 SVG
moon run examples/texmorph # 示例三:公式 x^2 ↔ \frac{x^2}{2} 部件匹配变形moon run examples/morph > frames.txt| 包 | 导入路径 | 职责 |
|---|---|---|
| math/ | Lmy271828/moonim/math | Vec2 / Mat3 仿射变换 / Color / BBox |
| geom/ | Lmy271828/moonim/geom | 三次贝塞尔、路径、子路径拆分与点数对齐(Path::align)、弧长裁剪(Path::trim / point_at_proportion / to_dashed)、三角化(earcut 移植)、描边展开 |
| mobject/ | Lmy271828/moonim/mobject | 场景图 ADT:VMobject / Group / Tex(带符号标签),部件枚举与 same_shape,line / arrow 构造器 |
| anim/ | Lmy271828/moonim/anim | Interpolable trait、速率函数族(smooth/rush/wiggle/…)、Animation(transform_to / transform_matching / fade / grow / rotate / show_creation / unwrite / move_along_path / indicate 族 / add_lagged)、交互 Env、Scene 时间轴 |
| graph/ | Lmy271828/moonim/graph | 坐标系与函数图像:axes / number_line(刻度 + MiniTex 数字标签)、plot(函数采样成路径)、count(数字滚动)、map_point 数据→场景映射 |
| tex/ | Lmy271828/moonim/tex | FormulaRenderer trait(扩展点)+ MiniTex 子集排版器 + CachedRenderer 记忆化包装 |
| cache/ | Lmy271828/moonim/cache | 显式键控 LRU 记忆化(见 design.md「缓存层」) |
| backend/svg/ | Lmy271828/moonim/backend/svg | Mobject 树 → SVG 文档序列化 |
| playground/ | — | 浏览器 playground(js 目标构建 + 静态页面,见下节) |
| examples/ | — | 可执行示例(CI 中实际运行并校验输出) |
moon build --target js playground # 产出 _build/js/debug/build/playground/playground.js
python3 -m http.server # 在仓库根目录启动静态服务
# 打开 http://localhost:8000/playground/let circle = @mobject.Mobject::vmobject(
@geom.Path::circle(@math.Vec2::new(200.0, 100.0), 100.0),
)
let square = @mobject.Mobject::vmobject(
@geom.Path::rect(@math.Vec2::new(100.0, 0.0), 200.0, 200.0),
)
let scene = @anim.Scene::new()
scene.add_layer(
@anim.Layer::new(circle, [
@anim.Animation::transform_to(square, duration=2.0),
]),
)
let svg = @svg.render_svg(scene.render_at(1.0)) // t = 1.0s 处的一帧moon fmt # 格式化
moon check # 类型检查
moon test # 白盒测试(各包 *_wbtest.mbt)
moon info # 生成 .mbti 公共接口文件Install
Download zipA mathematical animation engine kernel: bezier geometry, mobject scene graph, typed animation combinators and an SVG backend.