Commit c7910428 authored by Nezael's avatar Nezael
Browse files

Merge branch '195-ajouts-de-fonctionnalites' into paperboard

parents 995a05a6 71bea1e7
......@@ -16,10 +16,10 @@ ui-sref="project.workshops.overview">{{::_labels.disconnectWorkshopBtn}}
<button ng-click="paperBoardCtrl.blackPaint()">Black</button>
<button ng-click="paperBoardCtrl.bluePaint()">Blue</button>
<button ng-click="paperBoardCtrl.redPaint()">Red</button>
<button>Cursor</button>
<button ng-click="paperBoardCtrl.cursorMode()">Cursor</button>
<button ng-click="paperBoardCtrl.penMode()">Pen</button>
<button>Circle</button>
<button>Square</button>
<button ng-click="paperBoardCtrl.circleMode()">Circle</button>
<button ng-click="paperBoardCtrl.squareMode()">Square</button>
<button>Add Post-It</button>
<button>Erase</button>
<label for="lineWidth"> Line Width :
......
......@@ -19,6 +19,10 @@ root.controller('PaperBoardCtrl', ['$scope', '$stateParams', '$http', '$state',
let isDrawing = false;
let style = "#000";
let pen = false;
var circle = false;
var cursor = false;
var square = false;
......@@ -56,9 +60,72 @@ root.controller('PaperBoardCtrl', ['$scope', '$stateParams', '$http', '$state',
ctx.closePath();
}
paperBoardCtrl.drawSquare = function(ctx, x1, y1, x2, y2, styleColor, lineWidth)
{
ctx.beginPath();
ctx.strokeStyle = styleColor;
ctx.lineWidth = lineWidth;
ctx.rect(x1, y1, x2 - x1, y2 - y1);
ctx.stroke();
ctx.closePath();
}
paperBoardCtrl.drawCircle = function(ctx, x1, y1, x2, y2, styleColor, lineWidth)
{
ctx.beginPath();
ctx.strokeStyle = styleColor;
ctx.lineWidth = lineWidth;
if(x2 > x1 && y2 > y1)
{
ctx.arc(x1, y1, ((x2 - x1) + (y2 - y1)) / 2, 0, 2 * Math.PI);
}
else if (x2 > x1 && y2 < y1)
{
ctx.arc(x1, y1, ((x2 - x1) + (y1 - y2)) / 2, 0, 2 * Math.PI);
}
else if (x2 < x1 && y2 > y1)
{
ctx.arc(x1, y1, ((x1 - x2) + (y2 - y1)) / 2, 0, 2 * Math.PI);
}
else
{
ctx.arc(x1, y1, ((x1 - x2) + (y1 - y2)) / 2, 0, 2 * Math.PI);
}
ctx.stroke();
ctx.closePath();
}
paperBoardCtrl.penMode = function ()
{
pen = true;
pen = true;
circle = false;
square = false;
cursor = false;
}
paperBoardCtrl.circleMode = function ()
{
pen = false;
circle = true;
square = false;
cursor = false;
}
paperBoardCtrl.squareMode = function ()
{
pen = false;
circle = false;
square = true;
cursor = false;
}
paperBoardCtrl.cursorMode = function ()
{
pen = false;
circle = false;
square = false;
cursor = true;
}
$scope.leaveBoard = function(){
......@@ -83,7 +150,7 @@ root.controller('PaperBoardCtrl', ['$scope', '$stateParams', '$http', '$state',
console.log("X: " + mouseX + " : Y: " + mouseY);
isDrawing = true;
});
canvas.addEventListener('mousemove', e=>
{
if(isDrawing)
......@@ -96,12 +163,22 @@ root.controller('PaperBoardCtrl', ['$scope', '$stateParams', '$http', '$state',
mouseY = e.clientY - rect.top;
}
}
});
canvas.addEventListener('mouseup', e =>
canvas.addEventListener('mouseup', e =>
{
isDrawing = false;
if(circle && isDrawing)
{
paperBoardCtrl.drawCircle(ctx, mouseX, mouseY, e.clientX - rect.left, e.clientY - rect.top, style, lineWidth);
}
if(square && isDrawing)
{
paperBoardCtrl.drawSquare(ctx, mouseX, mouseY, e.clientX - rect.left, e.clientY - rect.top, style, lineWidth);
}
isDrawing = false;
});
document.querySelector('#personnalized-color').addEventListener('change', e =>
......@@ -128,4 +205,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