limu is a diagram layout engine in Go. It reads Mermaid and leaves the drawing to your program.

How it works

Mermaid and Pele lay out a diagram and write it as SVG for a browser to draw.

A renderer of SVG

limu stops one step earlier, at the scene. A scene is the laid-out diagram as data. It says what each part is and where it goes, but not how it looks. A backend then draws it, whether that is limumygo on the GPU, the svg package, or one you write.

limu

Because the scene holds no colors, it's laid out once and can be drawn any number of ways. Switching themes only redraws it, and a backend can also draw each part its own way.

One scene, laid out once and drawn four ways

The scene Boxes, paths and labels, with no style.

approvereviseDraftReviewShip

Kohu Drawn in limu’s light theme.

Drawn in limu’s light theme.

KohuDark Only the colors change.

Only the colors change.

Liquid Glass Each part drawn its own way, with MyGo’s glass.

Each part drawn its own way, with MyGo’s glass.

An app can also ask the scene which part is under the pointer.

limu in your app

go get github.com/firede/limu/limumygo

limumygo draws a scene on the GPU with MyGo’s native UI and tells you which part is under the pointer. Lay out the diagram with the same fonts you draw it in.

fonts := limumygo.DefaultFontssc, err := limu.Layout(src, &layout.Options{Measurer: fonts})if err != nil {	return err}// Draw the diagram in a view, and see which part was clicked.w := limumygo.View(c, sc, &limumygo.Options{	Look:  style.Look{Theme: style.KohuDark()},	Fonts: fonts,})if it := w.Clicked(); it != nil {	fmt.Println("clicked", it.Role, it.ID)}

Explore

limu and Pele

Most of limu is ported function by function from Pele, the small, fast Mermaid renderer made by the Obsidian team. limu’s tests check that its layouts match Pele’s number for number. limu is open source under the MIT license.

Pele is named after the goddess of Hawaiʻi’s volcanoes. Limu is the Hawaiian word for the algae in its seas, and this site takes its colors from limu kohu, a red alga that grows in tide pools.