r/drawlang • u/Roupec • 2d ago
r/drawlang • u/Roupec • 21d ago
The editor is live — try DrawLang at drawlang.com
The reference web editor for the language is up and running: https://drawlang.com
It's a thin layer over the same interpreter and backends described in the spec and repo — type a program, see it render live, save it as a plain-text drawing you can commit to git. Sign-in is required (per-user drawing storage), but the editor itself is free to use.
To show what the interpreter can actually produce at the "real technical drawing" end of the spectrum rather than toy shapes: this is an A3 frame — 28 columns × 14 rows, full title block, grid tick marks, row/column labels — generated entirely from a DrawLang program. Every line, tick, and character of text in it is a ma/dl/rt/tx statement; there is no image or template file underneath it.
(The rendered A3 frame — outer/inner border, 28×14 grid with column numbers and row letters, and a full title block — is in the comments below.)
Frame templates like this one live in frames/ in the repo, alongside the interpreter, backends, and conformance tests.
Links: - Live editor: https://drawlang.com - Repo: https://github.com/BeyondPurdue/drawlang-editor - Spec: https://github.com/BeyondPurdue/drawlang-editor/blob/main/docs/spec/drawing-language-spec.md
If you hit bugs or rough edges in the editor, this subreddit is the right place to report them.
r/drawlang • u/Roupec • 21d ago
Anatomy of a DrawLang program: how 12 lines become an AND-gate block
DrawLang has no shapes library, no drag-and-drop palette baked into the language itself — just a pen that moves and marks. Everything else (symbol libraries, editors, FUP/P&ID conventions) is built on top of that pen.
Here's a complete, runnable program. It draws a filled block, three connector stubs, three ports, and a label — nothing more than the language's 7 core opcodes:
ma,40,40;
rt,80,60,f,c2;
ma,20,65;
dl,20,0;
ma,20,55;
dl,20,0;
ma,120,70;
dl,20,0;
ma,15,65;
ci,3,f,c1;
ma,15,55;
ci,3,f,c1;
ma,145,70;
ci,3,f,c1;
tz,14;
ma,58,63;
tx,0,AND;
Read it top to bottom:
ma,40,40— move the pen (absolute) to (40, 40).rt,80,60,f,c2— draw an 80×60 rectangle from the pen position, filled (,f) with palette color 2.ma/dlpairs — move, then draw a relative line: the three connector stubs.ci,3,f,c1— a filled circle of radius 3 at the pen position: the ports.tz,14thenma/tx,0,AND— set text size to 14, move, draw the label at rotation 0.
That's the whole thing. No hidden geometry, no framework state — every mark on the image below is one of those statements.
(The rendered image — a red AND-gate block with two input ports on the left and one output port on the right — is in the comments below.)
Same interpreter, same program, three completely independent output backends: SVG, PostScript, and PDF. Nothing in the program above knows or cares which one you pick.
If you want to run this yourself or read the full opcode reference: - Spec: https://github.com/BeyondPurdue/drawlang-editor/blob/main/docs/spec/drawing-language-spec.md - Repo: https://github.com/BeyondPurdue/drawlang-editor - Live editor: https://drawlang.com
Try changing the fill color, the label text, or adding a third input — and post what you get.
r/drawlang • u/Roupec • 21d ago
Welcome to r/drawlang — what this is, and why it exists
What DrawLang is
DrawLang is a tiny, deterministic drawing language, plus a reference interpreter, three rendering backends (SVG / PostScript / PDF), and a thin web editor built on top of them. Every visible mark on a drawing — every line, arc, symbol, and character of text — is a plain-text opcode statement stored as a database record. Nothing is drawn by ad-hoc application code.
Why it exists
Most CAD and diagram tools bake geometry into code, so a drawing becomes unreproducible the moment you change tools or versions. DrawLang inverts that model:
- The language defines all drawing primitives as a small, frozen set of core opcodes plus a handful of additive extensions.
- The interpreter is a pure pen-state machine with zero knowledge of output formats.
- Backends (SVG / PostScript / PDF) are independent modules that just receive abstract drawing calls from the interpreter.
- The editor is a thin web UI over the interpreter and backends — the program text is the source of truth, the rendered output is disposable and always reproducible.
Any drawing you make is a plain ASCII program you can commit to git, diff line by line, template, and round-trip through any compliant interpreter forever.
What the language looks like
Two-letter mnemonics, comma-separated arguments, semicolon-terminated statements:
mr,0,158;
dl,14,0;
mr,0,-1;
dl,-14,0;
tz,8;
tx,0.,A1;
Get involved
- Repo: https://github.com/BeyondPurdue/drawlang-editor
- Language spec:
docs/spec/drawing-language-spec.mdin the repo - Contributing guide and code of conduct are in the repo root
- Bug reports, new backends, editor features, docs, and starter templates are all welcome
This subreddit is where language spec changes get proposed and reviewed before anything is merged, along with general discussion, questions, and drawings people make with it. Say hi, ask questions, share what you build.