diff --git a/2D/js/main.js b/2D/js/main.js index eabd4ff..f068d8a 100644 --- a/2D/js/main.js +++ b/2D/js/main.js @@ -101,7 +101,7 @@ class MainApp { this.gridBoard.grid[row][col] = '#000000'; } this.redraw(); - } + } else { this.isBlackening = false; this.canvas.style.cursor = 'default'; } } else { let clickedOnIcon = false; if (this.selectedPolyomino) { @@ -123,9 +123,7 @@ class MainApp { break; } } - if (!selected) { - this.selectedPolyomino = null; - } + if (!selected) { this.selectedPolyomino = null; } } this.redraw(); } @@ -141,9 +139,6 @@ class MainApp { this.redraw(); }; - enableBlackening() { this.isBlackening = true; document.body.style.cursor = 'url("../assets/cursor_blackend.png"), auto'; }; - disableBlackening() { this.isBlackening = false; document.body.style.cursor = 'default'; }; - redraw() { if (!this.needsRedraw) return; this.gridBoard.clear(); diff --git a/2D/js/polyomino.js b/2D/js/polyomino.js index 54b17a1..10b8e6e 100644 --- a/2D/js/polyomino.js +++ b/2D/js/polyomino.js @@ -92,21 +92,11 @@ export class Polyomino { handleIconClick(type) { switch (type) { - case 'flip': - this.flip(); - break; - case 'rotateLeft': - this.rotateLeft(); - break; - case 'rotateRight': - this.rotateRight(); - break; - case 'duplicate': - this.app.duplicatePolyomino(this); - break; - case 'trash': - this.app.deletePolyomino(this); - break; + case 'flip': this.flip(); break; + case 'rotateLeft': this.rotateLeft(); break; + case 'rotateRight': this.rotateRight(); break; + case 'duplicate': this.app.duplicatePolyomino(this); break; + case 'trash': this.app.deletePolyomino(this); break; } this.app.redraw(); }; diff --git a/2D/js/popup/grid.js b/2D/js/popup/grid.js index cae135b..159f7ca 100644 --- a/2D/js/popup/grid.js +++ b/2D/js/popup/grid.js @@ -84,11 +84,8 @@ export function showGridPopup(toolbar) { toolbar.closePopup('grid'); break; case 5: - if (toolbar.mainApp.isBlackening) { - toolbar.mainApp.disableBlackening(); - } else { - toolbar.mainApp.enableBlackening(); - } + toolbar.mainApp.isBlackening = true; + toolbar.mainApp.canvas.style.cursor = 'url("../../assets/cursor_blackend.png"), auto'; toolbar.closePopup('grid'); break; } diff --git a/2D/js/popup/polyomino.js b/2D/js/popup/polyomino.js index 983d864..0c47877 100644 --- a/2D/js/popup/polyomino.js +++ b/2D/js/popup/polyomino.js @@ -63,8 +63,8 @@ export function showPolyominoPopup(toolbar) { const getRandomPosition = (max) => Math.floor(Math.random() * max); - const canvasPaddingX = getRandomPosition(window.innerWidth < 600 ? 300 : 1200) + (window.innerWidth < 600 ? 40 : 0); - const canvasPaddingY = getRandomPosition(170) + (window.innerHeight < 600 ? 0 : 40); + const canvasPaddingX = getRandomPosition(window.innerWidth < 600 ? 300 : 1200) + (window.innerWidth < 600 ? 0 : 40); + const canvasPaddingY = getRandomPosition(170) + (window.innerHeight < 600 ? 40 : 0); polyominoes.forEach(({ polyomino, shape, shapeSize, y }) => { const leftColumnRect = { x: 10, y: y - shapeSize / 2, width: 180, height: shapeSize + 20 };