Commit 2c63ab01 authored by Alexandre's avatar Alexandre
Browse files

we can reset the canvas and erase

parent 5a6b7e46
......@@ -21,7 +21,8 @@ ui-sref="project.workshops.overview">{{::_labels.disconnectWorkshopBtn}}
<button>Circle</button>
<button>Square</button>
<button>Add Post-It</button>
<button>Erase</button>
<button ng-click="paperBoardCtrl.eraseMode()">Erase</button>
<button ng-click="paperBoardCtrl.reset()">Reset</button>
<label for="lineWidth"> Line Width :
<input type="range" name="lineWidth" id="lineWidth" min="1" max="15" value="3" step="1">
</label>
......
......@@ -19,7 +19,7 @@ root.controller('PaperBoardCtrl', ['$scope', '$stateParams', '$http', '$state',
let isDrawing = false;
let style = "#000";
let pen = false;
let erase = false;
paperBoardCtrl.getPaperBoardDetails = function (paperBoardDetails) {
......@@ -59,6 +59,7 @@ root.controller('PaperBoardCtrl', ['$scope', '$stateParams', '$http', '$state',
paperBoardCtrl.penMode = function ()
{
pen = true;
erase = false;
}
$scope.leaveBoard = function(){
......@@ -66,6 +67,16 @@ root.controller('PaperBoardCtrl', ['$scope', '$stateParams', '$http', '$state',
alert("Vous venez de quitter l'atelier");
}
paperBoardCtrl.reset = function(){
ctx.clearRect(0,0,canvas.width,canvas.height);
}
paperBoardCtrl.eraseMode = function(){
erase = true;
pen = false;
}
paperBoardCtrl.getPaperBoardDetails();
document.querySelector('#lineWidth').addEventListener('change', e =>
......@@ -83,7 +94,7 @@ root.controller('PaperBoardCtrl', ['$scope', '$stateParams', '$http', '$state',
console.log("X: " + mouseX + " : Y: " + mouseY);
isDrawing = true;
});
canvas.addEventListener('mousemove', e=>
{
if(isDrawing)
......@@ -96,10 +107,16 @@ root.controller('PaperBoardCtrl', ['$scope', '$stateParams', '$http', '$state',
mouseY = e.clientY - rect.top;
}
if(erase)
{
paperBoardCtrl.lineDraw(ctx,mouseX,mouseY,e.clientX - rect.left, e.clientY - rect.top, "white", lineWidth);
mouseX = e.clientX - rect.left;
mouseY = e.clientY - rect.top;
}
}
});
canvas.addEventListener('mouseup', e =>
canvas.addEventListener('mouseup', e =>
{
isDrawing = false;
});
......@@ -128,4 +145,3 @@ root.controller('PaperBoardCtrl', ['$scope', '$stateParams', '$http', '$state',
}
}]);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment