Diagrams as source files.
DiagramIDE is a small workspace for writing Pikchr diagrams, previewing the rendered result, and keeping related source fragments in one place. It is built for users who prefer diagrams to remain inspectable as text.
A diagram may be written directly in Pikchr, assembled from named fragments, or generated from a small program — Prolog DCGs, Tcl, or Ruby. Rendered output can be exported as SVG, PNG, transparent PNG, or copied as Pikchr source.
Direct Pikchr source and paired render window.
Ruby output used to generate Pikchr.
Export menu: SVG, PNG, transparent PNG, and Pikchr source.
Source
- Pikchr editor with live preview — see the output (or errors) as you type.
- Plain-text fragments and named editors for reuse.
Generation — produce Pikchr from a small program when the structure is repetitive:
- Prolog — define diagrams as DCGs (root
diagram//0); runs Trealla Prolog embedded via WASM. - Tcl — concise text-transformation scripting; requires Tcl 8.6 libraries.
- Ruby — generate Pikchr through
print/puts; requires Ruby available.
Composition — reference one editor from another:
$$name$$— include another editor's generated Pikchr output.!!name!!— include another editor's raw source.
Workspaces
- Multiple related editors, render windows, and snippets in one place, with autosaving.
Export
- SVG · PNG (opaque) · PNG (transparent) · copy generated Pikchr source.
- Renders use the Space Mono font for crisp preview and PNG output.
- Write — create the diagram in Pikchr, or generate Pikchr when the structure is repetitive.
- Inspect — keep source and rendered diagram visible at the same time.
- Reuse — move repeated shapes, labels, or layout fragments into named editors.
- Export — produce an image or copy the generated source when the diagram is ready.
Build from source (cargo install --path . installs DiagramIDE, the default root
binary), grab the 1.0.0 release, or try the
Nightly Release.
This repository is a Cargo workspace. DiagramIDE (at the repo root) is the application; the following are satellite projects:
| Project | Crate · path | Role | License |
|---|---|---|---|
| pikchr.pro | pikchr_pro · crates/pikchr_pro |
core Prolog→Pikchr→SVG library + CLI | GPL-3.0-only |
| pikchr.pl | pikchr_pl · crates/pikchr_pl |
older iced-based GUI, superseded by DiagramIDE | GPL-3.0-only |
trealla-wasm |
crates/trealla_wasm |
Trealla Prolog over WASM runtime | MIT |
pikchr_pro reads a Prolog file on STDIN (expecting a diagram//0 DCG) and writes
the rendered SVG to STDOUT:
cat my_diagram.pl | pikchr_pro > output.svg
The original iced-based GUI, now superseded by DiagramIDE (egui). It remains in-tree and still ships in the nightly releases.
DiagramIDE works and can create and export diagrams, but it is not yet polished:
- Workspace autosaving works, but an update could wipe your workspace — keep backups.
- Some obvious things are missing (e.g. indenting selected lines, shortcuts for many actions).
- Expect code crumbs, verbose debugging, and undocumented behavior.
Hidden features
- Cmd/Ctrl+R in an editor renames it.
$$EDITOR_NAME$$embeds an editor's generated Pikchr in another editor.!!EDITOR_NAME!!embeds an editor's raw source in another editor.- Cmd/Ctrl+click destroys a window (the × button only hides it).
DiagramIDE currently embeds Tcl and Prolog for generation. There are two requirements for a language to be integrated:
- It must be able to return text (valid Pikchr after transformation).
- It must be embeddable into Rust.
Prolog (Trealla, via WASM) was the first, since DCGs enable declarative diagrams
and composition through atoms. After writing a Prolog helper library (embedded
into pikchr.pl, not DiagramIDE itself) I found I'd often rather write raw Pikchr.
Tcl joined second — by accident, it turned out to be an excellent fit for the text transformation DiagramIDE does. Other languages may follow (M4 as a macro layer, Markdown for diagrams-plus-text); the deciding factor is Rust embeddability (e.g. Starlark).
- I'm a fan of visual communication, but drawing diagrams (and updating them later) is hard.
- Most diagramming tools are constrained — you hit a wall where you accept subpar output or fight the tool.
- Graphics programs don't support composition: you can't declare "this is my node" and edit all instances.
- Pikchr is the closest fit, but its scripting is limited — no conditional logic, no smart loops.
- Pikchr renders to SVG without a font or background, making SVG hard to use in code, and rasterizing SVG cleanly is non-trivial.
- And in the end — it's nice to see where your diagram is at as you make it.
DiagramIDE is licensed under the Business Source License 1.1 (BSL). The satellite projects pikchr.pl and pikchr.pro are licensed under the GPL-3.0-only.
- DiagramIDE (
diagramide, this crate) — Business Source License 1.1. Source-available; mandated/corporate use requires a commercial license. Converts to GPL-3.0-or-later on 2029-01-01. See LICENSE and NOTICE. - pikchr.pl / pikchr.pro (
pikchr_pl,pikchr_pro) — GPL-3.0-only. See each crate'sLICENSE. - trealla-wasm (
trealla_wasm) — MIT. See itsLICENSE. - Space Mono font — SIL Open Font License 1.1. See
assets/fonts/LICENSE.SpaceMono. - Trealla Prolog — MIT-style license. See
crates/trealla_wasm/native/tpl/LICENSE. - Pikchr — the author disclaims copyright (zero-clause BSD). See the header of
crates/pikchr_pro/native/pikchr/pikchr.c.
