Skip to content

armgit / klad

Public Imported from GitHub
0

A drawing app built for agent/human collaboration

Rust

The icon is the plain K, without the points

Indicode BVe26bb640551c
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 27a6e5b..7814a8f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,7 +4,7 @@
The first builds, and klad's licences.
-- A new icon, painted in klad: a K in two brush strokes, one of them showing the points that keep it editable.
+- A new icon, painted in klad: a K in two brush strokes.
- Drawings are `.klad` folders in a fresh format, `klad/6` (drawings from the first builds open as they are, except their bones, which are dropped). Drawings from before (`.draw` folders) do not open and are not converted.
- Drawings live well in git: an edit changes only the files of what it edits (`doc.json` keeps no revision or id counter), and copies of a drawing edited apart, in a clone or a worktree, never make the same id, so edits to different layers merge. New ids end in the copy's two-letter tag (`l48qa`, `c12:s349qa`); `klad info` shows it. The editor follows a `git checkout` of an open drawing, and klad never renders an old picture from its cache after one. Recolouring several strokes or fills at once (the selection bar in the editor, or `klad recolour`) moves them to the new colour together and keeps each one's own shade, so a painted-over area stays painted. If a merge still leaves an id used twice, `klad repair` (or **Repair and open** when the drawing won't open) gives every later one a new id and moves its stroke files along.
- Erasers, smudges and blends stay with the strokes they were drawn over: move, copy or delete the strokes and they come along (or split, when only some of the strokes move), and an eraser erases only its own strokes, so moving them never bites into the paint they land on. The selection bar shows what is attached, "attached only" moves it on its own (it attaches to what it lands on), and detach frees it (`klad detach`); a stroke its erasers wipe out completely is skipped by clicks and the lasso. `klad strokes --json` lists `on`, `attached` and `hidden`. Stroke files move to version 2 (format `klad/6`); older drawings open with nothing attached.
diff --git a/docs/DESIGN.md b/docs/DESIGN.md
index 989b5cd..09eb32d 100644
--- a/docs/DESIGN.md
+++ b/docs/DESIGN.md
@@ -29,7 +29,7 @@ crates/
Two binaries from one crate: `klad`, the command line, and `klad-editor`, the editor alone (a windowed program on Windows, the executable of `klad.app` on a Mac, started by the Linux AppImage). `klad open [bundle]` launches the same editor from the command line, on the bundle or, without one, on the start window (new, open, recent). `--no-default-features` builds `klad` without the editor. `klad --version` and the editor's About show the version and `git describe` of the commit it was built from (`crates/version.rs`, shared by both crates' build scripts; `KLAD_BUILD` overrides it).
-**Platforms and packaging (M7).** Folders follow each platform: settings in `~/Library/Application Support/klad`, `%APPDATA%\klad` or `$XDG_CONFIG_HOME/klad`; downloaded fonts in the same places' data folder; drawings in `~/Drawings` by default. The open panel is `NSOpenPanel` on macOS and `rfd` elsewhere (the XDG portal on Linux, the common dialog on Windows). The pen: macOS reads `NSEvent`; elsewhere a pen that the system reports as a touch with force (Windows pens through `WM_POINTER`) draws with that pressure (`pen::from_egui`), and anything else draws as a mouse at full pressure; Linux tablets report no pressure through `winit` yet. `packaging/` makes the downloads: `macos/app.sh` builds `klad.app` (both binaries, lipo'd when several targets are given, the fonts, licences and skill in `Resources`, `.klad` declared as a document package of type `com.indicode.klad.drawing` so Finder shows a drawing as one item and opens it in klad) and a disk image; `archive.sh <target>` builds a `tar.gz` or `zip` with both binaries, `fonts/`, the licences and `SKILL.md`, and an AppImage on Linux when `APPIMAGETOOL` is set; `icon/` draws the icon in klad and packs `klad.icns` and `klad.ico` (the icon is two brush strokes with paint body, the ember one showing its path, points and handles as the point tool draws them; sizes of 64 px and under come from a second drawing with heavier strokes and no points, also kept as `icon-small.png` for small marks, and `build.sh <folder>` keeps both drawings to open in the editor). Builds use the `dist` profile (no debug info, stripped, thin LTO); the samples hash the same from it. The fonts are found next to the binary (`fonts/`), in `../Resources/fonts` or `../share/klad/fonts`. On macOS a drawing opened from Finder arrives as an `application:openURLs:` message, which klad adds to `NSObject` before the event loop starts so it reaches whatever delegate `winit` installs; the paths queue up (`opened.rs`) and the start window or editor opens the last. `klad install` puts `klad` on the terminal's path (a link in `/usr/local/bin` through an administrator prompt on macOS, `~/.local/bin` on Linux, the user's `PATH` on Windows); the editor's document menu runs it as a job. `klad skill` prints the agent skill compiled into the binary; `klad samples` lists and copies the sample drawings a build carries (First start, below). Builds are sold on itch.io (later Steam) for macOS and Windows, and Linux is built from source: on a version tag the `release` workflow builds the Windows version and pushes it to itch.io with butler (never as a workflow artifact, which anyone could download from a public repository) and publishes the changelog section as the release notes, and `just itch-mac` builds and pushes the Mac app from a Mac; `check` runs the format check and the licence and advisory audit on every pull request and every push to `main`; `full`, started by hand from the Actions tab, runs clippy and the tests on Linux, the tests on macOS and the CLI build on Windows (they do not pass on the hosted runners yet, so they are kept off the commits; run `just lint` and `just test` before sending a change). The editor asks the GitHub releases API at most once a day (`updates.rs`, curl on a thread, off in the settings window) and, when a newer version is out, says so in the start window, the message line and About, with a link to what changed; it installs nothing. About's "check now" and `klad updates` check on demand (`updates::spawn`, a channel per check) and say why a check failed: no release published yet, no network, or a feed that does not parse.
+**Platforms and packaging (M7).** Folders follow each platform: settings in `~/Library/Application Support/klad`, `%APPDATA%\klad` or `$XDG_CONFIG_HOME/klad`; downloaded fonts in the same places' data folder; drawings in `~/Drawings` by default. The open panel is `NSOpenPanel` on macOS and `rfd` elsewhere (the XDG portal on Linux, the common dialog on Windows). The pen: macOS reads `NSEvent`; elsewhere a pen that the system reports as a touch with force (Windows pens through `WM_POINTER`) draws with that pressure (`pen::from_egui`), and anything else draws as a mouse at full pressure; Linux tablets report no pressure through `winit` yet. `packaging/` makes the downloads: `macos/app.sh` builds `klad.app` (both binaries, lipo'd when several targets are given, the fonts, licences and skill in `Resources`, `.klad` declared as a document package of type `com.indicode.klad.drawing` so Finder shows a drawing as one item and opens it in klad) and a disk image; `archive.sh <target>` builds a `tar.gz` or `zip` with both binaries, `fonts/`, the licences and `SKILL.md`, and an AppImage on Linux when `APPIMAGETOOL` is set; `icon/` draws the icon in klad and packs `klad.icns` and `klad.ico` (the icon is a K in two brush strokes with paint body and a dry edge, an ink stem and one ember stroke for the arm and the leg; `build.sh <folder>` keeps the drawing to open in the editor). Builds use the `dist` profile (no debug info, stripped, thin LTO); the samples hash the same from it. The fonts are found next to the binary (`fonts/`), in `../Resources/fonts` or `../share/klad/fonts`. On macOS a drawing opened from Finder arrives as an `application:openURLs:` message, which klad adds to `NSObject` before the event loop starts so it reaches whatever delegate `winit` installs; the paths queue up (`opened.rs`) and the start window or editor opens the last. `klad install` puts `klad` on the terminal's path (a link in `/usr/local/bin` through an administrator prompt on macOS, `~/.local/bin` on Linux, the user's `PATH` on Windows); the editor's document menu runs it as a job. `klad skill` prints the agent skill compiled into the binary; `klad samples` lists and copies the sample drawings a build carries (First start, below). Builds are sold on itch.io (later Steam) for macOS and Windows, and Linux is built from source: on a version tag the `release` workflow builds the Windows version and pushes it to itch.io with butler (never as a workflow artifact, which anyone could download from a public repository) and publishes the changelog section as the release notes, and `just itch-mac` builds and pushes the Mac app from a Mac; `check` runs the format check and the licence and advisory audit on every pull request and every push to `main`; `full`, started by hand from the Actions tab, runs clippy and the tests on Linux, the tests on macOS and the CLI build on Windows (they do not pass on the hosted runners yet, so they are kept off the commits; run `just lint` and `just test` before sending a change). The editor asks the GitHub releases API at most once a day (`updates.rs`, curl on a thread, off in the settings window) and, when a newer version is out, says so in the start window, the message line and About, with a link to what changed; it installs nothing. About's "check now" and `klad updates` check on demand (`updates::spawn`, a channel per check) and say why a check failed: no release published yet, no network, or a feed that does not parse.
### Stack
diff --git a/packaging/icon/build.sh b/packaging/icon/build.sh
index ea65ddc..efddcb6 100755
--- a/packaging/icon/build.sh
+++ b/packaging/icon/build.sh
@@ -9,22 +9,15 @@ else
work="$(mktemp -d)"
trap 'rm -rf "$work"' EXIT
fi
-draw() {
- rm -rf "$work/$1.klad"
- "$klad" new "$work/$1.klad" --width 1024 --height 1024 --layers 0 >/dev/null
- for brush in icon-wet icon-dry; do
- python3 "$here/generate.py" --brush "$brush" | "$klad" brushes "$work/$1.klad" --set "$brush" - >/dev/null
- done
- python3 "$here/generate.py" ${2:-} | "$klad" apply "$work/$1.klad" >/dev/null
-}
-draw icon
-draw icon-small --small
+rm -rf "$work/icon.klad"
+"$klad" new "$work/icon.klad" --width 1024 --height 1024 --layers 0 >/dev/null
+for brush in icon-wet icon-dry; do
+ python3 "$here/generate.py" --brush "$brush" | "$klad" brushes "$work/icon.klad" --set "$brush" - >/dev/null
+done
+python3 "$here/generate.py" | "$klad" apply "$work/icon.klad" >/dev/null
"$klad" render "$work/icon.klad" --out "$here/icon.png" >/dev/null
-"$klad" render "$work/icon-small.klad" --out "$here/icon-small.png" >/dev/null
for size in 16 24 32 48 64 128 256 512 1024; do
- drawing=icon
- [ "$size" -le 64 ] && drawing=icon-small
- "$klad" render "$work/$drawing.klad" --scale "$(python3 -c "print($size/1024)")" --out "$work/icon-$size.png" >/dev/null
+ "$klad" render "$work/icon.klad" --scale "$(python3 -c "print($size/1024)")" --out "$work/icon-$size.png" >/dev/null
done
python3 "$here/pack.py" "$work" "$here/klad.icns" "$here/klad.ico"
-echo "$here/icon.png $here/icon-small.png $here/klad.icns $here/klad.ico"
+echo "$here/icon.png $here/klad.icns $here/klad.ico"
diff --git a/packaging/icon/generate.py b/packaging/icon/generate.py
index ff66928..ac6f553 100644
--- a/packaging/icon/generate.py
+++ b/packaging/icon/generate.py
@@ -6,8 +6,8 @@ INK = "#1d2230"
INK_DRY = "#39425c"
EMBER = "#d4612c"
EMBER_DRY = "#f09a48"
-POINT = "#1aa7f2"
SCALE = 0.84
+HEAVY = 1.34
SHIFT = -28
@@ -74,7 +74,7 @@ def stroke(path, size, colour, second, pressure, brush="icon-wet", **extra):
"second": second, "path": path, "pressure": pressure, "taper": [0, 0], **extra}
-def streaks(points, width, tones, seed, count, heavy):
+def streaks(points, width, tones, seed, count):
rng = random.Random(seed)
line = along(points)
@@ -82,7 +82,7 @@ def streaks(points, width, tones, seed, count, heavy):
start = rng.uniform(0, 0.55)
end = min(start + rng.uniform(0.3, 0.7), 0.97)
first = int(start * len(line))
- moved = offset(line[first:max(int(end * len(line)), first + 4)], width * heavy * SCALE * rng.uniform(-0.38, 0.38))
+ moved = offset(line[first:max(int(end * len(line)), first + 4)], width * HEAVY * SCALE * rng.uniform(-0.38, 0.38))
tone = tones[rng.random() < 0.55]
return stroke("M" + " L".join(f"{x} {y}" for x, y in moved), width * rng.uniform(0.08, 0.22), tone, tone,
[0.2, 0.8, 1, 0.8, 0.5, 0.15], brush="icon-dry", opacity=round(rng.uniform(0.16, 0.34), 2),
@@ -90,46 +90,29 @@ def streaks(points, width, tones, seed, count, heavy):
return [one(i) for i in range(count)]
-def paint(heavy):
+def paint():
ember = ["#e77a33", "#b94412"]
ink = ["#343c55", "#11141d"]
lock = {"op": "set", "id": "paint", "lockAlpha": True}
free = {"op": "set", "id": "paint", "lockAlpha": False}
return [
- stroke(d(ARM + LEG[1:]), 156 * heavy, EMBER, EMBER_DRY, [0.16, 0.36, 0.5, 0.56, 0.58, 0.7, 0.9, 1, 0.98, 0.8, 0.5, 0.2]),
- stroke(d(LEG[3:]), 148 * heavy, EMBER, EMBER_DRY, [0.96, 0.9, 0.66, 0.34, 0.1], brush="icon-dry"),
+ stroke(d(ARM + LEG[1:]), 156 * HEAVY, EMBER, EMBER_DRY, [0.16, 0.36, 0.5, 0.56, 0.58, 0.7, 0.9, 1, 0.98, 0.8, 0.5, 0.2]),
+ stroke(d(LEG[3:]), 148 * HEAVY, EMBER, EMBER_DRY, [0.96, 0.9, 0.66, 0.34, 0.1], brush="icon-dry"),
lock,
- *streaks(LEG, 130, ember, 4, 9, heavy),
- *streaks(ARM, 74, ember, 5, 5, heavy),
+ *streaks(LEG, 130, ember, 4, 9),
+ *streaks(ARM, 74, ember, 5, 5),
free,
- stroke(d(STEM), 140 * heavy, INK, INK_DRY, [0.86, 1, 0.98, 0.96, 0.92, 0.84, 0.7]),
- stroke("M" + " L".join(f"{x} {y}" for x, y in along(STEM)[20:]), 132 * heavy, INK, INK_DRY,
+ stroke(d(STEM), 140 * HEAVY, INK, INK_DRY, [0.86, 1, 0.98, 0.96, 0.92, 0.84, 0.7]),
+ stroke("M" + " L".join(f"{x} {y}" for x, y in along(STEM)[20:]), 132 * HEAVY, INK, INK_DRY,
[0.94, 0.9, 0.78, 0.5, 0.22], brush="icon-dry"),
lock,
- *streaks(STEM, 120, ink, 6, 8, heavy),
+ *streaks(STEM, 120, ink, 6, 8),
free,
{"op": "set", "id": "paint", "effects": [{"relief": {"light": [-0.6, -0.8], "strength": 3.6, "softness": 4}}]},
]
-def points():
- line = {"paint": POINT, "width": 5, "cap": "round", "join": "round"}
- handles = (LEG[2], LEG[4])
- anchors = [(ARM[0], False), (ARM[3], False), (LEG[6], False), (LEG[3], True)]
- return [
- layer("points", "vector"),
- node("points", type="path", d=d(ARM + LEG[1:]), fill="none", stroke=line),
- node("points", type="path", d=f"M{handles[0][0]} {handles[0][1]} L{handles[1][0]} {handles[1][1]}", fill="none",
- stroke=line),
- *[node("points", type="ellipse", cx=x, cy=y, rx=12.5, ry=12.5, fill="#ffffff", stroke={"paint": POINT, "width": 5})
- for x, y in handles],
- *[node("points", type="rect", x=x - 16, y=y - 16, w=32, h=32, fill=POINT if chosen else "#ffffff",
- stroke={"paint": "#ffffff" if chosen else POINT, "width": 5}) for (x, y), chosen in anchors],
- {"op": "set", "id": "points", "effects": [{"shadow": {"x": 0, "y": 3, "radius": 5, "color": "#00000050"}}]},
- ]
-
-
-def ops(small):
+def ops():
paper = {"linear": {"from": [0, 100], "to": [0, 924], "stops": [[0, "#f9f2e5"], [1, "#e8d9c0"]]}}
rim = {"linear": {"from": [0, 100], "to": [0, 924],
"stops": [[0, "#ffffffd0"], [0.35, "#ffffff00"], [0.7, "#00000000"], [1, "#0000001c"]]}}
@@ -139,8 +122,7 @@ def ops(small):
node("plate", type="rect", x=102, y=102, w=820, h=820, radius=184, fill="none", stroke={"paint": rim, "width": 4}),
{"op": "set", "id": "plate", "effects": [{"shadow": {"x": 0, "y": 14, "radius": 22, "color": "#00000044"}}]},
layer("paint", "paint", clip=True),
- *paint(1.34 if small else 1),
- *([] if small else points()),
+ *paint(),
]
@@ -148,4 +130,4 @@ if __name__ == "__main__":
if sys.argv[1:2] == ["--brush"]:
print(json.dumps(BRUSHES[sys.argv[2]]))
else:
- print("\n".join(json.dumps(op) for op in ops("--small" in sys.argv)))
+ print("\n".join(json.dumps(op) for op in ops()))
diff --git a/packaging/icon/icon-small.png b/packaging/icon/icon-small.png
deleted file mode 100644
index df4fbbf..0000000
Binary files a/packaging/icon/icon-small.png and /dev/null differ
diff --git a/packaging/icon/icon.png b/packaging/icon/icon.png
index 09813ca..df4fbbf 100644
Binary files a/packaging/icon/icon.png and b/packaging/icon/icon.png differ
diff --git a/packaging/icon/klad.icns b/packaging/icon/klad.icns
index 1d2aee6..2395dba 100644
Binary files a/packaging/icon/klad.icns and b/packaging/icon/klad.icns differ
diff --git a/packaging/icon/klad.ico b/packaging/icon/klad.ico
index d9df51b..92ea84a 100644
Binary files a/packaging/icon/klad.ico and b/packaging/icon/klad.ico differ