feat(image-editor): wire Gradient (G) — drag to define linear gradient#40
Merged
feat(image-editor): wire Gradient (G) — drag to define linear gradient#40
Conversation
Promotes the Gradient tool from stub to functional. Drag from start to end on the canvas to define a linear gradient that goes FG → BG; result lands as a new image-shape layer covering the full canvas. - New \`Interaction\` kind in \`Canvas.tsx\`: \`gradient-drawing\` (start + current end in canvas-pixel space). mousedown → start; mousemove → update end; mouseup → call \`onCommitGradient(start, end)\` if the drag is non-trivial. - Live preview overlay (white dashed line + black-outlined endpoint dots) drawn after \`renderTo\` so it sits on top, identity transform for pixel-perfect placement. Same pattern as the crop overlay; never bleeds into the export canvas. - \`ImageEditor.handleCommitGradient\` re-derives source-pixel coords (shifting by crop origin if a crop is active) and renders a linear gradient using \`ctx.createLinearGradient\` onto a baseW × baseH canvas. The bitmap is stored at SOURCE resolution so exports are sharp; layer rect spans the full preview canvas. - New \`OptionsBar\` variant: FG + BG color pickers and a hint reminding the user that the start gets FG and the end gets BG. Shape-tools variant signature gains \`bgColor\`/\`setBgColor\`. Removes \`gradient\` from \`STUB_TOOLS\`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
c026152 to
53fc2ee
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Promotes the Gradient tool from stub to functional. Drag from start to
end on the canvas → linear FG→BG gradient lands as a new image-shape
layer covering the full canvas.
Implementation
current end in canvas-pixel space). mousedown → start; mousemove →
update end; mouseup → `onCommitGradient(start, end)` if the drag is
non-trivial.
dots) drawn after `renderTo`, identity transform for pixel-perfect
placement. Same pattern as the crop overlay; never bleeds into export.
crop is active, scales to source pixels, and renders the gradient via
`ctx.createLinearGradient` onto a baseW × baseH canvas. SOURCE-res
bitmap → sharp exports.
start = FG, end = BG.
Removes `gradient` from `STUB_TOOLS`.
Test plan
🤖 Generated with Claude Code