Skip to content

dkdc-io/draw

Repository files navigation

draw

GitHub Release PyPI crates.io CI License: MIT

Local-first, sketch-style drawing tool. Excalidraw-inspired, built on Rust with a vanilla JS frontend.

Single binary. No cloud. Your drawings live in ~/.config/draw/drawings/.

Features

  • 9 tools: Select, Rectangle, Ellipse, Diamond, Line, Arrow, Pen (freedraw), Text, Eraser
  • Sketch-style fills: hachure (diagonal lines), cross-hatch, solid, none
  • Full interactions: drag, resize, multi-select, rubber band, pan (scroll/space+drag), zoom (ctrl+scroll)
  • Undo/redo: all operations, including batched multi-element changes
  • Copy/paste/duplicate with proper ID remapping
  • Z-ordering: bring to front/back/forward/backward
  • Styles: stroke color/width/dash, fill color/pattern/density, opacity, font
  • Export: SVG and PNG
  • Document management: auto-save, dirty indicator, rename, list
  • Desktop app: native window via webview (same UI, no browser needed)
  • Python bindings: import dkdc_draw
  • Keyboard-driven: full shortcut set, ? for help overlay

Install

From source (Rust)

cargo install dkdc-draw --features webapp

From source (Python)

uv tool install dkdc-draw

Development

bin/setup    # install dependencies
bin/install  # build and install CLI

Usage

draw --webapp       # launch web UI
draw --app          # launch desktop app
draw new [name]     # create new drawing
draw open <file>    # open .draw.json file
draw list           # list saved drawings
draw export-svg <file> [-o output.svg]
draw export-png <file> [-o output.png] [--scale 2.0]

Python

import dkdc_draw

doc = dkdc_draw.new_document("sketch")
dkdc_draw.save_document(doc, "sketch.draw.json")
svg = dkdc_draw.export_svg(doc)

Examples

Runnable hello-world in both languages:

cargo run --example hello -p dkdc-draw-core   # Rust: writes hello.svg + hello.png
uv run python examples/hello.py               # Python: same, plus hello.draw.json

Both build a small document programmatically and export it. Source: crates/draw-core/examples/hello.rs, examples/hello.py.

Sample gallery

examples/gallery/ contains five canonical drawings — flowchart, sticky-notes, wireframe, sketch, patterns — each committed as .draw.json + .svg + .png. All five are produced by a single Rust example that exercises the full API surface (every element type, every fill pattern, stroke/dash styles, freedraw curves, arrows with heads):

cargo run --example gallery -p dkdc-draw-core

Keyboard shortcuts

Key Action
V Select
R Rectangle
O Ellipse
D Diamond
L Line
A Arrow
P Pen (freedraw)
T Text
E Eraser
G Toggle grid snap
? Help overlay
Ctrl+Z Undo
Ctrl+Shift+Z Redo
Ctrl+S Save
Ctrl+A Select all
Ctrl+D Duplicate
Delete Delete selected
] / [ Bring to front / Send to back

Architecture

crates/
  draw-core/     Document model, serialization, SVG/PNG export, tiny-skia renderer
  draw-cli/      CLI binary (clap)
  draw-webapp/   Axum web server (port 1213) + embedded vanilla JS frontend
  draw-app/      Desktop app (wry webview)
  draw-wasm/     WASM bindings for the renderer
  draw-py/       PyO3 Python bindings

Development

bin/build    # build all (Rust + Python)
bin/check    # run all checks (format, lint, test)
bin/format   # format all code
bin/test     # run all tests

Contributing

See CONTRIBUTING.md. Issues and PRs welcome.

Changelog

See CHANGELOG.md.

License

MIT