Commit Graph

363 Commits

Author SHA1 Message Date
Dariusz L
4de1812370 Update config.js 2025-07-30 13:35:53 +02:00
Dariusz L
e3cef041c9 Implement robust world-based positioning for Blend Mode menu
Redesigned the positioning system for the Blend Mode menu, inspired by the "Custom Output Area" logic. The menu now anchors precisely to the top-right corner of the viewport and stays in place during panning and zooming.
2025-07-30 13:06:01 +02:00
Dariusz L
03950b1787 Implement adaptive selection frame based on layer coverage
Added a smart selection frame for layers that dynamically switches between solid and dashed lines depending on visibility:

Functionality:

Solid line: visible edge segments, not covered by other layers

Dashed line: covered edge segments, obscured by layers with higher zIndex and opacity > 0.1
2025-07-30 11:43:29 +02:00
Dariusz L
3d60c6aafa Move setOutputAreaSize 2025-07-30 11:37:26 +02:00
Dariusz L
fcb5565a28 Fix "Output Area Size" button behavior using new sizing method
Refactored the "Output Area Size" button to use the new setOutputAreaSize method:

Correctly sets output area size and position based on current system logic (custom shape, extensions, outputAreaBounds)

Fully functional across all editor modes

New resizing logic:

Operates relative to the current center of the output area

Output area expands or contracts around its center without repositioning

Ensures center remains unchanged as expected

This fix provides precise control over layout dimensions and aligns with user expectations across workflows.
2025-07-30 11:17:48 +02:00
Dariusz L
fb5bbdd187 Unify styling for "Run GC" and "Clear Cache" buttons
Updated the "Run GC" and "Clear Cache" buttons to match the styling of standard UI buttons
2025-07-30 11:10:13 +02:00
Dariusz L
7662a501a4 Add right-click deselection for layers
Implemented a new feature: right-clicking a layer in the layer panel now deselects it (if it was selected).
2025-07-30 11:06:37 +02:00
Dariusz L
fc4c343418 Improve minimized "Custom Output Area Active" styling
Unified the appearance of the minimized "Custom Output Area Active" bar with the full menu styling:
2025-07-30 11:05:04 +02:00
Dariusz L
b09f9789de Last Point yellow
Added a clear first point distinction when drawing a custom shape: if the mouse cursor is near the beginning of a line (the shape can be closed), the first point is drawn in yellow and larger. This allows the user to see when they can close the shape with a single click. The code has been compiled and is ready to use. The functionality works as expected.
2025-07-30 10:37:12 +02:00
Dariusz L
0de9aabb72 Hide pending generation areas 2025-07-30 09:52:07 +02:00
Dariusz L
3941104bd5 Tooltip Menu change to modern layout 2025-07-28 19:42:10 +02:00
Dariusz L
6b04e3891b Changed to switch button mask on/off 2025-07-28 19:02:29 +02:00
Dariusz L
257bada28d Nice Icon Comfy Clipspace
Nice Icon Comfy Clipspace
2025-07-28 17:54:50 +02:00
Dariusz L
7f39cfc8ed modernized the "Custom Shape Menu"
I updated src/css/custom_shape_menu.css with new styles for a modern look and feel, and I refactored src/CustomShapeMenu.ts to use a new HTML structure for the checkboxes that works with the updated CSS. The menu should now be fully functional with the new design.
2025-07-28 17:05:57 +02:00
Dariusz L
d2b7b396aa moved all CSS from src/CustomShapeMenu.ts to a new file
moved all CSS from src/CustomShapeMenu.ts to a new file src/css/custom_shape_menu.css and updated the TypeScript file to use the external stylesheet. This improves code organization and maintainability.
2025-07-28 16:43:59 +02:00
Dariusz L
0bae8c9c9d fixed the persistent shape preview bug
fixed the persistent shape preview bug where blue dashed lines would remain visible even when the user was no longer interacting with the slider. The issue was caused by race conditions and timing problems in the preview system.
2025-07-28 16:38:45 +02:00
Dariusz L
f57b9f6b58 Layout change 2025-07-28 15:57:28 +02:00
Dariusz L
bb687a768b Refactor text rendering and adjust viewport defaults
Introduced a drawTextWithBackground helper to centralize and simplify text rendering with backgrounds in CanvasRenderer (JS/TS). Updated all relevant usages to use this helper. Adjusted initial viewport x/y offsets in Canvas and Canvas.ts for improved default positioning.
2025-07-28 02:50:01 +02:00
Dariusz L
5e9869f827 Refactor notifications and improve matting UX
Refactored notification utilities for a more modern, reusable notification system and added info/success/error notifications to the background removal (matting) workflow. Removed the custom error dialog in favor of notifications, and exposed all notification types for debugging. Updated imports and cleaned up notification-related code.
2025-07-28 00:58:04 +02:00
Dariusz L
bfea0cdbab Enhance notification system and auto-correct node_id
Adds a modern, type-based notification UI with support for success, error, info, warning, and alert styles, including a new showAlertNotification function. CanvasState now auto-corrects the node_id widget before saving state and notifies the user if a correction occurs. CanvasView centering logic now uses the actual canvas container for more accurate viewport adjustments.
2025-07-28 00:28:15 +02:00
Dariusz L
7701ceda56 Center canvas viewport on fullscreen toggle
Adds logic to adjust the canvas viewport to keep content centered when entering or exiting fullscreen mode. The adjustment calculates the difference in container sizes and updates the viewport position accordingly, improving user experience during fullscreen transitions.
2025-07-27 22:51:37 +02:00
Dariusz L
9e4e618955 Add ESC key support to close fullscreen editor
Implemented an ESC key handler to allow users to close the fullscreen editor mode using the Escape key. Updated the editor button tooltip and the shortcuts documentation to reflect this new shortcut.
2025-07-27 21:39:18 +02:00
Dariusz L
19d1f9aa52 Move mask rendering before preview outlines
The mask is now drawn after layers but before all preview outlines, ensuring correct visual stacking. The redundant mask rendering code after the preview outlines has been removed.
2025-07-27 21:23:05 +02:00
Dariusz L
8d6cd783ec Restore and save outputAreaBounds in CanvasState
Adds logic to restore outputAreaBounds from saved state if available, or fallback to a default for legacy saves. Also ensures outputAreaBounds is included when saving state, improving consistency across sessions.
2025-07-27 21:17:52 +02:00
Dariusz L
7fc49d72f5 Update MaskEditorIntegration.js 2025-07-27 21:11:06 +02:00
Dariusz L
e68fc7e2cb Add dynamic wait time based on image size
Introduced a calculateDynamicWaitTime method to determine wait time before applying a mask, scaling the delay according to the image's pixel count. This improves responsiveness and reliability for different image sizes in the mask editor integration.
2025-07-27 21:10:58 +02:00
Dariusz L
058a1c4d67 Standart Error in Utils 2025-07-27 20:30:06 +02:00
Dariusz L
64ee2c6abb createElement to createCanvas 2025-07-27 20:02:45 +02:00
Dariusz L
f36f91487f Replace alert with notification utilities and refactor canvas creation
Replaces all uses of alert() with showErrorNotification or showSuccessNotification for improved user experience and consistency. Refactors canvas creation to use the createCanvas utility function across multiple files, reducing code duplication and improving maintainability. Also updates layer ID generation to use generateUUID.
2025-07-27 19:12:25 +02:00
Dariusz L
207bacc1f8 Refactor image and mask utility functions
Moved convertToImage, createMaskFromImageSrc, and canvasToMaskImage from MaskProcessingUtils and mask_utils to ImageUtils for better modularity and reuse. Updated imports in dependent modules to use the new locations. Removed duplicate implementations from mask_utils and MaskProcessingUtils.
2025-07-27 18:47:41 +02:00
Dariusz L
9d0c946e22 Refactor canvas creation to use createCanvas utility
Replaces direct usage of document.createElement('canvas') and manual context setup with the createCanvas utility across multiple utility modules. This change improves code consistency, reduces duplication, and centralizes canvas/context creation logic. Also updates notification usage in ClipboardManager to use showNotification and showInfoNotification utilities.
2025-07-27 18:34:46 +02:00
Dariusz L
7e71d3ec3e Refactor image, mask, and notification logic into utils
Extracted image upload, mask processing, notification, and preview update logic into dedicated utility modules. Updated MaskEditorIntegration and SAMDetectorIntegration to use these new utilities, reducing code duplication and improving maintainability.
2025-07-27 18:19:35 +02:00
Dariusz L
25d07767f1 Rename canvasMask to maskEditorIntegration in Canvas
Refactors the Canvas class to rename the 'canvasMask' property to 'maskEditorIntegration' for consistency. Updates all references and import to use the new name with the .js extension.
2025-07-27 18:00:55 +02:00
Dariusz L
35f8a85c8b Delete CanvasMask.js 2025-07-27 17:39:40 +02:00
Dariusz L
4019a8a88f Rename CanvasMask to MaskEditorIntegration
Renamed the CanvasMask class and file to MaskEditorIntegration for improved clarity and consistency. Updated all references in Canvas and SAMDetectorIntegration to use the new name.
2025-07-27 17:39:13 +02:00
Dariusz L
0d6bfb01d6 Optimize mask handling and shape mask UX for output area
Replaces full-canvas mask operations with getMaskForOutputArea() for significant performance improvements when processing masks for the output area. Refines shape mask removal and application logic to ensure correct mask state when changing expansion values or custom shapes, including auto-removal and re-application of masks. Adds throttling to shape preview rendering for better UI responsiveness. Improves mask removal to eliminate antialiasing artifacts and updates SAM mask integration to use correct output area positioning.
2025-07-27 17:23:08 +02:00
Dariusz L
6491d80225 Refactor MaskTool with utility methods and deduplication
Introduces utility methods to eliminate code duplication in chunk operations, mask creation, and shape processing. Adds universal chunk processing, chunk operation, and canvas helper methods. Refactors shape mask application and removal to use unified logic, and consolidates morphological and feathering operations for masks. Improves maintainability and readability by centralizing repeated logic.
2025-07-27 14:26:26 +02:00
Dariusz L
6121403460 Refactor MaskTool chunk operations and shape offset handling
Introduces utility methods for chunk bounds calculation, intersection, and activation for better code reuse and clarity. Refactors shape mask application and removal to consistently account for output area extensions, and centralizes chunk empty status updates. Improves chunk activation logic for mask and shape operations to enhance visibility and maintainability.
2025-07-27 13:35:30 +02:00
Dariusz L
03c841380e Optimize mask chunk activation and canvas updates
Introduces active chunk management for mask drawing, activating only nearby chunks during drawing for performance. Updates the active mask canvas to show all chunks but optimizes updates to redraw only active chunks during drawing, reducing lag. Adds LRU-style tracking and safety limits for active chunks, and improves chunk activation logic for both drawing and mask application.
2025-07-27 01:11:31 +02:00
Dariusz L
46e92f30e8 Refactor CanvasInteractions for code reuse and clarity
Introduces helper methods to reduce code duplication and improve readability in CanvasInteractions. Mouse coordinate extraction, event prevention, zoom operations, drag-and-drop styling, and layer wheel transformations are now handled by dedicated methods. This refactor centralizes logic, making the codebase easier to maintain and extend.
2025-07-27 00:10:56 +02:00
Dariusz L
796a65d251 Remove unused and redundant methods from canvas modules
Cleaned up the codebase by removing unused or redundant methods from Canvas, CanvasIO, CanvasLayers, CanvasLayersPanel, CanvasRenderer, and MaskTool. This reduces code complexity and improves maintainability without affecting core functionality.
2025-07-26 23:39:29 +02:00
Dariusz L
f28783348e Fix custom shape output area extension and mask logic
Refactors how custom output area shapes interact with extensions, ensuring the shape's position and mask application remain consistent when extensions are toggled. Moves output area shape logic to CanvasInteractions, tracks original shape position, and updates all rendering, IO, and mask operations to use the correct coordinates. Improves mask chunk clearing and adds chunked mask application/removal for shape masks, ensuring correct behavior with expansion and feathering.
2025-07-26 22:39:03 +02:00
Dariusz L
f329a6ded5 Refactor output area bounds handling for custom shapes
Output area bounds are now positioned relative to the world, not always at (0,0), and are updated to match custom shape placement. Rendering and extension logic have been updated to respect the new bounds, and the mask tool now adjusts to the output area position. Also sets log level to DEBUG for development.
2025-07-26 21:20:18 +02:00
Dariusz L
ca9e1890c4 Refactor mask system to use chunked canvas storage
Replaces the single large mask canvas with a chunked system, where mask data is stored in 512x512 pixel chunks. Updates all mask drawing, compositing, and manipulation logic to operate on these chunks, improving performance and scalability for large or sparse masks. The active mask canvas is now a composite of all non-empty chunks, and all mask operations (drawing, setting, clearing) are adapted to the new chunked architecture.
2025-07-26 19:19:23 +02:00
Dariusz L
14c5f291a6 Refactor output area and mask handling for flexible canvas bounds
This update introduces a unified output area bounds system, allowing the output area to be extended in all directions independently of the custom shape. All mask and layer operations now reference outputAreaBounds, ensuring correct alignment and rendering. The mask tool, mask editor, and export logic have been refactored to use these bounds, and a new UI for output area extension with live preview and tooltips has been added. The code also improves logging and visualization of mask and output area boundaries.
2025-07-26 18:27:14 +02:00
Dariusz L
1fc06f65a2 Refine shape mask UI and ensure hard-edged mask removal
Consolidates shape mask controls into a styled container, improves UI logic for showing/hiding sub-options, and updates slider initialization to reflect current values. Mask removal now always uses a hard-edged shape, even if feathering was previously applied, ensuring complete erasure of feathered areas. The mask application logic also clears the maximum possible mask area before applying the new mask to prevent artifacts from previous slider values. Checkbox and slider labels are updated for clarity.
2025-07-26 01:50:44 +02:00
Dariusz L
ccfa2b6cfb Add shape mask preview system for expansion and feather sliders
Implements a real-time blue outline preview when adjusting the expansion and feather sliders in the custom shape mask UI. The preview updates dynamically while dragging, and applies the mask only on mouse release. Adds a viewport change listener to keep the preview in sync during zooming or panning. Refactors mask expansion/contraction to use fast morphological operations for sharp edges and updates mask drawing to handle holes correctly.
2025-07-26 00:16:11 +02:00
Dariusz L
4c4856f9e7 Add shape mask preview system for expansion and feather sliders
Implements a real-time blue outline preview for shape mask expansion and feather adjustments in CustomShapeMenu, providing immediate visual feedback while dragging sliders. Adds a dedicated shape preview canvas and efficient morphological operations in MaskTool for sharp, fast previews. Also synchronizes the preview with viewport changes and refines mask expansion/contraction logic for improved accuracy and performance.
2025-07-26 00:15:44 +02:00
Dariusz L
24ef702f16 Add custom shape mask menu with expansion and feathering
Introduces a CustomShapeMenu UI component for managing custom output area shape masks, including options for auto-applying the mask, expansion/contraction, and feathering. Updates Canvas and MaskTool to support these new mask operations, and ensures the menu is shown or hidden based on shape presence. Adds distance transform-based algorithms for accurate mask expansion and feathering.
2025-07-25 18:40:21 +02:00
Dariusz L
764e802311 Add blend area effect for layers with distance field mask
Introduces a 'blendArea' property to layers and UI controls for adjusting it. Implements distance field mask generation in ImageAnalysis.ts and applies the mask during layer rendering for smooth edge blending. Refactors CanvasRenderer to delegate layer drawing to CanvasLayers for proper blend area support.
2025-07-24 23:34:27 +02:00