mirror of
https://github.com/Azornes/Comfyui-LayerForge.git
synced 2026-03-21 20:52:12 -03:00
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.
This commit is contained in:
@@ -778,29 +778,6 @@ export class MaskTool {
|
||||
this.updateActiveMaskCanvas();
|
||||
return this.activeMaskCanvas;
|
||||
}
|
||||
getMaskImageWithAlpha() {
|
||||
const tempCanvas = document.createElement('canvas');
|
||||
tempCanvas.width = this.maskCanvas.width;
|
||||
tempCanvas.height = this.maskCanvas.height;
|
||||
const tempCtx = tempCanvas.getContext('2d', { willReadFrequently: true });
|
||||
if (!tempCtx) {
|
||||
throw new Error("Failed to get 2D context for temporary canvas");
|
||||
}
|
||||
tempCtx.drawImage(this.maskCanvas, 0, 0);
|
||||
const imageData = tempCtx.getImageData(0, 0, tempCanvas.width, tempCanvas.height);
|
||||
const data = imageData.data;
|
||||
for (let i = 0; i < data.length; i += 4) {
|
||||
const alpha = data[i];
|
||||
data[i] = 255;
|
||||
data[i + 1] = 255;
|
||||
data[i + 2] = 255;
|
||||
data[i + 3] = alpha;
|
||||
}
|
||||
tempCtx.putImageData(imageData, 0, 0);
|
||||
const maskImage = new Image();
|
||||
maskImage.src = tempCanvas.toDataURL();
|
||||
return maskImage;
|
||||
}
|
||||
resize(width, height) {
|
||||
this.initPreviewCanvas();
|
||||
const oldMask = this.maskCanvas;
|
||||
@@ -830,11 +807,6 @@ export class MaskTool {
|
||||
log.info(`Mask canvas resized to ${this.activeMaskCanvas.width}x${this.activeMaskCanvas.height}, position (${this.x}, ${this.y})`);
|
||||
log.info(`Canvas size change: width ${isIncreasingWidth ? 'increased' : 'decreased'}, height ${isIncreasingHeight ? 'increased' : 'decreased'}`);
|
||||
}
|
||||
updatePosition(dx, dy) {
|
||||
this.x += dx;
|
||||
this.y += dy;
|
||||
log.info(`Mask position updated to (${this.x}, ${this.y})`);
|
||||
}
|
||||
/**
|
||||
* Updates mask canvas to ensure it covers the current output area
|
||||
* This should be called when output area position or size changes
|
||||
@@ -1405,21 +1377,6 @@ export class MaskTool {
|
||||
}
|
||||
return distances;
|
||||
}
|
||||
/**
|
||||
* Creates an expanded mask using distance transform - much better for complex shapes
|
||||
* than the centroid-based approach. This version only does expansion without transparency calculations.
|
||||
*/
|
||||
_calculateExpandedPoints(points, expansionValue) {
|
||||
if (points.length < 3 || expansionValue === 0)
|
||||
return points;
|
||||
// For expansion, we need to create a temporary canvas to use the distance transform approach
|
||||
// This will give us much better results for complex shapes than the centroid method
|
||||
const tempCanvas = this._createExpandedMaskCanvas(points, expansionValue, this.maskCanvas.width, this.maskCanvas.height);
|
||||
// Extract the expanded shape outline from the canvas
|
||||
// For now, return the original points as a fallback - the real expansion happens in the canvas
|
||||
// The calling code will use the canvas directly instead of these points
|
||||
return points;
|
||||
}
|
||||
/**
|
||||
* Creates an expanded/contracted mask canvas using simple morphological operations
|
||||
* This gives SHARP edges without smoothing, unlike distance transform
|
||||
|
||||
Reference in New Issue
Block a user