Commit fadcb82e authored by bbaer's avatar bbaer
Browse files

set Brush colors, rectangles with border

parent 3e5b09f4
......@@ -12,6 +12,8 @@ $(function () {
var bgOpacity = 1;
var fgColor = '#000';
var borderColor = '#000';
var borderSize = 5;
var brushWidth = 2;
var textSize = 16;
var addPositionLeft = 20;
var addPositionTop = 20;
......@@ -66,8 +68,11 @@ $(function () {
isDown = false;
var rect = canvas.getActiveObject();
rect.hasControls = true;
canvas.setActiveObject(rect);
canvas.selection = true;
canvas.discardActiveObject();
canvas.renderAll();
var group = new canvas.Group([rect]);
canvas.add(group);
}
function adjustDefaultPosition() {
......@@ -106,11 +111,15 @@ $(function () {
height: pointer.y-origY,
angle: 0,
fill: 'rgba(255,0,0,0.5)',
strokeWidth: borderSize,
stroke: 'rgba(255, 0, 0, 1)',
selectable: true,
hasControls: false
});
canvas.add(rect);
canvas.discardActiveObject;
canvas.setActiveObject(rect);
canvas.selection = false;
}
function resizeRectangle(o) {
......@@ -151,10 +160,17 @@ $(function () {
top: addPositionTop
});
canvas.add(group);
canvas.setActiveGroup(group);
adjustDefaultPosition();
}
function setBrush(color, brushSize) {
canvas.freeDrawingBrush.color = color;
if (!brushSize) {
brushSize = 2;
}
canvas.freeDrawingBrush.width = brushSize;
}
// Custom Mouse / Touch Events on Canvas
canvas.on('mouse:up', function (e) {
......@@ -298,6 +314,22 @@ $(function () {
bgColor = '#fff'
});
$("#draw-black").on("click", function() {
setBrush('rgba(0, 0, 0, 0.8)');
});
$("#draw-red").on("click", function() {
setBrush('rgba(255, 0, 0, 0.8)');
});
$("#draw-blue").on("click", function() {
setBrush('rgba(0, 0, 255, 0.8)');
});
$("#highlight-yellow").on("click", function() {
setBrush('rgba(255, 204, 0, 0.4)', 12);
});
$("#text-yellow-border").on("click", function() {
borderColor = '#2b2200';
bgOpacity = 1;
......
Supports Markdown
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