Declarative rendering pipeline: JSON in, SVG/PNG/WebP out
Project description
predraw
Declarative rendering pipeline: JSON in, SVG/PNG/WebP out.
The missing link between your AI and the SVGs you want to make.
Install
uv tool install predraw
Quick start
Create a project directory:
my-asset/
main.json
config.json
main.json -- the scene:
{
"width": 400,
"height": 200,
"styles": {
"bg": {"light": "#ffffff", "dark": "#1a1a1a"},
"fg": {"light": "#000000", "dark": "#ffffff"}
},
"elements": [
{"type": "background", "fill": "$bg"},
{
"type": "text",
"id": "title",
"content": "hello world",
"x": 200,
"y": 110,
"anchor": "middle",
"fill": "$fg",
"font": {"family": "Liberation Sans", "size": 48, "weight": 700}
}
],
"pipeline": [
{"action": "text-to-paths", "target": "title"}
]
}
config.json -- output targets:
{
"outputs": [
{"format": "svg", "path": "hello-dark.svg", "mode": "dark"},
{"format": "png", "path": "hello-light.png", "mode": "light"},
{"format": "webp", "path": "hello-dark.webp", "mode": "dark", "quality": 90}
]
}
Build:
predraw build my-asset/
Commands
build [path]
Render all outputs defined in config.json. Path can be a directory (looks for main.json) or a file.
predraw build # current directory
predraw build path/to/project # explicit path
pack [path] [-o file]
Convert a directory project into a single portable JSON file. Imports are resolved and inlined as defs.
predraw pack my-asset/ -o packed.json
unpack <file> [-o dir]
Convert a packed JSON file back into a directory project with separate component files.
predraw unpack packed.json -o my-asset/
Format
Element types
| Type | Purpose | Key properties |
|---|---|---|
background |
Full-canvas fill | fill |
rect |
Rectangle | x, y, width, height, fill |
path |
SVG path | d, fill, opacity, transform |
text |
Text (can convert to paths) | content, font, anchor, charStyles |
group |
Container | elements, transform |
Use (component instantiation)
Reference a component from imports or defs:
{"use": "logo", "transform": {"translate": [100, 50], "scale": [2, 2]}}
Property overrides cascade to children:
{"use": "logo", "fill": "#ff0000", "opacity": 0.5}
Styles
Define color tokens with light/dark variants:
{
"styles": {
"primary": {"light": "#000000", "dark": "#ffffff"},
"muted": {"light": "#666666", "dark": "#999999"}
}
}
Reference with $ prefix: "fill": "$primary". Mode is selected per-output in config.json.
charStyles
Style individual characters differently:
{
"type": "text",
"content": "releasable",
"fill": "#ffffff",
"charStyles": [
{"chars": "rlsbl", "opacity": 1.0},
{"chars": "eeaa", "opacity": 0.12}
]
}
Pipeline
Ordered postprocessing steps:
| Action | Fields | Description |
|---|---|---|
text-to-paths |
target |
Convert text to path outlines via font glyphs |
center |
target, axis (x/y/both) |
Center element on canvas |
place |
target, below, gap |
Position element below another |
group |
targets, id |
Wrap elements into a group |
Components
Split reusable parts into separate files:
project/
main.json
config.json
components/
logo.json
main.json:
{
"imports": {"logo": "./components/logo.json"},
"elements": [
{"use": "logo", "transform": {"translate": [10, 10]}}
]
}
Packed format
predraw pack inlines imports as defs:
{
"defs": {
"logo": {"type": "group", "elements": [...]}
},
"elements": [
{"use": "logo"}
]
}
Config
config.json defines output targets:
{
"outputs": [
{"format": "svg", "path": "out.svg"},
{"format": "png", "path": "out-dark.png", "mode": "dark"},
{"format": "webp", "path": "out.webp", "mode": "dark", "quality": 90}
]
}
| Field | Required | Description |
|---|---|---|
format |
Yes | svg, png, or webp |
path |
Yes | Output file path (relative to project dir) |
mode |
No | light or dark (default: dark) |
quality |
No | WebP quality 1-100 (default: 90) |
JSON Schema
Formal schemas for editor validation and LLM structured output:
schema/scene.schema.json-- scene formatschema/config.schema.json-- config format
Requirements
- Python 3.11+
- System fonts for
text-to-paths(searches standard font directories)
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file predraw-0.1.1.tar.gz.
File metadata
- Download URL: predraw-0.1.1.tar.gz
- Upload date:
- Size: 61.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78ff46f5cc8558460124469201d25c0af2b5611adf29b2f1f246c5301582375e
|
|
| MD5 |
234fbcbd59bdc3c20935b381d2ef6904
|
|
| BLAKE2b-256 |
45d796feef875f6d9dc5576cd2216c3e8414a826958aefa5b27b32bfd70fc01e
|
Provenance
The following attestation bundles were made for predraw-0.1.1.tar.gz:
Publisher:
publish.yml on smm-h/predraw
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
predraw-0.1.1.tar.gz -
Subject digest:
78ff46f5cc8558460124469201d25c0af2b5611adf29b2f1f246c5301582375e - Sigstore transparency entry: 1433721900
- Sigstore integration time:
-
Permalink:
smm-h/predraw@01b0e0126e56392ee32d65e6851fe5e9dd7fb9ee -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/smm-h
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@01b0e0126e56392ee32d65e6851fe5e9dd7fb9ee -
Trigger Event:
release
-
Statement type:
File details
Details for the file predraw-0.1.1-py3-none-any.whl.
File metadata
- Download URL: predraw-0.1.1-py3-none-any.whl
- Upload date:
- Size: 21.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d55686a8a6b7222e5f91662b105085905f08a826edac46f40daa5940ceb5f08a
|
|
| MD5 |
39e67d11f0001e5ac0a5eabba7ef9bdb
|
|
| BLAKE2b-256 |
cf48e7c33430d6d8d5f58abc44b0fec7da6fb41466f8b2e1cea1dc724893789e
|
Provenance
The following attestation bundles were made for predraw-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on smm-h/predraw
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
predraw-0.1.1-py3-none-any.whl -
Subject digest:
d55686a8a6b7222e5f91662b105085905f08a826edac46f40daa5940ceb5f08a - Sigstore transparency entry: 1433722046
- Sigstore integration time:
-
Permalink:
smm-h/predraw@01b0e0126e56392ee32d65e6851fe5e9dd7fb9ee -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/smm-h
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@01b0e0126e56392ee32d65e6851fe5e9dd7fb9ee -
Trigger Event:
release
-
Statement type: