Picture applying a gradient preset and watching your carefully angled gradient snap back to some default angle. VectorCraft's new presets don't do that, because the preset code never touches placement at all.
Here's the PR: storytold/vectorcraft#4701. I opened it on 30 October 2026 and bflatastic merged it the same day.
The missing piece
VectorCraft, an open source vector drawing app built in Rust, keeps a ranked list of its own gaps. Entry G13 said gradient presets were missing: if you liked a gradient, you rebuilt it by hand in each new document.
The fix adds a Presets row to the Gradient panel: a dropdown with the built in gradients by theme and, underneath, any you've saved. Saving, deleting and hiding the row live in the panel's own menu.
Colours change, placement stays
A gradient has two halves. One is the colour ramp: the type (linear, radial or freeform), the stops (where each colour sits), the blending method, and dither on fills (fine noise that hides banding). The other is placement: angle, aspect and origin.
A preset only carries the ramp. VectorCraft already had a command, paint.editGradient, that edits the gradient on the active fill or stroke in place. So the apply command just builds that command's input and calls it (trimmed):
let mut edit = p.clone(); // trimmed: get `o`, the JSON object inside `edit` o.remove("name"); o.insert("stops".into(), stops_json(&g.stops)); let out = s.execute("paint.editGradient", &edit)?; It copies the incoming parameters, drops the preset name, fills in the preset's type, stops and method (and dither on a fill), and runs the existing command. Angle, aspect and origin never appear in it, so they stay as they were.
That one decision bought a lot. Fills versus strokes, a solid colour turning into a gradient, the default paint when nothing is selected, and undo as a single step all come from paint.editGradient's existing rules. None of that logic was rewritten.
Small rules that matter
Saved presets live with the app's preferences, so they're there in every document. Because of that, saving unlinks any stop tied to a swatch in the current document (the colour stays, the link goes). Names are unique regardless of case, built in names are reserved, and built in presets can't be deleted.
The built in presets cost no new artwork: they're the gradient swatches from libraries VectorCraft already computes.
On the drawing side, the swatch popup and the new Presets menu needed the same row (a colour chip plus a name), so both now call one helper, gradient_row.
Review
CodeRabbit flagged duplicate Colour and Path rows in a docs table, while noting they predated my PR. I merged main, which had added more copies, and collapsed each into a single row with all the evidence kept. The bot confirmed the fix, and bflatastic merged.
The lesson
If a command already knows how to make an edit safely, make your feature produce input for it. You get its rules, its undo and its edge cases for free, and the apply code stays short.
Have you ever built a feature as a thin wrapper around an existing command? Did it hold up, or did you end up needing your own version later?
The full story, with all the code, is on my blog: https://ashokramsi.hashnode.dev/vectorcraft-gradient-presets