diff --git a/images/layout.png b/images/layout.png new file mode 100644 index 0000000..3fb3b2c Binary files /dev/null and b/images/layout.png differ diff --git a/js/_move.js b/js/_move.js index 76c15c0..719b2ea 100644 --- a/js/_move.js +++ b/js/_move.js @@ -1,5 +1,6 @@ var imageDataToMove; var canMoveSelection = false; +var lastMovePos; // TODO: move with arrows function updateMovePreview(mouseEvent) { @@ -12,6 +13,7 @@ function updateMovePreview(mouseEvent) { Math.round(lastMousePos[0] / zoom - imageDataToMove.width / 2), Math.round(lastMousePos[1] / zoom - imageDataToMove.height / 2)); + lastMovePos = lastMousePos; moveSelection(lastMousePos[0] / zoom, lastMousePos[1] / zoom, imageDataToMove.width, imageDataToMove.height) } @@ -21,6 +23,6 @@ function endSelection() { currentLayer.context.putImageData( imageDataToMove, - Math.round(lastMousePos[0] / zoom - imageDataToMove.width / 2), - Math.round(lastMousePos[1] / zoom - imageDataToMove.height / 2)); + Math.round(lastMovePos[0] / zoom - imageDataToMove.width / 2), + Math.round(lastMovePos[1] / zoom - imageDataToMove.height / 2)); } \ No newline at end of file diff --git a/js/_rectSelect.js b/js/_rectSelect.js index a1a2e84..26653ea 100644 --- a/js/_rectSelect.js +++ b/js/_rectSelect.js @@ -73,11 +73,6 @@ function endRectSelection(mouseEvent) { // Updating the cursor updateCursor(); - // NOW - // the move tool stops working when esc is pressed - // when the move tool is disabled, the control is given to the brush tool - // the image data is added to the original layer when the move tool is disabled - //currentLayer.context.putImageData(imageData, startX, startY); } @@ -89,7 +84,7 @@ function drawRect(x, y) { // Clearing the vfx canvas vfxContext.clearRect(0, 0, VFXCanvas.width, VFXCanvas.height); vfxContext.lineWidth = 1; - vfxContext.fillStyle = "black"; + vfxContext.strokeStyle = "black"; vfxContext.setLineDash([4]); // Drawing the rect diff --git a/js/_rectangle.js b/js/_rectangle.js index e7458fc..3976ddd 100644 --- a/js/_rectangle.js +++ b/js/_rectangle.js @@ -1,5 +1,7 @@ var rectangleSize = 1; var prevRectangleSie = rectangleSize; +var emptySVG = document.getElementById("empty-button-svg"); +var fullSVG = document.getElementById("full-button-svg"); var drawMode = 'empty'; var isDrawingRect = false; @@ -70,19 +72,10 @@ function endRectDrawing(mouseEvent) { line(endRectX, endRectY, startRectX, endRectY, rectangleSize); line(startRectX, endRectY, startRectX, startRectY, rectangleSize); -/* - // Drawing the final rectangle - currentLayer.context.lineWidth = rectangleSize; - currentLayer.context.strokeStyle = currentGlobalColor; + if (drawMode == 'fill') { + currentLayer.context.fillRect(startRectX, startRectY, endRectX - startRectX, endRectY - startRectY); + } - // Drawing the rect - currentLayer.context.beginPath(); - console.log("Coords: " + startRectX + ", " + startRectY); - currentLayer.context.imageSmoothingEnabled = false; - currentLayer.context.rect(startRectX, startRectY, endRectX - startRectX, endRectY - startRectY); - currentLayer.context.setLineDash([]); - currentLayer.context.stroke(); -*/ // Clearing the vfx canvas vfxContext.clearRect(0, 0, VFXCanvas.width, VFXCanvas.height); } @@ -106,6 +99,17 @@ function drawRectangle(x, y) { vfxContext.stroke(); } +function setRectToolSvg() { + if (drawMode == 'empty') { + emptySVG.setAttribute("display", "visible"); + fullSVG.setAttribute("display", "none"); + } + else { + emptySVG.setAttribute("display", "none"); + fullSVG.setAttribute("display", "visible"); + } +} + function applyChanges() { VFXCanvas.style.zIndex = MIN_Z_INDEX; } \ No newline at end of file diff --git a/js/_toolButtons.js b/js/_toolButtons.js index 21b1776..6c846d1 100644 --- a/js/_toolButtons.js +++ b/js/_toolButtons.js @@ -37,10 +37,12 @@ on('click',"rectangle-button", function(){ // If the user clicks twice on the button, they change the draw mode if (currentTool == 'rectangle') { if (drawMode == 'empty') { - drawMode = 'full'; + drawMode = 'fill'; + setRectToolSvg(); } else { drawMode = 'empty'; + setRectToolSvg(); } } else { diff --git a/views/pixel-editor.hbs b/views/pixel-editor.hbs index 318b203..57750db 100644 --- a/views/pixel-editor.hbs +++ b/views/pixel-editor.hbs @@ -16,7 +16,6 @@ {{{google-analytics}}} {{{favicons}}} - @@ -87,7 +86,8 @@
  • - +