predraw 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- predraw-0.1.1/.claude/settings.json +15 -0
- predraw-0.1.1/.github/workflows/ci.yml +18 -0
- predraw-0.1.1/.github/workflows/publish.yml +16 -0
- predraw-0.1.1/.gitignore +24 -0
- predraw-0.1.1/.python-version +1 -0
- predraw-0.1.1/.rlsbl/hashes.json +15 -0
- predraw-0.1.1/.rlsbl/hooks/post-release.sh +8 -0
- predraw-0.1.1/.rlsbl/hooks/pre-release.sh +27 -0
- predraw-0.1.1/.rlsbl/version +1 -0
- predraw-0.1.1/CHANGELOG.md +23 -0
- predraw-0.1.1/CLAUDE.md +20 -0
- predraw-0.1.1/LICENSE +21 -0
- predraw-0.1.1/PKG-INFO +250 -0
- predraw-0.1.1/README.md +237 -0
- predraw-0.1.1/predraw/__init__.py +1 -0
- predraw-0.1.1/predraw/__main__.py +5 -0
- predraw-0.1.1/predraw/bbox.py +304 -0
- predraw-0.1.1/predraw/cli.py +349 -0
- predraw-0.1.1/predraw/fonts.py +198 -0
- predraw-0.1.1/predraw/loader.py +192 -0
- predraw-0.1.1/predraw/model.py +70 -0
- predraw-0.1.1/predraw/output.py +64 -0
- predraw-0.1.1/predraw/pipeline.py +281 -0
- predraw-0.1.1/predraw/renderer.py +200 -0
- predraw-0.1.1/predraw/validator.py +38 -0
- predraw-0.1.1/pyproject.toml +25 -0
- predraw-0.1.1/schema/config.schema.json +49 -0
- predraw-0.1.1/schema/scene.schema.json +496 -0
- predraw-0.1.1/tests/test_predraw.py +731 -0
- predraw-0.1.1/uv.lock +544 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches: [main]
|
|
5
|
+
pull_request:
|
|
6
|
+
branches: [main]
|
|
7
|
+
jobs:
|
|
8
|
+
test:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
strategy:
|
|
11
|
+
matrix:
|
|
12
|
+
python-version: ["3.12", "3.13", "3.14"]
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v6
|
|
15
|
+
- uses: astral-sh/setup-uv@v7
|
|
16
|
+
- run: uv python install ${{ matrix.python-version }}
|
|
17
|
+
- run: uv sync
|
|
18
|
+
- run: uv run python -c "import predraw"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
name: Publish
|
|
2
|
+
on:
|
|
3
|
+
release:
|
|
4
|
+
types: [published]
|
|
5
|
+
permissions:
|
|
6
|
+
contents: read
|
|
7
|
+
id-token: write
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
publish:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v6
|
|
14
|
+
- uses: astral-sh/setup-uv@v7
|
|
15
|
+
- run: uv build
|
|
16
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
predraw-0.1.1/.gitignore
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Python-generated files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[oc]
|
|
4
|
+
build/
|
|
5
|
+
dist/
|
|
6
|
+
wheels/
|
|
7
|
+
*.egg-info
|
|
8
|
+
|
|
9
|
+
# Virtual environments
|
|
10
|
+
.venv
|
|
11
|
+
|
|
12
|
+
# Added by rlsbl
|
|
13
|
+
node_modules/
|
|
14
|
+
*.pyc
|
|
15
|
+
*.log
|
|
16
|
+
.DS_Store
|
|
17
|
+
coverage/
|
|
18
|
+
*.egg-info/
|
|
19
|
+
.rlsbl-notes-*.tmp
|
|
20
|
+
.credentials.json
|
|
21
|
+
.*-cache.json
|
|
22
|
+
.env
|
|
23
|
+
.env.local
|
|
24
|
+
*.local-only
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.13
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
".github/workflows/ci.yml": "1e689a1086bc3f1fb1b493515bfa1b7135ca920f8df79c9047f190c0dd63e865",
|
|
3
|
+
".github/workflows/publish.yml": "361e7d328a7e9aeb8f4ce94cd4fd3b76a1495740b1f7623ff92643319402403b",
|
|
4
|
+
"CHANGELOG.md": "7a6ec46141007c18090a0ff325e2dd68cd51588c4e0b5af7b580365e5eaaca85",
|
|
5
|
+
"LICENSE": "68116658f2927be53e8d038aa46a6a579974633b9e470207fa18ca3e83531974",
|
|
6
|
+
"CLAUDE.md": "641d50a31d6b7cd75f0796e3e8f85456c0c40c761f119fc633a7a8e8e535f4e5",
|
|
7
|
+
"scripts/check-prs.sh": "a438f046ac169256b859873e6f12b66bf629e12fa4bc1f766ed8484af983383c",
|
|
8
|
+
"scripts/record-gif.sh": "c1ab1f4d168ef1572579d857c610e2648b5f2a8e193ece99284626eb16f32c9b",
|
|
9
|
+
"scripts/pre-release.sh": "1b13062dda97df66792df382312263d704a6cc706d2dd3da921f4c470488276d",
|
|
10
|
+
"scripts/post-release.sh": "b455f8511e0b2655509ecf5dcb0ab7da5bb7c961f47910ff8e00cab5bd51f833",
|
|
11
|
+
"scripts/pre-push-hook.sh": "0dd1c23af794cc5e9fb6a3082c7fe821d40683c49ed14bbf81f2f98afcb91fee",
|
|
12
|
+
".claude/settings.json": "99ee3041446e119611136c7c0f1955c1eef7e12ff21350e3da3380351dc25ef4",
|
|
13
|
+
".rlsbl/hooks/pre-release.sh": "1b13062dda97df66792df382312263d704a6cc706d2dd3da921f4c470488276d",
|
|
14
|
+
".rlsbl/hooks/post-release.sh": "b455f8511e0b2655509ecf5dcb0ab7da5bb7c961f47910ff8e00cab5bd51f833"
|
|
15
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Post-release hook. Runs after a successful release (non-fatal).
|
|
3
|
+
# Environment: RLSBL_VERSION is set to the released version.
|
|
4
|
+
# Customize this for your project (e.g., local install, deploy, notify).
|
|
5
|
+
|
|
6
|
+
set -euo pipefail
|
|
7
|
+
|
|
8
|
+
echo "Post-release: v$RLSBL_VERSION"
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Pre-release validation hook.
|
|
3
|
+
# Runs before rlsbl creates a release. Exit non-zero to abort.
|
|
4
|
+
# Detects project type and runs appropriate checks automatically.
|
|
5
|
+
|
|
6
|
+
set -euo pipefail
|
|
7
|
+
|
|
8
|
+
echo "Running pre-release checks..."
|
|
9
|
+
|
|
10
|
+
if [ -f go.mod ]; then
|
|
11
|
+
echo "Detected Go project"
|
|
12
|
+
go vet ./...
|
|
13
|
+
go build ./...
|
|
14
|
+
go test ./... -race -short -count=1
|
|
15
|
+
elif [ -f package.json ]; then
|
|
16
|
+
echo "Detected npm project"
|
|
17
|
+
npm test
|
|
18
|
+
elif [ -f pyproject.toml ]; then
|
|
19
|
+
echo "Detected Python project"
|
|
20
|
+
if command -v uv &>/dev/null; then
|
|
21
|
+
uv run pytest
|
|
22
|
+
elif command -v pytest &>/dev/null; then
|
|
23
|
+
pytest
|
|
24
|
+
fi
|
|
25
|
+
fi
|
|
26
|
+
|
|
27
|
+
echo "Pre-release checks passed."
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.7.0
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
- Bounding box calculation for paths — `place` pipeline step now uses real geometry instead of font-size heuristic
|
|
6
|
+
- Local `fonts/` directory support — project-local fonts searched before system fonts for reproducible rendering
|
|
7
|
+
- Component property overrides — `use` elements can override `fill` (replaces) and `opacity` (multiplies) on referenced components
|
|
8
|
+
|
|
9
|
+
## 0.1.0
|
|
10
|
+
|
|
11
|
+
- Declarative JSON format for describing visual assets (rect, path, text, group, background)
|
|
12
|
+
- `$style` tokens with light/dark mode variants, resolved at render time
|
|
13
|
+
- Per-character text styling via `charStyles`
|
|
14
|
+
- Component system: `imports` + `use` with property overrides (fill, opacity cascade)
|
|
15
|
+
- `text-to-paths` pipeline step via fonttools (converts text to SVG path outlines)
|
|
16
|
+
- Pipeline steps: `center`, `place`, `group`, `text-to-paths`
|
|
17
|
+
- Output formats: SVG, PNG (via cairosvg), WebP (via Pillow)
|
|
18
|
+
- Config-driven outputs with per-output mode selection (`config.json`)
|
|
19
|
+
- `predraw build` — render all outputs from a project directory or single file
|
|
20
|
+
- `predraw pack` — convert directory project to single portable JSON file
|
|
21
|
+
- `predraw unpack` — convert packed file back to directory with components
|
|
22
|
+
- JSON Schema for scene and config formats
|
|
23
|
+
- `predraw validate` — validate scene/config files against the JSON Schema
|
predraw-0.1.1/CLAUDE.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# predraw
|
|
2
|
+
|
|
3
|
+
## Release workflow
|
|
4
|
+
|
|
5
|
+
This project uses [rlsbl](https://github.com/smm-h/rlsbl) for release orchestration.
|
|
6
|
+
|
|
7
|
+
- Update CHANGELOG.md with a `## X.Y.Z` entry describing changes
|
|
8
|
+
- Run `rlsbl release [patch|minor|major]` to bump version and create a GitHub Release
|
|
9
|
+
- CI handles publishing automatically via the publish workflow
|
|
10
|
+
- Never publish manually — always use `rlsbl release`
|
|
11
|
+
- Requires `NPM_TOKEN` secret on GitHub (for npm projects)
|
|
12
|
+
- Use `rlsbl release --dry-run` to preview a release without making changes
|
|
13
|
+
|
|
14
|
+
## Conventions
|
|
15
|
+
|
|
16
|
+
- No tokens or secrets in command-line arguments (use env vars or config files)
|
|
17
|
+
- All file writes to shared state should be atomic (write to tmp, then rename)
|
|
18
|
+
- External calls (APIs, CLI tools) must have timeouts and graceful fallbacks
|
|
19
|
+
- Use `npm link` (npm) or `uv pip install -e .` (Python) for local development
|
|
20
|
+
- CI runs smoke tests on every push; manual testing for UI/UX changes
|
predraw-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 mhxv
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
predraw-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: predraw
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Declarative rendering pipeline: JSON in, SVG/PNG/WebP out
|
|
5
|
+
License-File: LICENSE
|
|
6
|
+
Keywords: declarative,json,pipeline,png,render,rlsbl,svg,text-to-paths,webp
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Requires-Dist: cairosvg>=2.7
|
|
9
|
+
Requires-Dist: fonttools>=4.62.1
|
|
10
|
+
Requires-Dist: jsonschema>=4.20
|
|
11
|
+
Requires-Dist: pillow>=10.0
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
# predraw
|
|
15
|
+
|
|
16
|
+
Declarative rendering pipeline: JSON in, SVG/PNG/WebP out.
|
|
17
|
+
|
|
18
|
+
The missing link between your AI and the SVGs you want to make.
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
uv tool install predraw
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Quick start
|
|
27
|
+
|
|
28
|
+
Create a project directory:
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
my-asset/
|
|
32
|
+
main.json
|
|
33
|
+
config.json
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**main.json** -- the scene:
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"width": 400,
|
|
41
|
+
"height": 200,
|
|
42
|
+
"styles": {
|
|
43
|
+
"bg": {"light": "#ffffff", "dark": "#1a1a1a"},
|
|
44
|
+
"fg": {"light": "#000000", "dark": "#ffffff"}
|
|
45
|
+
},
|
|
46
|
+
"elements": [
|
|
47
|
+
{"type": "background", "fill": "$bg"},
|
|
48
|
+
{
|
|
49
|
+
"type": "text",
|
|
50
|
+
"id": "title",
|
|
51
|
+
"content": "hello world",
|
|
52
|
+
"x": 200,
|
|
53
|
+
"y": 110,
|
|
54
|
+
"anchor": "middle",
|
|
55
|
+
"fill": "$fg",
|
|
56
|
+
"font": {"family": "Liberation Sans", "size": 48, "weight": 700}
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
"pipeline": [
|
|
60
|
+
{"action": "text-to-paths", "target": "title"}
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**config.json** -- output targets:
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"outputs": [
|
|
70
|
+
{"format": "svg", "path": "hello-dark.svg", "mode": "dark"},
|
|
71
|
+
{"format": "png", "path": "hello-light.png", "mode": "light"},
|
|
72
|
+
{"format": "webp", "path": "hello-dark.webp", "mode": "dark", "quality": 90}
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Build:
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
predraw build my-asset/
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Commands
|
|
84
|
+
|
|
85
|
+
### build [path]
|
|
86
|
+
|
|
87
|
+
Render all outputs defined in `config.json`. Path can be a directory (looks for `main.json`) or a file.
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
predraw build # current directory
|
|
91
|
+
predraw build path/to/project # explicit path
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### pack [path] [-o file]
|
|
95
|
+
|
|
96
|
+
Convert a directory project into a single portable JSON file. Imports are resolved and inlined as `defs`.
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
predraw pack my-asset/ -o packed.json
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### unpack \<file\> [-o dir]
|
|
103
|
+
|
|
104
|
+
Convert a packed JSON file back into a directory project with separate component files.
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
predraw unpack packed.json -o my-asset/
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Format
|
|
111
|
+
|
|
112
|
+
### Element types
|
|
113
|
+
|
|
114
|
+
| Type | Purpose | Key properties |
|
|
115
|
+
|---|---|---|
|
|
116
|
+
| `background` | Full-canvas fill | `fill` |
|
|
117
|
+
| `rect` | Rectangle | `x`, `y`, `width`, `height`, `fill` |
|
|
118
|
+
| `path` | SVG path | `d`, `fill`, `opacity`, `transform` |
|
|
119
|
+
| `text` | Text (can convert to paths) | `content`, `font`, `anchor`, `charStyles` |
|
|
120
|
+
| `group` | Container | `elements`, `transform` |
|
|
121
|
+
|
|
122
|
+
### Use (component instantiation)
|
|
123
|
+
|
|
124
|
+
Reference a component from `imports` or `defs`:
|
|
125
|
+
|
|
126
|
+
```json
|
|
127
|
+
{"use": "logo", "transform": {"translate": [100, 50], "scale": [2, 2]}}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Property overrides cascade to children:
|
|
131
|
+
|
|
132
|
+
```json
|
|
133
|
+
{"use": "logo", "fill": "#ff0000", "opacity": 0.5}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Styles
|
|
137
|
+
|
|
138
|
+
Define color tokens with light/dark variants:
|
|
139
|
+
|
|
140
|
+
```json
|
|
141
|
+
{
|
|
142
|
+
"styles": {
|
|
143
|
+
"primary": {"light": "#000000", "dark": "#ffffff"},
|
|
144
|
+
"muted": {"light": "#666666", "dark": "#999999"}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Reference with `$` prefix: `"fill": "$primary"`. Mode is selected per-output in `config.json`.
|
|
150
|
+
|
|
151
|
+
### charStyles
|
|
152
|
+
|
|
153
|
+
Style individual characters differently:
|
|
154
|
+
|
|
155
|
+
```json
|
|
156
|
+
{
|
|
157
|
+
"type": "text",
|
|
158
|
+
"content": "releasable",
|
|
159
|
+
"fill": "#ffffff",
|
|
160
|
+
"charStyles": [
|
|
161
|
+
{"chars": "rlsbl", "opacity": 1.0},
|
|
162
|
+
{"chars": "eeaa", "opacity": 0.12}
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Pipeline
|
|
168
|
+
|
|
169
|
+
Ordered postprocessing steps:
|
|
170
|
+
|
|
171
|
+
| Action | Fields | Description |
|
|
172
|
+
|---|---|---|
|
|
173
|
+
| `text-to-paths` | `target` | Convert text to path outlines via font glyphs |
|
|
174
|
+
| `center` | `target`, `axis` (x/y/both) | Center element on canvas |
|
|
175
|
+
| `place` | `target`, `below`, `gap` | Position element below another |
|
|
176
|
+
| `group` | `targets`, `id` | Wrap elements into a group |
|
|
177
|
+
|
|
178
|
+
### Components
|
|
179
|
+
|
|
180
|
+
Split reusable parts into separate files:
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
project/
|
|
184
|
+
main.json
|
|
185
|
+
config.json
|
|
186
|
+
components/
|
|
187
|
+
logo.json
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
**main.json:**
|
|
191
|
+
```json
|
|
192
|
+
{
|
|
193
|
+
"imports": {"logo": "./components/logo.json"},
|
|
194
|
+
"elements": [
|
|
195
|
+
{"use": "logo", "transform": {"translate": [10, 10]}}
|
|
196
|
+
]
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Packed format
|
|
201
|
+
|
|
202
|
+
`predraw pack` inlines imports as `defs`:
|
|
203
|
+
|
|
204
|
+
```json
|
|
205
|
+
{
|
|
206
|
+
"defs": {
|
|
207
|
+
"logo": {"type": "group", "elements": [...]}
|
|
208
|
+
},
|
|
209
|
+
"elements": [
|
|
210
|
+
{"use": "logo"}
|
|
211
|
+
]
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Config
|
|
216
|
+
|
|
217
|
+
`config.json` defines output targets:
|
|
218
|
+
|
|
219
|
+
```json
|
|
220
|
+
{
|
|
221
|
+
"outputs": [
|
|
222
|
+
{"format": "svg", "path": "out.svg"},
|
|
223
|
+
{"format": "png", "path": "out-dark.png", "mode": "dark"},
|
|
224
|
+
{"format": "webp", "path": "out.webp", "mode": "dark", "quality": 90}
|
|
225
|
+
]
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
| Field | Required | Description |
|
|
230
|
+
|---|---|---|
|
|
231
|
+
| `format` | Yes | `svg`, `png`, or `webp` |
|
|
232
|
+
| `path` | Yes | Output file path (relative to project dir) |
|
|
233
|
+
| `mode` | No | `light` or `dark` (default: `dark`) |
|
|
234
|
+
| `quality` | No | WebP quality 1-100 (default: 90) |
|
|
235
|
+
|
|
236
|
+
## JSON Schema
|
|
237
|
+
|
|
238
|
+
Formal schemas for editor validation and LLM structured output:
|
|
239
|
+
|
|
240
|
+
- `schema/scene.schema.json` -- scene format
|
|
241
|
+
- `schema/config.schema.json` -- config format
|
|
242
|
+
|
|
243
|
+
## Requirements
|
|
244
|
+
|
|
245
|
+
- Python 3.11+
|
|
246
|
+
- System fonts for `text-to-paths` (searches standard font directories)
|
|
247
|
+
|
|
248
|
+
## License
|
|
249
|
+
|
|
250
|
+
MIT
|
predraw-0.1.1/README.md
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
# predraw
|
|
2
|
+
|
|
3
|
+
Declarative rendering pipeline: JSON in, SVG/PNG/WebP out.
|
|
4
|
+
|
|
5
|
+
The missing link between your AI and the SVGs you want to make.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
uv tool install predraw
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick start
|
|
14
|
+
|
|
15
|
+
Create a project directory:
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
my-asset/
|
|
19
|
+
main.json
|
|
20
|
+
config.json
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**main.json** -- the scene:
|
|
24
|
+
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"width": 400,
|
|
28
|
+
"height": 200,
|
|
29
|
+
"styles": {
|
|
30
|
+
"bg": {"light": "#ffffff", "dark": "#1a1a1a"},
|
|
31
|
+
"fg": {"light": "#000000", "dark": "#ffffff"}
|
|
32
|
+
},
|
|
33
|
+
"elements": [
|
|
34
|
+
{"type": "background", "fill": "$bg"},
|
|
35
|
+
{
|
|
36
|
+
"type": "text",
|
|
37
|
+
"id": "title",
|
|
38
|
+
"content": "hello world",
|
|
39
|
+
"x": 200,
|
|
40
|
+
"y": 110,
|
|
41
|
+
"anchor": "middle",
|
|
42
|
+
"fill": "$fg",
|
|
43
|
+
"font": {"family": "Liberation Sans", "size": 48, "weight": 700}
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
"pipeline": [
|
|
47
|
+
{"action": "text-to-paths", "target": "title"}
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**config.json** -- output targets:
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"outputs": [
|
|
57
|
+
{"format": "svg", "path": "hello-dark.svg", "mode": "dark"},
|
|
58
|
+
{"format": "png", "path": "hello-light.png", "mode": "light"},
|
|
59
|
+
{"format": "webp", "path": "hello-dark.webp", "mode": "dark", "quality": 90}
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Build:
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
predraw build my-asset/
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Commands
|
|
71
|
+
|
|
72
|
+
### build [path]
|
|
73
|
+
|
|
74
|
+
Render all outputs defined in `config.json`. Path can be a directory (looks for `main.json`) or a file.
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
predraw build # current directory
|
|
78
|
+
predraw build path/to/project # explicit path
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### pack [path] [-o file]
|
|
82
|
+
|
|
83
|
+
Convert a directory project into a single portable JSON file. Imports are resolved and inlined as `defs`.
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
predraw pack my-asset/ -o packed.json
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### unpack \<file\> [-o dir]
|
|
90
|
+
|
|
91
|
+
Convert a packed JSON file back into a directory project with separate component files.
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
predraw unpack packed.json -o my-asset/
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Format
|
|
98
|
+
|
|
99
|
+
### Element types
|
|
100
|
+
|
|
101
|
+
| Type | Purpose | Key properties |
|
|
102
|
+
|---|---|---|
|
|
103
|
+
| `background` | Full-canvas fill | `fill` |
|
|
104
|
+
| `rect` | Rectangle | `x`, `y`, `width`, `height`, `fill` |
|
|
105
|
+
| `path` | SVG path | `d`, `fill`, `opacity`, `transform` |
|
|
106
|
+
| `text` | Text (can convert to paths) | `content`, `font`, `anchor`, `charStyles` |
|
|
107
|
+
| `group` | Container | `elements`, `transform` |
|
|
108
|
+
|
|
109
|
+
### Use (component instantiation)
|
|
110
|
+
|
|
111
|
+
Reference a component from `imports` or `defs`:
|
|
112
|
+
|
|
113
|
+
```json
|
|
114
|
+
{"use": "logo", "transform": {"translate": [100, 50], "scale": [2, 2]}}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Property overrides cascade to children:
|
|
118
|
+
|
|
119
|
+
```json
|
|
120
|
+
{"use": "logo", "fill": "#ff0000", "opacity": 0.5}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Styles
|
|
124
|
+
|
|
125
|
+
Define color tokens with light/dark variants:
|
|
126
|
+
|
|
127
|
+
```json
|
|
128
|
+
{
|
|
129
|
+
"styles": {
|
|
130
|
+
"primary": {"light": "#000000", "dark": "#ffffff"},
|
|
131
|
+
"muted": {"light": "#666666", "dark": "#999999"}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Reference with `$` prefix: `"fill": "$primary"`. Mode is selected per-output in `config.json`.
|
|
137
|
+
|
|
138
|
+
### charStyles
|
|
139
|
+
|
|
140
|
+
Style individual characters differently:
|
|
141
|
+
|
|
142
|
+
```json
|
|
143
|
+
{
|
|
144
|
+
"type": "text",
|
|
145
|
+
"content": "releasable",
|
|
146
|
+
"fill": "#ffffff",
|
|
147
|
+
"charStyles": [
|
|
148
|
+
{"chars": "rlsbl", "opacity": 1.0},
|
|
149
|
+
{"chars": "eeaa", "opacity": 0.12}
|
|
150
|
+
]
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Pipeline
|
|
155
|
+
|
|
156
|
+
Ordered postprocessing steps:
|
|
157
|
+
|
|
158
|
+
| Action | Fields | Description |
|
|
159
|
+
|---|---|---|
|
|
160
|
+
| `text-to-paths` | `target` | Convert text to path outlines via font glyphs |
|
|
161
|
+
| `center` | `target`, `axis` (x/y/both) | Center element on canvas |
|
|
162
|
+
| `place` | `target`, `below`, `gap` | Position element below another |
|
|
163
|
+
| `group` | `targets`, `id` | Wrap elements into a group |
|
|
164
|
+
|
|
165
|
+
### Components
|
|
166
|
+
|
|
167
|
+
Split reusable parts into separate files:
|
|
168
|
+
|
|
169
|
+
```
|
|
170
|
+
project/
|
|
171
|
+
main.json
|
|
172
|
+
config.json
|
|
173
|
+
components/
|
|
174
|
+
logo.json
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**main.json:**
|
|
178
|
+
```json
|
|
179
|
+
{
|
|
180
|
+
"imports": {"logo": "./components/logo.json"},
|
|
181
|
+
"elements": [
|
|
182
|
+
{"use": "logo", "transform": {"translate": [10, 10]}}
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Packed format
|
|
188
|
+
|
|
189
|
+
`predraw pack` inlines imports as `defs`:
|
|
190
|
+
|
|
191
|
+
```json
|
|
192
|
+
{
|
|
193
|
+
"defs": {
|
|
194
|
+
"logo": {"type": "group", "elements": [...]}
|
|
195
|
+
},
|
|
196
|
+
"elements": [
|
|
197
|
+
{"use": "logo"}
|
|
198
|
+
]
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Config
|
|
203
|
+
|
|
204
|
+
`config.json` defines output targets:
|
|
205
|
+
|
|
206
|
+
```json
|
|
207
|
+
{
|
|
208
|
+
"outputs": [
|
|
209
|
+
{"format": "svg", "path": "out.svg"},
|
|
210
|
+
{"format": "png", "path": "out-dark.png", "mode": "dark"},
|
|
211
|
+
{"format": "webp", "path": "out.webp", "mode": "dark", "quality": 90}
|
|
212
|
+
]
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
| Field | Required | Description |
|
|
217
|
+
|---|---|---|
|
|
218
|
+
| `format` | Yes | `svg`, `png`, or `webp` |
|
|
219
|
+
| `path` | Yes | Output file path (relative to project dir) |
|
|
220
|
+
| `mode` | No | `light` or `dark` (default: `dark`) |
|
|
221
|
+
| `quality` | No | WebP quality 1-100 (default: 90) |
|
|
222
|
+
|
|
223
|
+
## JSON Schema
|
|
224
|
+
|
|
225
|
+
Formal schemas for editor validation and LLM structured output:
|
|
226
|
+
|
|
227
|
+
- `schema/scene.schema.json` -- scene format
|
|
228
|
+
- `schema/config.schema.json` -- config format
|
|
229
|
+
|
|
230
|
+
## Requirements
|
|
231
|
+
|
|
232
|
+
- Python 3.11+
|
|
233
|
+
- System fonts for `text-to-paths` (searches standard font directories)
|
|
234
|
+
|
|
235
|
+
## License
|
|
236
|
+
|
|
237
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|