Add draw-to-create shapes + freehand paint to the Inverse FFT tab#11
Merged
Conversation
Replace the Inverse FFT tab's "Add circle/ellipse" buttons with three draw-on-canvas tools: Ellipse and Rectangle (drag to draw, Shift = circle/ square, with editable move/resize handles) and a freehand Paint brush that highlights an irregular Fourier region as a colored transparent overlay. All kinds grab their conjugate partner (point reflection through DC) so the reconstruction stays real, and honour the existing Mask controls (Remove/Keep, Conjugate symmetry, Soft edge). - inverse_fft.py: FourierRect/FourierStrokes + generalized fourier_region_mask (signed-distance rect, disc-union strokes, soft edges) + fourier_region_from_dict; fourier_ellipse_mask kept as a back-compat wrapper. - fft_selection.py: draw-to-create flow with Shift constraint, rectangle patches, q-space-aligned AxesImage paint overlay, handle editing, to_regions(). - fft_viewer_reconstruct_mixin.py: checkable tool buttons (ellipse/rectangle/ freehand icons), brush size + color controls, region-based mask wiring, JSON-safe op params. - state.py: replay all region kinds; paint persists as a compact q-space stroke list. Back-compatible with legacy ellipse-only saved states. Tests: extend test_inverse_fft (rect/strokes/soft-edge/conjugate/region_from_dict/ mixed), rewrite test_fft_selection_gui for the draw/paint interaction. Full suite: 2089 passed, 3 skipped. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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
Replaces the Inverse FFT tab's "Add circle / Add ellipse" buttons with three draw-on-canvas tools:
All three grab their conjugate partner (point reflection through DC) so the reconstruction stays real, and honour the existing Mask controls (Remove/Keep, Conjugate symmetry, Soft edge).
Changes
FourierRect/FourierStrokesdataclasses, generalizedfourier_region_mask(signed-distance rect, disc-union strokes, soft edges),fourier_region_from_dict;fourier_ellipse_maskkept as a back-compat wrapper.AxesImagepaint overlay, handle editing,to_regions().ellipse.png/rectangle.png/freehand.png), brush size + color controls, region-based mask wiring, JSON-safe op params.Testing
test_inverse_fft.py(rect/strokes/soft-edge/conjugate/region_from_dict/mixed) and rewrotetest_fft_selection_gui.pyfor the draw/paint interaction.mask(-q)=mask(q)holds for all region kinds; state replay matches the in-viewer preview exactly.🤖 Generated with Claude Code