I added gradient presets to VectorCraft by reusing one command
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…
VectorCraft, an open source vector drawing app built in Rust, recently added gradient presets to its Gradient panel. The feature eliminates the need to rebuild gradients from scratch each time, as previously required. A PR was opened on October 30th, 2026, and merged on the same day by user bflatastic.
VectorCraft maintains a ranked list of its own gaps, with entry G13 noting the absence of gradient presets. The solution involves adding a Presets row to the Gradient panel, which includes built-in gradients by theme and any user-saved gradients. Saving, deleting, and hiding the row are managed through the panel's own menu.
A gradient comprises two components: the colour ramp, encompassing the gradient type (linear, radial, or freeform), stops, blending method, and dither for fills; and placement, which pertains to angle, aspect, and origin. The new presets only carry the colour ramp, leaving the placement unchanged.
The gradient preset functionality is built upon an existing command, paint.editGradient, which edits the gradient on the active fill or stroke within the document. The apply command for the presets simply builds the input for this command, excluding the preset name. Angle, aspect, and origin are not included, thus remaining unaffected.
The presets are stored with the app's preferences and are available in every document. However, unlinked stops tied to a swatch in the current document are removed when saving, as names are unique regardless of case, built-in names are reserved, and built-in presets cannot be deleted. The built-in presets avoid additional artwork creation, utilizing gradient swatches already computed by VectorCraft.
The new Presets menu and swatch popup share the same row, which now employs a shared helper, gradient_row. CodeRabbit identified duplicate Colour and Path rows in a documentation table, attributing this to pre-PR history. The main branch retained the merged changes, with duplicate rows consolidated into a single row containing all relevant information.
The bot validated the fix, allowing bflatastic to merge it. The lesson learned: when a command already possesses the capability to make edits safely, leveraging it to create a feature is advantageous. It inherits the command's rules, undo functionality, and edge cases, streamlining the apply code and minimizing the need for a separate version later on.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to