@yorab/react-paint 0.3.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,13 +29,13 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
29
29
 
30
30
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
31
31
 
32
- var applyShapeTransformations = function applyShapeTransformations(ctx, marker, responsiveScale, canvasOffset) {
32
+ var applyShapeTransformations = function applyShapeTransformations(ctx, marker, responsiveScale, canvasOffset, selectionPadding) {
33
33
  ctx.save();
34
34
  ctx.scale(responsiveScale, responsiveScale);
35
35
  ctx.translate(marker.translation[0] + canvasOffset[0], marker.translation[1] + canvasOffset[1]);
36
36
 
37
37
  if (marker.rotation !== 0) {
38
- var _getShapeInfos = (0, _shapeData.getShapeInfos)(marker),
38
+ var _getShapeInfos = (0, _shapeData.getShapeInfos)(marker, selectionPadding),
39
39
  center = _getShapeInfos.center;
40
40
 
41
41
  ctx.translate(center[0], center[1]);
@@ -55,9 +55,9 @@ var updateDrawStyle = function updateDrawStyle(ctx) {
55
55
  _style$globalAlpha = style.globalAlpha,
56
56
  globalAlpha = _style$globalAlpha === void 0 ? 100 : _style$globalAlpha,
57
57
  _style$strokeColor = style.strokeColor,
58
- strokeColor = _style$strokeColor === void 0 ? 'blue' : _style$strokeColor,
58
+ strokeColor = _style$strokeColor === void 0 ? _shapes.SELECTION_DEFAULT_COLOR : _style$strokeColor,
59
59
  _style$lineWidth = style.lineWidth,
60
- lineWidth = _style$lineWidth === void 0 ? 1 : _style$lineWidth,
60
+ lineWidth = _style$lineWidth === void 0 ? _shapes.SELECTION_DEFAULT_WIDTH : _style$lineWidth,
61
61
  _style$lineDash = style.lineDash,
62
62
  lineDash = _style$lineDash === void 0 ? 0 : _style$lineDash;
63
63
  ctx.lineCap = 'round';
@@ -249,9 +249,9 @@ var drawPicture = function drawPicture(ctx, picture) {
249
249
 
250
250
  exports.drawPicture = drawPicture;
251
251
 
252
- var drawShape = function drawShape(ctx, shape, responsiveScale, canvasOffset) {
252
+ var drawShape = function drawShape(ctx, shape, responsiveScale, canvasOffset, selectionPadding) {
253
253
  if (shape.visible === false) return;
254
- applyShapeTransformations(ctx, shape, responsiveScale, canvasOffset);
254
+ applyShapeTransformations(ctx, shape, responsiveScale, canvasOffset, selectionPadding);
255
255
 
256
256
  switch (shape.type) {
257
257
  case 'brush':
@@ -301,17 +301,30 @@ var drawSelectionDefault = function drawSelectionDefault(_ref) {
301
301
  var ctx = _ref.ctx,
302
302
  shape = _ref.shape,
303
303
  withAnchors = _ref.withAnchors,
304
+ selectionPadding = _ref.selectionPadding,
305
+ selectionWidth = _ref.selectionWidth,
306
+ selectionColor = _ref.selectionColor,
304
307
  _ref$currentScale = _ref.currentScale,
305
308
  currentScale = _ref$currentScale === void 0 ? 1 : _ref$currentScale;
306
- var scaleWithMinCap = Math.min(1, currentScale);
307
309
 
308
- var _getShapeInfos2 = (0, _shapeData.getShapeInfos)(shape),
310
+ var _getShapeInfos2 = (0, _shapeData.getShapeInfos)(shape, selectionPadding / currentScale),
309
311
  borders = _getShapeInfos2.borders;
310
312
 
311
- drawRect(ctx, borders);
313
+ drawRect(ctx, _objectSpread(_objectSpread({}, borders), {}, {
314
+ style: {
315
+ fillColor: 'transparent',
316
+ strokeColor: selectionColor,
317
+ lineWidth: selectionWidth / currentScale
318
+ }
319
+ }));
312
320
  if (!withAnchors || shape.locked) return;
313
321
  drawLine(ctx, {
314
- points: [[borders.x + borders.width / 2, borders.y], [borders.x + borders.width / 2, borders.y - _shapes.SELECTION_ANCHOR_SIZE / 2 - _shapes.SELECTION_ROTATED_ANCHOR_POSITION / scaleWithMinCap]]
322
+ points: [[borders.x + borders.width / 2, borders.y], [borders.x + borders.width / 2, borders.y - _shapes.SELECTION_ANCHOR_SIZE / 2 - _shapes.SELECTION_ROTATED_ANCHOR_POSITION / currentScale]],
323
+ style: {
324
+ fillColor: 'transparent',
325
+ strokeColor: selectionColor,
326
+ lineWidth: selectionWidth / currentScale
327
+ }
315
328
  });
316
329
 
317
330
  var _iterator = _createForOfIteratorHelper(_shapes.SELECTION_RESIZE_ANCHOR_POSITIONS),
@@ -323,11 +336,11 @@ var drawSelectionDefault = function drawSelectionDefault(_ref) {
323
336
  drawCircle(ctx, {
324
337
  x: borders.x + borders.width * anchorPosition[0],
325
338
  y: borders.y + borders.height * anchorPosition[1],
326
- radius: _shapes.SELECTION_ANCHOR_SIZE / 2 / scaleWithMinCap,
339
+ radius: _shapes.SELECTION_ANCHOR_SIZE / 2 / currentScale,
327
340
  style: {
328
341
  fillColor: 'rgb(255,255,255)',
329
342
  strokeColor: 'rgb(150,150,150)',
330
- lineWidth: 2 / scaleWithMinCap
343
+ lineWidth: selectionWidth / currentScale
331
344
  }
332
345
  });
333
346
  }
@@ -339,12 +352,12 @@ var drawSelectionDefault = function drawSelectionDefault(_ref) {
339
352
 
340
353
  drawCircle(ctx, {
341
354
  x: borders.x + borders.width / 2,
342
- y: borders.y - _shapes.SELECTION_ANCHOR_SIZE / 2 - _shapes.SELECTION_ROTATED_ANCHOR_POSITION / scaleWithMinCap,
343
- radius: _shapes.SELECTION_ANCHOR_SIZE / 2 / scaleWithMinCap,
355
+ y: borders.y - _shapes.SELECTION_ANCHOR_SIZE / 2 - _shapes.SELECTION_ROTATED_ANCHOR_POSITION / currentScale,
356
+ radius: _shapes.SELECTION_ANCHOR_SIZE / 2 / currentScale,
344
357
  style: {
345
358
  fillColor: 'rgb(255,255,255)',
346
359
  strokeColor: 'rgb(150,150,150)',
347
- lineWidth: 2 / scaleWithMinCap
360
+ lineWidth: selectionWidth / currentScale
348
361
  }
349
362
  });
350
363
  };
@@ -353,14 +366,22 @@ var drawLineSelection = function drawLineSelection(_ref2) {
353
366
  var ctx = _ref2.ctx,
354
367
  shape = _ref2.shape,
355
368
  withAnchors = _ref2.withAnchors,
369
+ selectionPadding = _ref2.selectionPadding,
370
+ selectionWidth = _ref2.selectionWidth,
371
+ selectionColor = _ref2.selectionColor,
356
372
  _ref2$currentScale = _ref2.currentScale,
357
373
  currentScale = _ref2$currentScale === void 0 ? 1 : _ref2$currentScale;
358
- var scaleWithMinCap = Math.min(1, currentScale);
359
374
 
360
- var _getShapeInfos3 = (0, _shapeData.getShapeInfos)(shape),
375
+ var _getShapeInfos3 = (0, _shapeData.getShapeInfos)(shape, selectionPadding),
361
376
  borders = _getShapeInfos3.borders;
362
377
 
363
- drawRect(ctx, borders);
378
+ drawRect(ctx, _objectSpread(_objectSpread({}, borders), {}, {
379
+ style: {
380
+ fillColor: 'transparent',
381
+ strokeColor: selectionColor,
382
+ lineWidth: selectionWidth / currentScale
383
+ }
384
+ }));
364
385
  if (!withAnchors || shape.locked) return;
365
386
 
366
387
  for (var i = 0; i < shape.points.length; i++) {
@@ -370,23 +391,23 @@ var drawLineSelection = function drawLineSelection(_ref2) {
370
391
  drawRect(ctx, {
371
392
  x: coordinate[0] - _shapes.SELECTION_ANCHOR_SIZE / 2,
372
393
  y: coordinate[1] - _shapes.SELECTION_ANCHOR_SIZE / 2,
373
- width: _shapes.SELECTION_ANCHOR_SIZE / scaleWithMinCap,
374
- height: _shapes.SELECTION_ANCHOR_SIZE / scaleWithMinCap,
394
+ width: _shapes.SELECTION_ANCHOR_SIZE / currentScale,
395
+ height: _shapes.SELECTION_ANCHOR_SIZE / currentScale,
375
396
  style: {
376
397
  fillColor: 'rgb(255,255,255)',
377
398
  strokeColor: 'rgb(150,150,150)',
378
- lineWidth: 2 / scaleWithMinCap
399
+ lineWidth: selectionWidth / currentScale
379
400
  }
380
401
  });
381
402
  } else {
382
403
  drawCircle(ctx, {
383
404
  x: coordinate[0],
384
405
  y: coordinate[1],
385
- radius: _shapes.SELECTION_ANCHOR_SIZE / 2 / scaleWithMinCap,
406
+ radius: _shapes.SELECTION_ANCHOR_SIZE / 2 / currentScale,
386
407
  style: {
387
408
  fillColor: 'rgb(255,255,255)',
388
409
  strokeColor: 'rgb(150,150,150)',
389
- lineWidth: 2 / scaleWithMinCap
410
+ lineWidth: selectionWidth / currentScale
390
411
  }
391
412
  });
392
413
  }
@@ -399,9 +420,12 @@ var drawSelection = function drawSelection(_ref3) {
399
420
  _ref3$scaleRatio = _ref3.scaleRatio,
400
421
  scaleRatio = _ref3$scaleRatio === void 0 ? 1 : _ref3$scaleRatio,
401
422
  canvasOffset = _ref3.canvasOffset,
423
+ selectionPadding = _ref3.selectionPadding,
424
+ selectionWidth = _ref3.selectionWidth,
425
+ selectionColor = _ref3.selectionColor,
402
426
  _ref3$withAnchors = _ref3.withAnchors,
403
427
  withAnchors = _ref3$withAnchors === void 0 ? true : _ref3$withAnchors;
404
- applyShapeTransformations(ctx, shape, scaleRatio, canvasOffset);
428
+ applyShapeTransformations(ctx, shape, scaleRatio, canvasOffset, selectionPadding);
405
429
 
406
430
  switch (shape.type) {
407
431
  case 'polygon':
@@ -411,6 +435,9 @@ var drawSelection = function drawSelection(_ref3) {
411
435
  ctx: ctx,
412
436
  shape: shape,
413
437
  withAnchors: withAnchors,
438
+ selectionPadding: selectionPadding,
439
+ selectionWidth: selectionWidth,
440
+ selectionColor: selectionColor,
414
441
  currentScale: scaleRatio
415
442
  });
416
443
  break;
@@ -420,6 +447,9 @@ var drawSelection = function drawSelection(_ref3) {
420
447
  ctx: ctx,
421
448
  shape: shape,
422
449
  withAnchors: withAnchors,
450
+ selectionPadding: selectionPadding,
451
+ selectionWidth: selectionWidth,
452
+ selectionColor: selectionColor,
423
453
  currentScale: scaleRatio
424
454
  });
425
455
  break;
@@ -63,7 +63,7 @@ var encodeObjectToString = function encodeObjectToString(objectToEncode) {
63
63
  return 'data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(objectToEncode));
64
64
  };
65
65
 
66
- var getCanvasImage = function getCanvasImage(shapes, canvasOffset, width, height) {
66
+ var getCanvasImage = function getCanvasImage(shapes, canvasOffset, width, height, selectionPadding) {
67
67
  var newCanvas = document.createElement('canvas');
68
68
  newCanvas.width = width;
69
69
  newCanvas.height = height;
@@ -72,7 +72,7 @@ var getCanvasImage = function getCanvasImage(shapes, canvasOffset, width, height
72
72
  ctx.clearRect(0, 0, width, height);
73
73
 
74
74
  for (var i = shapes.length - 1; i >= 0; i--) {
75
- (0, _draw.drawShape)(ctx, shapes[i], 1, canvasOffset);
75
+ (0, _draw.drawShape)(ctx, shapes[i], 1, canvasOffset, selectionPadding);
76
76
  }
77
77
 
78
78
  return newCanvas.toDataURL('image/png');
@@ -45,10 +45,10 @@ var getCursorPosition = function getCursorPosition(e, canvas, givenWidth, givenH
45
45
 
46
46
  exports.getCursorPosition = getCursorPosition;
47
47
 
48
- var getSettingsPosition = function getSettingsPosition(shape, canvas, givenWidth, givenHeight) {
48
+ var getSettingsPosition = function getSettingsPosition(shape, canvas, givenWidth, givenHeight, selectionPadding) {
49
49
  var _canvas$getBoundingCl2;
50
50
 
51
- var shapeInfos = (0, _shapeData.getShapeInfos)(shape);
51
+ var shapeInfos = (0, _shapeData.getShapeInfos)(shape, selectionPadding);
52
52
  var positionInCanvas = getPointPositionBeforeCanvasTransformation(shapeInfos.center, [-shape.translation[0], -shape.translation[1]], shape.rotation, shapeInfos.center);
53
53
  var canvasBoundingRect = (_canvas$getBoundingCl2 = canvas === null || canvas === void 0 ? void 0 : canvas.getBoundingClientRect()) !== null && _canvas$getBoundingCl2 !== void 0 ? _canvas$getBoundingCl2 : {
54
54
  left: 0,
@@ -125,12 +125,12 @@ var applyRotationToVector = function applyRotationToVector(vector, shapeRotation
125
125
 
126
126
  exports.applyRotationToVector = applyRotationToVector;
127
127
 
128
- var checkPositionIntersection = function checkPositionIntersection(shape, position, canvasOffset) {
129
- var currentScale = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
130
- var checkAnchors = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
128
+ var checkPositionIntersection = function checkPositionIntersection(shape, position, canvasOffset, selectionPadding) {
129
+ var currentScale = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
130
+ var checkAnchors = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
131
131
  var scaleWithMinCap = Math.min(1, currentScale);
132
132
 
133
- var _getShapeInfos = (0, _shapeData.getShapeInfos)(shape),
133
+ var _getShapeInfos = (0, _shapeData.getShapeInfos)(shape, selectionPadding),
134
134
  borders = _getShapeInfos.borders,
135
135
  center = _getShapeInfos.center;
136
136
 
@@ -15,7 +15,7 @@ var _intersect = require("./intersect");
15
15
 
16
16
  var _shapeData = require("./shapeData");
17
17
 
18
- var getNewSelectionData = function getNewSelectionData(hoverMode, selectedShape, cursorPosition) {
18
+ var getNewSelectionData = function getNewSelectionData(hoverMode, selectedShape, cursorPosition, selectionPadding) {
19
19
  if (hoverMode.mode === 'translate') {
20
20
  return {
21
21
  mode: _Mode.SelectionModeLib.translate,
@@ -23,7 +23,7 @@ var getNewSelectionData = function getNewSelectionData(hoverMode, selectedShape,
23
23
  originalShape: selectedShape
24
24
  };
25
25
  } else if (hoverMode.mode === 'rotate') {
26
- var _getShapeInfos = (0, _shapeData.getShapeInfos)(selectedShape),
26
+ var _getShapeInfos = (0, _shapeData.getShapeInfos)(selectedShape, selectionPadding),
27
27
  centerBeforeResize = _getShapeInfos.center;
28
28
 
29
29
  var center = [centerBeforeResize[0], centerBeforeResize[1]];
@@ -47,12 +47,12 @@ var getNewSelectionData = function getNewSelectionData(hoverMode, selectedShape,
47
47
 
48
48
  exports.getNewSelectionData = getNewSelectionData;
49
49
 
50
- var selectShape = function selectShape(shapes, cursorPosition, currentScale, canvasOffset, selectedShape) {
50
+ var selectShape = function selectShape(shapes, cursorPosition, currentScale, canvasOffset, selectedShape, selectionPadding) {
51
51
  if (selectedShape) {
52
- var positionIntersection = (0, _intersect.checkPositionIntersection)(selectedShape, cursorPosition, canvasOffset, currentScale, true) || {
52
+ var positionIntersection = (0, _intersect.checkPositionIntersection)(selectedShape, cursorPosition, canvasOffset, selectionPadding, currentScale, true) || {
53
53
  mode: _Mode.SelectionModeLib["default"]
54
54
  };
55
- var newSelectionMode = getNewSelectionData(positionIntersection, selectedShape, cursorPosition);
55
+ var newSelectionMode = getNewSelectionData(positionIntersection, selectedShape, cursorPosition, selectionPadding);
56
56
 
57
57
  if (newSelectionMode) {
58
58
  return {
@@ -63,7 +63,7 @@ var selectShape = function selectShape(shapes, cursorPosition, currentScale, can
63
63
  }
64
64
 
65
65
  var foundShape = _fp["default"].find(function (shape) {
66
- return !!(0, _intersect.checkPositionIntersection)(shape, cursorPosition, canvasOffset, currentScale, false);
66
+ return !!(0, _intersect.checkPositionIntersection)(shape, cursorPosition, canvasOffset, selectionPadding, currentScale, false);
67
67
  }, shapes);
68
68
 
69
69
  if (!!foundShape) {
@@ -7,18 +7,13 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.getShapeInfos = void 0;
9
9
 
10
- var _shapes = require("../constants/shapes");
11
-
12
10
  var _fp = _interopRequireDefault(require("lodash/fp"));
13
11
 
14
- var getLineBorder = function getLineBorder(line) {
15
- var x = Math.min(line.points[0][0], line.points[1][0]) - _shapes.SELECTION_PADDING;
16
-
17
- var width = Math.abs(line.points[0][0] - line.points[1][0]) + _shapes.SELECTION_PADDING * 2;
18
-
19
- var y = Math.min(line.points[0][1], line.points[1][1]) - _shapes.SELECTION_PADDING;
20
-
21
- var height = Math.abs(line.points[0][1] - line.points[1][1]) + _shapes.SELECTION_PADDING * 2;
12
+ var getLineBorder = function getLineBorder(line, selectionPadding) {
13
+ var x = Math.min(line.points[0][0], line.points[1][0]) - selectionPadding;
14
+ var width = Math.abs(line.points[0][0] - line.points[1][0]) + selectionPadding * 2;
15
+ var y = Math.min(line.points[0][1], line.points[1][1]) - selectionPadding;
16
+ var height = Math.abs(line.points[0][1] - line.points[1][1]) + selectionPadding * 2;
22
17
  return {
23
18
  x: x,
24
19
  width: width,
@@ -27,26 +22,26 @@ var getLineBorder = function getLineBorder(line) {
27
22
  };
28
23
  };
29
24
 
30
- var getBrushBorder = function getBrushBorder(brush) {
25
+ var getBrushBorder = function getBrushBorder(brush, selectionPadding) {
31
26
  var brushPoints = _fp["default"].flatMap(function (points) {
32
27
  return points;
33
28
  }, brush.points);
34
29
 
35
30
  var minX = _fp["default"].flow(_fp["default"].map(function (point) {
36
31
  return point[0];
37
- }), _fp["default"].min, _fp["default"].add(-_shapes.SELECTION_PADDING))(brushPoints);
32
+ }), _fp["default"].min, _fp["default"].add(-selectionPadding))(brushPoints);
38
33
 
39
34
  var maxX = _fp["default"].flow(_fp["default"].map(function (point) {
40
35
  return point[0];
41
- }), _fp["default"].max, _fp["default"].add(_shapes.SELECTION_PADDING))(brushPoints);
36
+ }), _fp["default"].max, _fp["default"].add(selectionPadding))(brushPoints);
42
37
 
43
38
  var minY = _fp["default"].flow(_fp["default"].map(function (point) {
44
39
  return point[1];
45
- }), _fp["default"].min, _fp["default"].add(-_shapes.SELECTION_PADDING))(brushPoints);
40
+ }), _fp["default"].min, _fp["default"].add(-selectionPadding))(brushPoints);
46
41
 
47
42
  var maxY = _fp["default"].flow(_fp["default"].map(function (point) {
48
43
  return point[1];
49
- }), _fp["default"].max, _fp["default"].add(_shapes.SELECTION_PADDING))(brushPoints);
44
+ }), _fp["default"].max, _fp["default"].add(selectionPadding))(brushPoints);
50
45
 
51
46
  return {
52
47
  x: minX,
@@ -56,22 +51,22 @@ var getBrushBorder = function getBrushBorder(brush) {
56
51
  };
57
52
  };
58
53
 
59
- var getPolygonBorder = function getPolygonBorder(polygon) {
54
+ var getPolygonBorder = function getPolygonBorder(polygon, selectionPadding) {
60
55
  var minX = _fp["default"].flow(_fp["default"].map(function (point) {
61
56
  return point[0];
62
- }), _fp["default"].min, _fp["default"].add(-_shapes.SELECTION_PADDING))(polygon.points);
57
+ }), _fp["default"].min, _fp["default"].add(-selectionPadding))(polygon.points);
63
58
 
64
59
  var maxX = _fp["default"].flow(_fp["default"].map(function (point) {
65
60
  return point[0];
66
- }), _fp["default"].max, _fp["default"].add(_shapes.SELECTION_PADDING))(polygon.points);
61
+ }), _fp["default"].max, _fp["default"].add(selectionPadding))(polygon.points);
67
62
 
68
63
  var minY = _fp["default"].flow(_fp["default"].map(function (point) {
69
64
  return point[1];
70
- }), _fp["default"].min, _fp["default"].add(-_shapes.SELECTION_PADDING))(polygon.points);
65
+ }), _fp["default"].min, _fp["default"].add(-selectionPadding))(polygon.points);
71
66
 
72
67
  var maxY = _fp["default"].flow(_fp["default"].map(function (point) {
73
68
  return point[1];
74
- }), _fp["default"].max, _fp["default"].add(_shapes.SELECTION_PADDING))(polygon.points);
69
+ }), _fp["default"].max, _fp["default"].add(selectionPadding))(polygon.points);
75
70
 
76
71
  return {
77
72
  x: minX,
@@ -83,75 +78,75 @@ var getPolygonBorder = function getPolygonBorder(polygon) {
83
78
 
84
79
  var getCurveBorder = getPolygonBorder;
85
80
 
86
- var getRectBorder = function getRectBorder(rect) {
81
+ var getRectBorder = function getRectBorder(rect, selectionPadding) {
87
82
  return {
88
- x: rect.x - _shapes.SELECTION_PADDING,
89
- width: rect.width + _shapes.SELECTION_PADDING * 2,
90
- y: rect.y - _shapes.SELECTION_PADDING,
91
- height: rect.height + _shapes.SELECTION_PADDING * 2
83
+ x: rect.x - selectionPadding,
84
+ width: rect.width + selectionPadding * 2,
85
+ y: rect.y - selectionPadding,
86
+ height: rect.height + selectionPadding * 2
92
87
  };
93
88
  };
94
89
 
95
- var getTextBorder = function getTextBorder(text) {
90
+ var getTextBorder = function getTextBorder(text, selectionPadding) {
96
91
  return {
97
- x: text.x - _shapes.SELECTION_PADDING,
98
- width: text.width + _shapes.SELECTION_PADDING * 2,
99
- y: text.y - _shapes.SELECTION_PADDING,
100
- height: text.height + _shapes.SELECTION_PADDING * 2
92
+ x: text.x - selectionPadding,
93
+ width: text.width + selectionPadding * 2,
94
+ y: text.y - selectionPadding,
95
+ height: text.height + selectionPadding * 2
101
96
  };
102
97
  };
103
98
 
104
- var getPictureBorder = function getPictureBorder(picture) {
105
- return getRectBorder(picture);
99
+ var getPictureBorder = function getPictureBorder(picture, selectionPadding) {
100
+ return getRectBorder(picture, selectionPadding);
106
101
  };
107
102
 
108
- var getCircleBorder = function getCircleBorder(circle) {
103
+ var getCircleBorder = function getCircleBorder(circle, selectionPadding) {
109
104
  return {
110
- x: circle.x - circle.radius - _shapes.SELECTION_PADDING,
111
- width: (circle.radius + _shapes.SELECTION_PADDING) * 2,
112
- y: circle.y - circle.radius - _shapes.SELECTION_PADDING,
113
- height: (circle.radius + _shapes.SELECTION_PADDING) * 2
105
+ x: circle.x - circle.radius - selectionPadding,
106
+ width: (circle.radius + selectionPadding) * 2,
107
+ y: circle.y - circle.radius - selectionPadding,
108
+ height: (circle.radius + selectionPadding) * 2
114
109
  };
115
110
  };
116
111
 
117
- var getEllipseBorder = function getEllipseBorder(ellipse) {
112
+ var getEllipseBorder = function getEllipseBorder(ellipse, selectionPadding) {
118
113
  return {
119
- x: ellipse.x - ellipse.radiusX - _shapes.SELECTION_PADDING,
120
- width: (ellipse.radiusX + _shapes.SELECTION_PADDING) * 2,
121
- y: ellipse.y - ellipse.radiusY - _shapes.SELECTION_PADDING,
122
- height: (ellipse.radiusY + _shapes.SELECTION_PADDING) * 2
114
+ x: ellipse.x - ellipse.radiusX - selectionPadding,
115
+ width: (ellipse.radiusX + selectionPadding) * 2,
116
+ y: ellipse.y - ellipse.radiusY - selectionPadding,
117
+ height: (ellipse.radiusY + selectionPadding) * 2
123
118
  };
124
119
  };
125
120
 
126
- var getShapeBorders = function getShapeBorders(marker) {
121
+ var getShapeBorders = function getShapeBorders(marker, selectionPadding) {
127
122
  switch (marker.type) {
128
123
  case 'brush':
129
- return getBrushBorder(marker);
124
+ return getBrushBorder(marker, selectionPadding);
130
125
 
131
126
  case 'line':
132
- return getLineBorder(marker);
127
+ return getLineBorder(marker, selectionPadding);
133
128
 
134
129
  case 'polygon':
135
- return getPolygonBorder(marker);
130
+ return getPolygonBorder(marker, selectionPadding);
136
131
 
137
132
  case 'curve':
138
- return getCurveBorder(marker);
133
+ return getCurveBorder(marker, selectionPadding);
139
134
 
140
135
  case 'circle':
141
- return getCircleBorder(marker);
136
+ return getCircleBorder(marker, selectionPadding);
142
137
 
143
138
  case 'ellipse':
144
- return getEllipseBorder(marker);
139
+ return getEllipseBorder(marker, selectionPadding);
145
140
 
146
141
  case 'rect':
147
142
  case 'square':
148
- return getRectBorder(marker);
143
+ return getRectBorder(marker, selectionPadding);
149
144
 
150
145
  case 'text':
151
- return getTextBorder(marker);
146
+ return getTextBorder(marker, selectionPadding);
152
147
 
153
148
  case 'picture':
154
- return getPictureBorder(marker);
149
+ return getPictureBorder(marker, selectionPadding);
155
150
  }
156
151
 
157
152
  return {
@@ -166,8 +161,8 @@ var getShapeCenter = function getShapeCenter(borders) {
166
161
  return [borders.x + borders.width / 2, borders.y + borders.height / 2];
167
162
  };
168
163
 
169
- var getShapeInfos = function getShapeInfos(shape) {
170
- var borders = getShapeBorders(shape);
164
+ var getShapeInfos = function getShapeInfos(shape, selectionPadding) {
165
+ var borders = getShapeBorders(shape, selectionPadding);
171
166
  var center = getShapeCenter(borders);
172
167
  return {
173
168
  borders: borders,