The mental model behind m0saic
m0 is a layout language. A single string describes how rectangles subdivide inside a canvas — no pixels, no coordinates, just structure.
2(F,3[F,F,F])→// two columns, left gets 70%
10(>,>,>,>,>,>,F,>,>,F)
// three equal rows
3[F,F,F]
// nested: 2 columns, right split into 3 rows
2(F,3[F,F,F])
// gap between two tiles
5(F,>,>,-,F)
// overlay: content layered on top
2(F,F){F}The language is small. () split columns, [] split rows. F claims a tile, > donates space forward, - marks empty space, and {} layers content on top. That’s the entire surface.
CSS is a layout solution for the browser. Flexbox, Grid, and absolute positioning solve responsive, interactive UI. m0 solves a different problem.
F can be replaced with any valid m0 expression — one character or a million. 2(F,F) becomes 2(3[F,F,F],F) by swapping one token. No special API — just strings.The trade-off: m0 is not as responsive. Layouts are designed for a specific resolution, or constructed programmatically. Determinism and cross-platform consistency matter more than dynamic reflow when your output is a rendered frame.
Traditional video tools organize content on a timeline. Layers stack vertically, clips stretch horizontally. Time is the primary axis.
That works for editing. But for generating video programmatically — bar charts, dashboards, data visualizations, social media templates — time is the wrong abstraction. The hard part isn’t sequencing clips. It’s placing content in space.
m0saic uses geometry as its base. m0 is the geometry solution.
Instead of a timeline, you describe a layout. Each rectangle becomes a content slot. Fill the slots with images, videos, text, or colors. Frames are composited onto a final canvas based on the m0 geometry. The engine renders the output using ffmpeg.
Time is just another property of how that static rectangle behaves — enable at 2s, fade in over 500ms, hold for 3s, fade out. The rectangle itself is absolute. Everything else is configuration.
Traditional video scales horizontally — more clips on a longer timeline. m0saic scales vertically through composition. A dashboard is a layout that nests calls to opinionated templates (bar-graph, pie-chart, etc.), each of which returns its own m0 geometry and sources to fill those rectangles. Complexity grows through depth, not duration.
Here’s a real example. The @m0saic/hero/bar-graph/v1 template takes data and renders an animated bar chart. One CLI call:
$ m0saic make @m0saic/hero/bar-graph/v1 \
-w 1920 -h 1080 \
--props '{"values": [72, 45, 88, 31, 66]}' \
-o bar_chart.mp4Same template, same data, different resolution. The template maps data to geometry. The geometry maps to pixels. ffmpeg renders the output. No GUI, no timeline, no manual placement.
m0saic is not a video editor. It’s a video compiler.
Traditional editors are interactive tools for human creativity. m0saic is a deterministic tool for programmatic output. They serve different purposes.
That’s why rectangles. They’re the atom of visual composition — simple enough to reason about, powerful enough to express any grid-based layout, and deterministic enough to compile.