Delegate layer resize and rotate to CanvasLayers

Moved the resizeLayer and rotateLayer logic from Canvas.js to CanvasLayers.js, improving modularity and consistency. Updated REFACTORING_GUIDE.md to reflect these changes and document the current architecture and status.
This commit is contained in:
Dariusz L
2025-06-29 13:47:08 +02:00
parent b4a662b036
commit 22627b7532
3 changed files with 62 additions and 18 deletions

View File

@@ -198,6 +198,35 @@ export class CanvasLayers {
this.canvasLayers.saveState();
}
/**
* Zmienia rozmiar wybranych warstw
* @param {number} scale - Skala zmiany rozmiaru
*/
resizeLayer(scale) {
if (this.canvasLayers.selectedLayers.length === 0) return;
this.canvasLayers.selectedLayers.forEach(layer => {
layer.width *= scale;
layer.height *= scale;
});
this.canvasLayers.render();
this.canvasLayers.saveState();
}
/**
* Obraca wybrane warstwy
* @param {number} angle - Kąt obrotu w stopniach
*/
rotateLayer(angle) {
if (this.canvasLayers.selectedLayers.length === 0) return;
this.canvasLayers.selectedLayers.forEach(layer => {
layer.rotation += angle;
});
this.canvasLayers.render();
this.canvasLayers.saveState();
}
getLayerAtPosition(worldX, worldY) {
for (let i = this.canvasLayers.layers.length - 1; i >= 0; i--) {
const layer = this.canvasLayers.layers[i];