Drawlib
Pure-Python Library for "Illustration as Code" & "Illustrated Documentation as Code"
Drawlib is a declarative Python drawing library and integrated multi-format documentation compiler engineered for software developers and autonomous AI coding agents. Instead of maintaining brittle diagrams in external GUI tools (draw.io, Visio, PowerPoint) and manually pasting exported screenshots into wikis, Drawlib lets you author, animate, localize, version-control, and compile architectural diagrams, quantitative charts, technical documents, and 16:9 slide decks entirely from code in Git.
- Official Website & Documentation: English (
www.drawlib.com) | 日本語 (www.drawlib.com/ja/) - Repository Guides & Whitepapers:
Why Drawlib?
1. SmartArt Infographics, Quantitative Charts & Declarative Animations
Compose executive-ready infographics (drawlib.smartarts), quantitative data plots (drawlib.charts), and multi-frame APNG / WebP / GIF animations (drawlib.anim) on the exact same coordinate canvas:
- 18 SmartArt Components (
drawlib.smartarts): High-level structured layouts includingChevronProcess,Cycle,Table,TreeNode,MindMapNode,Pyramid,BoxList,CardList,KpiCards,Roadmap,Panel,BulletPoints,GridLayout, syntax-highlightedSourceCode, offline vector maps (GeoMap), andMonthCalendar/WeekCalendar/DayCalendar.
- 9 Quantitative Charts (
drawlib.charts): Pure-PythonBarChart,LineChart,AreaChart,PieChart,RadarChart,ScatterChart,GanttChart, andHeatmapChart/HeatmapOverlaystyled with the same design tokens as surrounding diagrams—no low-level Matplotlib boilerplate required. - Declarative Animations (
drawlib.anim): Turn any diagram, chart, or workflow into a crisp multi-frame APNG, WebP, or GIF animation (Animation(fps=..., loop=0)) that plays natively inside GitHubREADME.mdfiles, pull requests, and HTML documentation sites.
2. Auto-Layout Graphs & Software Engineering Diagrams
Stop hand-tuning complex node coordinates. Combine automatic graph layout solvers (drawlib.graph) with domain-specific software engineering diagrams (drawlib.diagrams):
- 5 Auto-Layout Coordinate Solvers (
drawlib.graph): Pure coordinate calculators (ArchitectureGraph,LayerGraph,TreeGraph,RadialGraph,GridGraph) that compute overlap-free node centers (.xy), nested cluster bounds, andoffset()fine-tuning viaget_layout()for seamless rendering withdrawlib.diagramsanddrawlib.shapes.
- 6 Technical Diagram Engines (
drawlib.diagrams):- Cloud Architecture (
ArchitectureDiagram): Nested VPC/subnet boundaries, multi-tier service cards, and official cloud provider icons. - Flowcharts (
FlowDiagram): Process steps, decision branches, and orthogonal connectors. - Sequence Diagrams (
SequenceDiagram): Client/server lifelines, synchronous/asynchronous calls, activation bars, and loop/alt frames. - State, UML Class & ER Diagrams (
StateDiagram,ClassDiagram,ERDiagram): State lifecycles, object-oriented class hierarchies, and relational database schemas.
- Cloud Architecture (
3. 34 Icon Suites (4,500+ Icons), 43 Primitives & Semantic Design System
At its core, Drawlib cleanly separates Content (geometry, coordinates, structure) from Style (colors, typography, borders, themes)—just like HTML and CSS:
- 34 Standardized Icon Suites (
drawlib.icons): Over 4,500 offline-cached vector icons spanning Phosphor (1,512icons across5weights), Cloud Providers (gcp,aws,azure), 15 Official Tech Brand Suites (ai,cicd,cloud,code,compute,container,data,database,k8s,linux,mobile,monitoring,network,security,workspace), and 15 Flat 2D Suites (original_*). - Rich Primitives (
drawlib.shapes,lines,images,text,fonts):- 43 Geometric Shapes: Spanning
basic,polygon,arrow,badge,container, andsymbolprimitives. - Lines & Connectors: Straight, curved (
bend), quadratic/cubic Bezier, and rounded polylines with rich arrowheads ("->","<-","<->"). - Images & Nested Canvases: Non-destructive
Dimagetransformations (crop(),sepia(),grayscale(),mosaic(),mirror()) plus in-memory diagram nesting viaget_dimage_from_code(). - Multilingual Typography: Automatic on-demand font caching (
FontRoboto,FontSansSerif,FontSerif,FontSourceCode,FontJapanese,FontChinese,FontKorean,FontArabic, etc.).
- 43 Geometric Shapes: Spanning
- 7-Role Semantic Style System (
drawlib.styles):- 6 built-in themes (
default,google,essentials,monochrome,warm,cold) accessed viaStyles.<Token>(Styles.Neutral,Styles.PrimaryFlat,Styles.SecondaryNeutral,Styles.MutedDashed,Styles.SuccessNeutral,Styles.WarningNeutral,Styles.DangerNeutral).
- 6 built-in themes (
4. Illustrated Documentation & 16:9 Slide Deck as Code (Multi-Locale Ready)
Author Markdown files with embedded ```drawlib code fences inside a unified drawlib.toml project. A single build compiles your repository into web portals, GitHub Markdown, PDFs, editable Word documents, HTML slide decks, and PowerPoint files:
- Unified
drawlib.toml& Multi-Locale (<lang>/) Architecture: Configure project metadata,[build]flags, and[i18n]locales (langs = ["en", "ja"]) indrawlib.tomlwith built-in structural parity checks across<src_dir>/<lang>/trees and locale-suffixed deliverables (*_<lang>.pdf,*_<lang>.docx,*_<lang>.pptx). - 4 Project Scaffolds (
drawlib init project <type>):drawlib init project site [-l en,ja]: Multi-page documentation website (docs_html/with language switcher, search, and sidebar TOC) and GitHub Markdown (docs_markdown/).drawlib init project doc [-l en,ja]: Linear technical specification or whitepaper (*_html/,*_markdown/, vector*_<lang>.pdf, plus editable MS Word*_<lang>.docxvia./<target>_src/build_docx.shordrawlib build docx).drawlib init project slide [-l en,ja]: 16:9 presentation slide deck (::: block+::: notespeaker notes) with native SVG typography, Presenter View, keyboard navigation (slide_html/), vectorslide_<lang>.pdf, and editable MS PowerPointslide_<lang>.pptxvia./<target>_src/build_pptx.shordrawlib build pptx.drawlib init project images: Standalone batch Python illustration scripts (images_src/->images/) backed by sub-millisecond.drawlib/cache.dbincremental caching.
- AI Inner Loop & Human Outer Loop (
drawlib init agent <agent>): Built from the ground up for AI coding agents (Claude Code, Cursor, Antigravity, Copilot, Windsurf, Cline, Roo, Codex, Gemini). Generate native workspace instruction files in one command (drawlib init agent claude), while agents querydrawlib rules show <topic>on demand, render headless coordinate-grid previews viadrawlib show -g, and multimodally self-correct text clipping or layout defects—freeing engineers to focus on high-level architecture and review.
Installation
Install drawlib from PyPI using uv (recommended) or pip (Python >= 3.11):
uv add drawlib
# or: pip install drawlib
Configure AI Agent Instructions (Optional — Strongly Recommended)
If you author code or documentation with an AI coding agent (Claude Code, Cursor, Antigravity, GitHub Copilot, Windsurf, Cline, Roo Code, OpenAI Codex, or Gemini CLI), initialize workspace agent instructions right after installation so your agent automatically follows Drawlib's bottom-left (0, 0) coordinate space, 50%+ neutral style discipline, drawlib init project scaffolding, and 3-stage visual self-correction loop:
drawlib init agent list # List supported agents & target file paths
drawlib init agent claude # -> .claude/rules/drawlib.md
drawlib init agent cursor # -> .cursor/rules/drawlib.mdc
drawlib init agent antigravity # -> .agents/rules/drawlib.md
drawlib init agent claude cursor copilot # Initialize multiple agents (or 'all')
Zero-Config Export & Offline Caching
PDF, MS Word (.docx), and MS PowerPoint (.pptx) export work out of the box—playwright, python-docx, and python-pptx are standard dependencies, and headless Chromium (chromium-headless-shell) downloads automatically on your first drawlib build pdf or drawlib build pptx run.
- Offline / Air-Gapped / CI Environments: Pre-download all fonts, icons, maps, and headless Chromium ahead of time with
drawlib cache download --all(or Chromium only withdrawlib cache download --browser). - Minimal Linux Containers (e.g.,
python:3.12-slimlacking OS shared libraries such aslibnss3orlibgbm1): Install OS browser dependencies once viaplaywright install-deps chromium(orplaywright install --with-deps --only-shell chromium).
Verify the installation:
drawlib --version
Quick Start
1. Standalone Python Script (5-Step Drawing Workflow)
Every Drawlib script follows a clean 5-step pattern: Import -> Setup Canvas -> Draw Zones (Optional) -> Shapes & Lines -> Save:
Create client_server.py:
from drawlib.canvas import save, setup
from drawlib.lines import line
from drawlib.shapes import circle, rectangle
from drawlib.styles import Styles
from drawlib.text import text
setup(width=100, height=44)
# Optional: boundary zone
rectangle((50, 22), 92, 36, style=Styles.MutedDashed)
circle((25, 22), 12,
style=Styles.Neutral, text="Client")
rectangle((75, 22), 26, 20,
style=Styles.PrimaryFlat, text="Server")
line((37, 22), (62, 22),
arrow_head="->", style=Styles.DarkBold)
text((49.5, 27), "REST API", style=Styles.DarkBold)
save()
Run the script with Python to generate client_server.png:
python client_server.py
Core Principles at a Glance
- Bottom-Left Origin
(0, 0):setup(width=100, height=44)defines a Cartesian coordinate canvas wherexspans0..100(left to right) andyspans0..44(bottom to top). - Predictable Coordinate Anchors: Core primitives (
rectangle,circle,icon,image,text) anchor at their center(cx, cy)for effortless alignment, while high-levelChartsandDiagramsanchor at bottom-left(x0, y0). - 50%+ Neutral Baseline: Ground supporting shapes in calm neutral tokens (
Styles.Neutral,Styles.SecondaryNeutral,Styles.MutedDashed) and reserve saturated fills (Styles.PrimaryFlat) for 1–2 focal elements. - Non-Destructive Style Patching (
.patch()): Customize any preset token cleanly viaStyles.MutedBold.patch(text_size=10)orStyles.Primary.patch(shape_line_width=2).
2. Illustrated Documentation & Slide Deck Workflow
Scaffold a multi-page documentation site, linear whitepaper, or 16:9 slide deck in seconds (pass -l en,ja for multi-locale <src_dir>/<lang>/ projects):
# Initialize a bilingual multi-page documentation site in docs_src/ (en/ & ja/)
drawlib init project site -l en,ja
# Or initialize a 16:9 presentation slide deck in slide_src/
drawlib init project slide -l en,ja
# Generate AI coding agent instructions for your IDE / CLI agent
drawlib init agent claude
Inside your Markdown files (docs_src/en/index.md), embed Python drawing blocks using the ```drawlib fence:
# System Architecture
Below is our core request routing pipeline:
```drawlib code=fold align=center file=service_routing.png caption="Service Routing Pipeline"
from drawlib.canvas import save, setup
from drawlib.lines import line
from drawlib.shapes import rectangle
from drawlib.styles import Styles
setup(width=100, height=40)
rectangle((25, 20), width=30, height=16, r=2, style=Styles.Neutral, text="Ingress")
rectangle((75, 20), width=30, height=16, r=2, style=Styles.PrimaryFlat, text="Core API", text_style=Styles.WhiteBold)
line((40, 20), (60, 20), arrow_head="->", style=Styles.DarkBold)
save()
```
Compile, export, and preview with the drawlib CLI:
# Build HTML site, GitHub Markdown, or PDF via generated build script
./docs_src/build.sh
# Export editable MS Word (.docx) or MS PowerPoint (.pptx) per locale
./doc_src/build_docx.sh # or: drawlib build docx doc_src/ -o spec.docx --generate-index
./slide_src/build_pptx.sh # or: drawlib build pptx slide_src/ -o deck.pptx
# Launch local HTTP server with pre-flight broken-link verification
drawlib serve docs_html/ --check
# Render a single diagram with coordinate grid (-g) for visual layout inspection
drawlib show docs_src/en/index.md service_routing.png -g -o preview_grid.png
3. CLI Reference Summary
| Command | Description |
|---|---|
drawlib init project <site|doc|slide|images|list> [-l <langs>] |
Scaffold a documentation site, linear spec, 16:9 slide deck, or image project (drawlib.toml) |
drawlib init agent <agent...|all|list> [-m <auto|always>] |
Generate workspace rule/instruction files for AI coding agents (claude, cursor, antigravity, copilot, windsurf, cline, roo, codex, gemini) |
drawlib build <html|markdown|pdf|docx|slide|pptx|image> |
Compile sources into HTML, Markdown, PDF, MS Word (.docx), HTML Slides, MS PowerPoint (.pptx), or PNG/APNG/WebP images |
drawlib serve <html_dir> [--check] |
Start a local HTTP server for built HTML docs/slides with broken-link verification |
drawlib show <file> [target] [-g] |
Render and inspect a single script or embedded Markdown diagram (with optional coordinate grid) |
drawlib rules show [topic] |
On-demand CLI manual for AI coding agents (overview, style-guide, review-guide, api, lib-*) |
drawlib cache <list|download|clear> |
Manage local font, icon, map, and headless Chromium caches (--all, --browser, --images) |
Links & Resources
- Official Documentation: English (
https://www.drawlib.com/) | 日本語 (https://www.drawlib.com/ja/) - Release Notes & Changelog: English | 日本語
- PyPI Package: https://pypi.org/project/drawlib/
- GitHub Repository: https://github.com/yuichi110/drawlib
- License: Apache License 2.0
Metadata
Release files for drawlib 0.3.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| drawlib-0.3.4.tar.gz | 1.5 MB | Without provenance | Details for drawlib-0.3.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| drawlib-0.3.4-py3-none-any.whl | Python 3 | none | any | Details for drawlib-0.3.4-py3-none-any.whl |
Total release size: 3.5 MB
Release files / drawlib-0.3.4.tar.gz
| Download URL | drawlib-0.3.4.tar.gz |
|---|---|
| Size | 1.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7ef3be530a25cb0a73caec9fffad4306b05341e6f8df7c24387912b938d45069
|
|
BLAKE2b-256 checksum How to use checksums |
dfdb6ff4fb8df4b60fda438cf02d83eaa4a4a33de035a585e960b196ca3812be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux rodete","version":null,"id":"rodete","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / drawlib-0.3.4-py3-none-any.whl
| Download URL | drawlib-0.3.4-py3-none-any.whl |
|---|---|
| Size | 2.0 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0f19ea557465ab7a9ab1b7cb04b64795bb7e6a40e161766c8dc374baca898aad
|
|
BLAKE2b-256 checksum How to use checksums |
8019875bb36d95341e064f03102928ceef7372e7bc19b45e65a38a8c07eb00d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux rodete","version":null,"id":"rodete","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for drawlib 0.3.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.