13 Commits
Author SHA1 Message Date
Kui Xu 5a8445fdc0 feat: preload connected LoadImage mask bounds 2026-08-10 18:14:00 +02:00
Kui Xu ff70017ee1 feat: preview connected LoadImage without execution 2026-08-10 18:01:28 +02:00
Kui Xu 18e42a9d32 feat: improve canvas precision and direct background loading 2026-08-10 16:46:35 +02:00
ku1x 56dcdf50b2 fix: output bbox-cropped image instead of mask-applied image 2026-07-24 19:06:18 +02:00
ku1x 6184822616 feat: add internal_image combo for loading images without running workflow 2026-07-24 19:02:35 +02:00
ku1x 671d9e50bd fix: unify coordinate system between preview canvas and Python output
The root cause was a coordinate space mismatch between the floating panel
canvas and the Python backend:

Before (broken):
- Canvas mask window: fixed ~300px (arbitrary, unrelated to actual mask)
- Preview image: drawn at downscaled pixel size (e.g. 768x512)
- offsetX/Y: interpreted in preview image pixel space
- Python output: interprets offsetX/Y in ORIGINAL image pixel space
- Result: 100px offset in preview = 200px in output (2x mismatch at 50% scale)

After (fixed):
- Python sends orig_h/w (original image dims) + bbox_h/w (mask bbox) via mce_info
- Canvas computes zoom-to-fit so the full original image is visible
- Everything rendered in ORIGINAL image pixel space (zoomed for display)
- Mask window size = bbox_w * zoom × bbox_h * zoom (accurate proportional size)
- DrawImage stretches the preview to fill original dimensions (consistent coords)
- Mouse drag sensitivity = 1 / (zoom * scale) for correct image-pixel mapping
- offsetX/Y values in JS == same values applied by Python (no conversion needed)

This ensures WYSIWYG: what you see in the mask window IS what you get in output.
2026-07-23 15:31:48 +02:00
ku1x 180e2b4b48 refactor: compact node (240×80) + floating DOM canvas panel (ZhiHui style)
- Node body is now small with only a button widget
- Click button opens a floating DOM panel with full interactive canvas
- Panel: header (flip H/V, reset, close) + canvas + sidebar (sliders) + footer
- Canvas shows actual input image with transforms applied in real-time
- Mouse drag to pan, scroll to zoom, shift+scroll to rotate
- Apply button writes state back to hidden bridge widget and re-executes
- onDrawForeground shows a thumbnail preview on the compact node
2026-07-23 15:19:26 +02:00
ku1x 9cbe6517de fix: use prototype-based method overrides for reliable canvas rendering
- Move onDrawForeground, onMouseDown, onMouseMove, onMouseUp to
  beforeRegisterNodeDef prototype pattern (not instance-level)
- Use __mce_ prefixed properties to avoid name collisions
- Move toolbar/grid drawing to standalone functions for clarity
- Ensure setDirtyCanvas fires after all state changes
- Fallback text 'Queue workflow to load preview' when no image loaded
- Preserve image preview across redraws via __mce_img on instance
2026-07-23 15:07:26 +02:00
ku1x e23978d366 feat: render actual input image as canvas background on node body
Python:
- Save input image preview to ComfyUI temp dir after execution
- Use unique_id to generate stable filename per node instance
- Return UI dict with preview filename for frontend consumption

JS:
- Listen for onExecuted to receive preview image filename
- Load actual image from ComfyUI /view API
- Draw image centered at transforms origin — all transforms
  (scale, rotation, flip, offset) apply naturally to the image
- Fall back to checkerboard grid when no preview loaded yet
- Fixed corner marker drawing bug
2026-07-23 14:54:46 +02:00
ku1x 239fb708b2 docs: fix markdown table rendering and polish README 2026-07-23 14:45:50 +02:00
ku1x c602224f57 refactor: make node body a fully interactive canvas editor, remove all slider widgets
- Python: remove visible FLOAT/INT/BOOLEAN param widgets, add hidden transform_state JSON input
- JS: complete rewrite — node body IS the interactive canvas, no modal, no sliders
  - Drag to pan, scroll to zoom, shift+scroll to rotate
  - Toolbar with flip/reset buttons drawn directly on node
  - Hidden bridge widget for state serialization
  - Global wheel listener for reliable zoom/rotate across all ComfyUI versions
- README: update docs to reflect purely graphical design
2026-07-23 14:42:49 +02:00
ku1x dbbd4c4dfd docs: add Mermaid workflow diagram for data flow pipeline 2026-07-23 14:37:08 +02:00
ku1x 4b6ea5f4b8 feat: initial release — Mask Canvas Editor for ComfyUI
Interactive canvas-like visual editor for positioning images behind mask regions.
Supports scale, rotation, flip, and offset transforms with real-time preview.

- Python backend with F.grid_sample based inverse transform chain
- JavaScript frontend with full-screen HTML5 Canvas editor modal
- Mouse drag (pan), scroll (zoom), shift+scroll (rotate) interactions
- Bilingual README (EN + ZH_CN)
2026-07-21 15:29:42 +02:00