@syncfusion/ej2-image-editor 23.2.6 → 24.1.41
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.
- package/CHANGELOG.md +3 -51
- package/dist/ej2-image-editor.umd.min.js +2 -2
- package/dist/ej2-image-editor.umd.min.js.map +1 -1
- package/dist/es6/ej2-image-editor.es2015.js +7151 -4321
- package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
- package/dist/es6/ej2-image-editor.es5.js +7269 -4426
- package/dist/es6/ej2-image-editor.es5.js.map +1 -1
- package/dist/global/ej2-image-editor.min.js +2 -2
- package/dist/global/ej2-image-editor.min.js.map +1 -1
- package/dist/global/index.d.ts +1 -1
- package/package.json +12 -12
- package/src/image-editor/action/crop.d.ts +6 -0
- package/src/image-editor/action/crop.js +347 -188
- package/src/image-editor/action/draw.d.ts +35 -2
- package/src/image-editor/action/draw.js +1682 -881
- package/src/image-editor/action/export.js +90 -29
- package/src/image-editor/action/filter.d.ts +3 -1
- package/src/image-editor/action/filter.js +74 -94
- package/src/image-editor/action/freehand-draw.d.ts +4 -0
- package/src/image-editor/action/freehand-draw.js +259 -149
- package/src/image-editor/action/selection.d.ts +6 -1
- package/src/image-editor/action/selection.js +1133 -1091
- package/src/image-editor/action/shape.d.ts +7 -0
- package/src/image-editor/action/shape.js +921 -550
- package/src/image-editor/action/transform.d.ts +2 -0
- package/src/image-editor/action/transform.js +514 -346
- package/src/image-editor/action/undo-redo.d.ts +2 -0
- package/src/image-editor/action/undo-redo.js +137 -36
- package/src/image-editor/base/enum.d.ts +2 -1
- package/src/image-editor/base/enum.js +1 -0
- package/src/image-editor/base/image-editor-model.d.ts +37 -2
- package/src/image-editor/base/image-editor.d.ts +124 -3
- package/src/image-editor/base/image-editor.js +672 -171
- package/src/image-editor/base/interface.d.ts +69 -15
- package/src/image-editor/renderer/toolbar.d.ts +10 -0
- package/src/image-editor/renderer/toolbar.js +1371 -822
- package/styles/bootstrap-dark.css +113 -8
- package/styles/bootstrap.css +112 -7
- package/styles/bootstrap4.css +113 -8
- package/styles/bootstrap5-dark.css +113 -8
- package/styles/bootstrap5.css +113 -8
- package/styles/fabric-dark.css +114 -9
- package/styles/fabric.css +113 -8
- package/styles/fluent-dark.css +118 -9
- package/styles/fluent.css +118 -9
- package/styles/highcontrast-light.css +112 -7
- package/styles/highcontrast.css +116 -7
- package/styles/image-editor/_bootstrap-dark-definition.scss +3 -0
- package/styles/image-editor/_bootstrap-definition.scss +3 -0
- package/styles/image-editor/_bootstrap4-definition.scss +3 -0
- package/styles/image-editor/_bootstrap5-definition.scss +3 -0
- package/styles/image-editor/_fabric-dark-definition.scss +3 -0
- package/styles/image-editor/_fabric-definition.scss +3 -0
- package/styles/image-editor/_fluent-definition.scss +3 -0
- package/styles/image-editor/_fusionnew-definition.scss +3 -0
- package/styles/image-editor/_highcontrast-definition.scss +3 -0
- package/styles/image-editor/_highcontrast-light-definition.scss +3 -0
- package/styles/image-editor/_layout.scss +138 -4
- package/styles/image-editor/_material-dark-definition.scss +3 -0
- package/styles/image-editor/_material-definition.scss +3 -0
- package/styles/image-editor/_material3-definition.scss +3 -0
- package/styles/image-editor/_tailwind-definition.scss +3 -0
- package/styles/image-editor/_theme.scss +2 -4
- package/styles/image-editor/bootstrap-dark.css +113 -8
- package/styles/image-editor/bootstrap.css +112 -7
- package/styles/image-editor/bootstrap4.css +113 -8
- package/styles/image-editor/bootstrap5-dark.css +113 -8
- package/styles/image-editor/bootstrap5.css +113 -8
- package/styles/image-editor/fabric-dark.css +114 -9
- package/styles/image-editor/fabric.css +113 -8
- package/styles/image-editor/fluent-dark.css +118 -9
- package/styles/image-editor/fluent.css +118 -9
- package/styles/image-editor/highcontrast-light.css +112 -7
- package/styles/image-editor/highcontrast.css +116 -7
- package/styles/image-editor/icons/_bootstrap-dark.scss +60 -0
- package/styles/image-editor/icons/_bootstrap.scss +60 -0
- package/styles/image-editor/icons/_bootstrap4.scss +60 -0
- package/styles/image-editor/icons/_bootstrap5.scss +60 -0
- package/styles/image-editor/icons/_fabric-dark.scss +60 -0
- package/styles/image-editor/icons/_fabric.scss +60 -0
- package/styles/image-editor/icons/_fluent.scss +66 -0
- package/styles/image-editor/icons/_highcontrast-light.scss +60 -0
- package/styles/image-editor/icons/_highcontrast.scss +60 -0
- package/styles/image-editor/icons/_material-dark.scss +60 -0
- package/styles/image-editor/icons/_material.scss +60 -0
- package/styles/image-editor/icons/_material3.scss +60 -0
- package/styles/image-editor/icons/_tailwind.scss +60 -0
- package/styles/image-editor/material-dark.css +113 -8
- package/styles/image-editor/material.css +113 -8
- package/styles/image-editor/material3-dark.css +126 -9
- package/styles/image-editor/material3.css +126 -9
- package/styles/image-editor/tailwind-dark.css +114 -9
- package/styles/image-editor/tailwind.css +114 -9
- package/styles/material-dark.css +113 -8
- package/styles/material.css +113 -8
- package/styles/material3-dark.css +126 -9
- package/styles/material3.css +126 -9
- package/styles/tailwind-dark.css +114 -9
- package/styles/tailwind.css +114 -9
|
@@ -8,7 +8,7 @@ var Draw = /** @class */ (function () {
|
|
|
8
8
|
this.isShapeTextInserted = false;
|
|
9
9
|
this.isRotateZoom = false; // To restore zoomed image on selection crop selection
|
|
10
10
|
this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null }; // restore stroke settings on cancel
|
|
11
|
-
this.tempTextSettings = { text: 'Enter Text', fontFamily: '
|
|
11
|
+
this.tempTextSettings = { text: 'Enter Text', fontFamily: '', fontSize: null, fontRatio: null, bold: false, italic: false, underline: false }; // restore text settings on cancel
|
|
12
12
|
this.tempAdjValue = ''; // for temp internal slider value
|
|
13
13
|
this.tempFilter = ''; // restore filter style on cancel
|
|
14
14
|
this.tempUndoRedoStep = 0;
|
|
@@ -25,9 +25,12 @@ var Draw = /** @class */ (function () {
|
|
|
25
25
|
this.arrowDimension = { bar: { width: 10, height: 32, ratioX: null, ratioY: null },
|
|
26
26
|
arrow: { width: 24, height: 24, ratioX: null, ratioY: null }, arrowSolid: { width: 32, height: 32, ratioX: null, ratioY: null },
|
|
27
27
|
circle: { width: 10, height: 10, ratioX: null, ratioY: null }, square: { width: 20, height: 20, ratioX: null, ratioY: null } };
|
|
28
|
-
this.tempFrame = 'none';
|
|
29
28
|
this.origDim = { width: 0, height: 0 };
|
|
30
29
|
this.isImageApply = false;
|
|
30
|
+
this.imgCanvasPoints = [];
|
|
31
|
+
this.isCropSelect = false;
|
|
32
|
+
this.isDownScale = false;
|
|
33
|
+
this.preventStraightening = false;
|
|
31
34
|
this.parent = parent;
|
|
32
35
|
this.addEventListener();
|
|
33
36
|
}
|
|
@@ -70,7 +73,7 @@ var Draw = /** @class */ (function () {
|
|
|
70
73
|
this.setTransform(args.value['context'], args.value['value'], args.value['isReverse']);
|
|
71
74
|
break;
|
|
72
75
|
case 'render-image':
|
|
73
|
-
this.renderImage(args.value['isMouseWheel'], args.value['isPreventClearRect'], args.value['isFrame']);
|
|
76
|
+
this.renderImage(args.value['isMouseWheel'], args.value['isPreventClearRect'], args.value['isFrame'], args.value['isStraighten']);
|
|
74
77
|
break;
|
|
75
78
|
case 'draw-image-to-canvas':
|
|
76
79
|
this.drawImgToCanvas(args.value['dimension']);
|
|
@@ -100,10 +103,10 @@ var Draw = /** @class */ (function () {
|
|
|
100
103
|
this.redrawImgWithObj();
|
|
101
104
|
break;
|
|
102
105
|
case 'setCurrentObj':
|
|
103
|
-
this.setCurrentObj(args.value['obj']);
|
|
106
|
+
this.setCurrentObj(args.value['obj'], args.value['isUndoRedo']);
|
|
104
107
|
break;
|
|
105
108
|
case 'performPointZoom':
|
|
106
|
-
this.performPointZoom(args.value['x'], args.value['y'], args.value['type']);
|
|
109
|
+
this.performPointZoom(args.value['x'], args.value['y'], args.value['type'], args.value['isResize']);
|
|
107
110
|
break;
|
|
108
111
|
case 'open':
|
|
109
112
|
this.open(args.value['data']);
|
|
@@ -212,15 +215,9 @@ var Draw = /** @class */ (function () {
|
|
|
212
215
|
case 'applyFrame':
|
|
213
216
|
this.applyFrame(args.value['ctx'], args.value['frame'], args.value['preventImg']);
|
|
214
217
|
break;
|
|
215
|
-
case 'getTempFrame':
|
|
216
|
-
args.value['obj']['tempFrame'] = this.tempFrame;
|
|
217
|
-
break;
|
|
218
218
|
case 'drawImage':
|
|
219
219
|
this.drawImage();
|
|
220
220
|
break;
|
|
221
|
-
case 'setTempFrame':
|
|
222
|
-
this.tempFrame = args.value['frame'];
|
|
223
|
-
break;
|
|
224
221
|
case 'downScaleImgCanvas':
|
|
225
222
|
this.downScaleImgCanvas(args.value['ctx'], args.value['isImgAnnotation'], args.value['isHFlip'], args.value['isVFlip']);
|
|
226
223
|
break;
|
|
@@ -228,7 +225,7 @@ var Draw = /** @class */ (function () {
|
|
|
228
225
|
this.downScale(args.value['canvas'], args.value['width'], args.value['height']);
|
|
229
226
|
break;
|
|
230
227
|
case 'resetFrameZoom':
|
|
231
|
-
this.resetFrameZoom();
|
|
228
|
+
this.resetFrameZoom(args.value['isOk']);
|
|
232
229
|
break;
|
|
233
230
|
case 'triggerFrameChange':
|
|
234
231
|
args.value['obj']['frameChangeEventArgs'] = this.triggerFrameChange(args.value['prevFrameSettings']);
|
|
@@ -236,6 +233,63 @@ var Draw = /** @class */ (function () {
|
|
|
236
233
|
case 'setImageApply':
|
|
237
234
|
this.isImageApply = args.value['bool'];
|
|
238
235
|
break;
|
|
236
|
+
case 'zoomToSel':
|
|
237
|
+
this.zoomToSel(args.value['activeObj'], args.value['isToolbar']);
|
|
238
|
+
break;
|
|
239
|
+
case 'getStraightenActObj':
|
|
240
|
+
args.value['obj']['activeObj'] = this.straightenActObj;
|
|
241
|
+
break;
|
|
242
|
+
case 'setStraightenActObj':
|
|
243
|
+
this.straightenActObj = args.value['activeObj'];
|
|
244
|
+
break;
|
|
245
|
+
case 'updateImgCanvasPoints':
|
|
246
|
+
this.updateImgCanvasPoints();
|
|
247
|
+
break;
|
|
248
|
+
case 'isLinesIntersect':
|
|
249
|
+
args.value['obj']['isIntersect'] = this.isLinesIntersect(args.value['obj']);
|
|
250
|
+
break;
|
|
251
|
+
case 'getImageCanvasPoints':
|
|
252
|
+
args.value['obj']['points'] = this.imgCanvasPoints;
|
|
253
|
+
break;
|
|
254
|
+
case 'setDestForStraighten':
|
|
255
|
+
this.setDestForStraighten();
|
|
256
|
+
break;
|
|
257
|
+
case 'setTempDestForStraighten':
|
|
258
|
+
this.tempStraightenDestPoints = extend({}, this.straightenDestPoints, {}, true);
|
|
259
|
+
break;
|
|
260
|
+
case 'getStraightenInitZoom':
|
|
261
|
+
args.value['obj']['zoomFactor'] = this.straightenInitZoom;
|
|
262
|
+
break;
|
|
263
|
+
case 'setStraightenInitZoom':
|
|
264
|
+
this.straightenInitZoom = args.value['zoomFactor'];
|
|
265
|
+
break;
|
|
266
|
+
case 'isPointsInsideImg':
|
|
267
|
+
args.value['obj']['bool'] = this.checkPointPosition(args.value['x'], args.value['y'], this.imgCanvasPoints[0].x, this.imgCanvasPoints[0].y, this.imgCanvasPoints[1].x, this.imgCanvasPoints[1].y, this.imgCanvasPoints[2].x, this.imgCanvasPoints[2].y, this.imgCanvasPoints[3].x, this.imgCanvasPoints[3].y) !== 'inside';
|
|
268
|
+
break;
|
|
269
|
+
case 'setIsCropSelect':
|
|
270
|
+
this.isCropSelect = args.value['bool'];
|
|
271
|
+
break;
|
|
272
|
+
case 'updateCropSelection':
|
|
273
|
+
this.updateCropSelection();
|
|
274
|
+
break;
|
|
275
|
+
case 'updateCropSelObj':
|
|
276
|
+
this.updateCropSelObj();
|
|
277
|
+
break;
|
|
278
|
+
case 'redrawDownScale':
|
|
279
|
+
this.redrawDownScale();
|
|
280
|
+
break;
|
|
281
|
+
case 'updateFinetune':
|
|
282
|
+
this.updateFinetune();
|
|
283
|
+
break;
|
|
284
|
+
case 'isSelOutsideImg':
|
|
285
|
+
args.value['obj']['bool'] = this.isSelOutsideImg();
|
|
286
|
+
break;
|
|
287
|
+
case 'resetStraightenDestPoints':
|
|
288
|
+
this.straightenDestPoints = null;
|
|
289
|
+
break;
|
|
290
|
+
case 'checkPointPosition':
|
|
291
|
+
args.value['obj']['position'] = this.checkPointPosition(args.value['obj']['x'], args.value['obj']['y'], args.value['obj']['x1'], args.value['obj']['y1'], args.value['obj']['x2'], args.value['obj']['y2'], args.value['obj']['x3'], args.value['obj']['y3'], args.value['obj']['x4'], args.value['obj']['y4']);
|
|
292
|
+
break;
|
|
239
293
|
}
|
|
240
294
|
};
|
|
241
295
|
Draw.prototype.getModuleName = function () {
|
|
@@ -252,11 +306,13 @@ var Draw = /** @class */ (function () {
|
|
|
252
306
|
if (isNullOrUndefined(this.tempZoomFactor)) {
|
|
253
307
|
this.tempZoomFactor = parent.transform.zoomFactor;
|
|
254
308
|
}
|
|
309
|
+
if (this.tempTextSettings.fontFamily === '') {
|
|
310
|
+
this.tempTextSettings.fontFamily = parent.fontFamily.default;
|
|
311
|
+
}
|
|
255
312
|
};
|
|
256
313
|
Draw.prototype.reset = function () {
|
|
257
314
|
this.isInitialLoading = this.isErrorImage = this.isNewPath = this.isResizeSelect = false;
|
|
258
315
|
this.isShapeTextInserted = false;
|
|
259
|
-
this.tempFrame = 'none';
|
|
260
316
|
this.isImageApply = false;
|
|
261
317
|
this.initZoomValue = null;
|
|
262
318
|
this.tempFilter = '';
|
|
@@ -266,34 +322,71 @@ var Draw = /** @class */ (function () {
|
|
|
266
322
|
this.tempAdjValue = '';
|
|
267
323
|
this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null };
|
|
268
324
|
this.tempTextSettings =
|
|
269
|
-
{ text: 'Enter Text', fontFamily:
|
|
325
|
+
{ text: 'Enter Text', fontFamily: this.parent.fontFamily.default, fontSize: null, fontRatio: null, bold: false, italic: false, underline: false };
|
|
270
326
|
this.tempUndoRedoStep = this.tempFreehandCounter = this.tempCurrFhdIndex = 0;
|
|
271
327
|
this.tempZoomFactor = null;
|
|
272
328
|
this.isCancelAction = false;
|
|
273
329
|
this.rotatedFlipCropSel = false;
|
|
274
330
|
this.prevActObj = null;
|
|
331
|
+
this.tempStraightenDestPoints = null;
|
|
275
332
|
this.arrowDimension = { bar: { width: 10, height: 32, ratioX: null, ratioY: null },
|
|
276
333
|
arrow: { width: 24, height: 24, ratioX: null, ratioY: null }, arrowSolid: { width: 32, height: 32, ratioX: null, ratioY: null },
|
|
277
334
|
circle: { width: 10, height: 10, ratioX: null, ratioY: null }, square: { width: 20, height: 20, ratioX: null, ratioY: null } };
|
|
335
|
+
this.straightenActObj = null;
|
|
336
|
+
this.imgCanvasPoints = [];
|
|
337
|
+
this.straightenInitZoom = null;
|
|
338
|
+
this.straightenDestPoints = null;
|
|
339
|
+
this.isCropSelect = this.isDownScale = this.preventStraightening = false;
|
|
340
|
+
};
|
|
341
|
+
Draw.prototype.redrawDownScale = function () {
|
|
342
|
+
var parent = this.parent;
|
|
343
|
+
if (parent.transform.zoomFactor && parent.transform.zoomFactor < 0) {
|
|
344
|
+
var activeObj = extend({}, parent.activeObj, {}, true);
|
|
345
|
+
parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
|
|
346
|
+
this.isDownScale = true;
|
|
347
|
+
this.renderImage();
|
|
348
|
+
this.isDownScale = false;
|
|
349
|
+
if (activeObj.shape) {
|
|
350
|
+
this.drawObject('duplicate', activeObj);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
Draw.prototype.updateFinetune = function () {
|
|
355
|
+
var parent = this.parent;
|
|
356
|
+
if (parent.transform.zoomFactor && parent.transform.zoomFactor < 0) {
|
|
357
|
+
var filter = this.lowerContext.filter;
|
|
358
|
+
this.lowerContext.filter = 'none';
|
|
359
|
+
parent.notify('draw', { prop: 'redrawDownScale' });
|
|
360
|
+
var inMemoryContext = parent.inMemoryCanvas.getContext('2d');
|
|
361
|
+
var ctx = this.lowerContext;
|
|
362
|
+
var imageData = ctx.getImageData(0, 0, ctx.canvas.width, ctx.canvas.height);
|
|
363
|
+
parent.inMemoryCanvas.width = imageData.width;
|
|
364
|
+
parent.inMemoryCanvas.height = imageData.height;
|
|
365
|
+
inMemoryContext.putImageData(imageData, 0, 0);
|
|
366
|
+
this.lowerContext.filter = filter;
|
|
367
|
+
parent.notify('draw', { prop: 'redrawDownScale' });
|
|
368
|
+
}
|
|
278
369
|
};
|
|
279
370
|
Draw.prototype.drawImage = function () {
|
|
280
371
|
this.applyFrame(this.lowerContext, this.parent.frameObj.type);
|
|
281
372
|
};
|
|
282
373
|
Draw.prototype.drawObject = function (canvas, obj, isCropRatio, points, isPreventDrag, saveContext, isPreventSelection) {
|
|
283
374
|
var parent = this.parent;
|
|
375
|
+
var actObj = parent.activeObj;
|
|
284
376
|
var actPoint = parent.activeObj.activePoint;
|
|
285
377
|
this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
|
|
286
378
|
var canvasDraw;
|
|
287
|
-
|
|
379
|
+
canvas = canvas.toLowerCase();
|
|
380
|
+
if (canvas === 'original') {
|
|
288
381
|
canvasDraw = this.lowerContext;
|
|
289
382
|
}
|
|
290
|
-
else if (canvas
|
|
383
|
+
else if (canvas === 'duplicate') {
|
|
291
384
|
canvasDraw = this.upperContext;
|
|
292
385
|
}
|
|
293
386
|
else if (saveContext) {
|
|
294
387
|
canvasDraw = saveContext;
|
|
295
388
|
}
|
|
296
|
-
if (!isPreventDrag &&
|
|
389
|
+
if (!isPreventDrag && actObj.shape) {
|
|
297
390
|
this.setDragLimit();
|
|
298
391
|
}
|
|
299
392
|
if (parent.currObjType.shape) {
|
|
@@ -302,6 +395,19 @@ var Draw = /** @class */ (function () {
|
|
|
302
395
|
this.drawCropRatio();
|
|
303
396
|
}
|
|
304
397
|
}
|
|
398
|
+
actObj = parent.activeObj;
|
|
399
|
+
actPoint = parent.activeObj.activePoint;
|
|
400
|
+
if (isNullOrUndefined(actObj.strokeSettings)) {
|
|
401
|
+
var obj_1 = { strokeSettings: {} };
|
|
402
|
+
parent.notify('shape', { prop: 'getStrokeSettings', onPropertyChange: false, value: { obj: obj_1 } });
|
|
403
|
+
actObj.strokeSettings = obj_1['strokeSettings'];
|
|
404
|
+
}
|
|
405
|
+
if (isNullOrUndefined(actObj.strokeSettings.strokeWidth)) {
|
|
406
|
+
actObj.strokeSettings.strokeWidth = 2;
|
|
407
|
+
}
|
|
408
|
+
if (obj) {
|
|
409
|
+
parent.activeObj = extend({}, obj, {}, true);
|
|
410
|
+
}
|
|
305
411
|
if (points) {
|
|
306
412
|
actPoint.startX = points.startX;
|
|
307
413
|
actPoint.startY = points.startY;
|
|
@@ -310,38 +416,38 @@ var Draw = /** @class */ (function () {
|
|
|
310
416
|
actPoint.width = points.width;
|
|
311
417
|
actPoint.height = points.height;
|
|
312
418
|
}
|
|
313
|
-
if (isNullOrUndefined(parent.activeObj.strokeSettings)) {
|
|
314
|
-
var obj_1 = { strokeSettings: {} };
|
|
315
|
-
parent.notify('shape', { prop: 'getStrokeSettings', onPropertyChange: false,
|
|
316
|
-
value: { obj: obj_1 } });
|
|
317
|
-
parent.activeObj.strokeSettings = obj_1['strokeSettings'];
|
|
318
|
-
}
|
|
319
|
-
if (isNullOrUndefined(parent.activeObj.strokeSettings.strokeWidth)) {
|
|
320
|
-
parent.activeObj.strokeSettings.strokeWidth = 2;
|
|
321
|
-
}
|
|
322
|
-
if (obj) {
|
|
323
|
-
parent.activeObj = extend({}, obj, {}, true);
|
|
324
|
-
}
|
|
325
419
|
this.updateActiveObject();
|
|
326
|
-
|
|
327
|
-
|
|
420
|
+
actObj = parent.activeObj;
|
|
421
|
+
actPoint = parent.activeObj.activePoint;
|
|
422
|
+
if (isNullOrUndefined(actPoint.startX) && isNullOrUndefined(actPoint.startY)) {
|
|
328
423
|
return;
|
|
329
424
|
}
|
|
330
425
|
if (parent.currObjType.isText) {
|
|
331
426
|
var obj_2 = { keyHistory: '' };
|
|
332
427
|
parent.notify('shape', { prop: 'getKeyHistory', onPropertyChange: false, value: { obj: obj_2 } });
|
|
333
|
-
|
|
428
|
+
actObj.keyHistory = obj_2['keyHistory'];
|
|
334
429
|
}
|
|
335
|
-
|
|
430
|
+
var isCrop = false;
|
|
431
|
+
if (canvas !== 'original') {
|
|
336
432
|
var splitWords = void 0;
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
splitWords = parent.activeObj.shape.split('-');
|
|
433
|
+
if (actObj.shape) {
|
|
434
|
+
splitWords = actObj.shape.split('-');
|
|
340
435
|
if (splitWords[0] === 'crop') {
|
|
341
436
|
isCrop = true;
|
|
342
437
|
}
|
|
343
438
|
}
|
|
344
439
|
if (isCrop) {
|
|
440
|
+
if (points) {
|
|
441
|
+
actPoint.startX = points.startX;
|
|
442
|
+
actPoint.startY = points.startY;
|
|
443
|
+
actPoint.endX = points.endX;
|
|
444
|
+
actPoint.endY = points.endY;
|
|
445
|
+
actPoint.width = points.width;
|
|
446
|
+
actPoint.height = points.height;
|
|
447
|
+
}
|
|
448
|
+
else {
|
|
449
|
+
actPoint = actObj.activePoint;
|
|
450
|
+
}
|
|
345
451
|
this.upperContext.fillStyle = 'rgb(0, 0, 0, 0.25)';
|
|
346
452
|
this.upperContext.fillRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
|
|
347
453
|
this.upperContext.clearRect(actPoint.startX, actPoint.startY, actPoint.width, actPoint.height);
|
|
@@ -361,42 +467,60 @@ var Draw = /** @class */ (function () {
|
|
|
361
467
|
else if (object['keyHistory'] !== '' && parent.currObjType.isText) {
|
|
362
468
|
this.drawShapeObj(canvas, 'text', saveContext, isPreventSelection);
|
|
363
469
|
}
|
|
364
|
-
else if (
|
|
365
|
-
this.drawShapeObj(canvas,
|
|
470
|
+
else if (actObj.shape) {
|
|
471
|
+
this.drawShapeObj(canvas, actObj.shape, saveContext, isPreventSelection);
|
|
366
472
|
}
|
|
367
473
|
else {
|
|
368
474
|
this.drawShapeObj(canvas, undefined, saveContext, isPreventSelection);
|
|
369
475
|
}
|
|
476
|
+
if (canvas === 'duplicate' && isCrop && actObj.shape !== 'crop-circle' && parent.frameObj.type !== 'none') {
|
|
477
|
+
this.applyFrame(this.upperContext, parent.frameObj.type);
|
|
478
|
+
this.drawCornerCircles(this.upperContext);
|
|
479
|
+
}
|
|
370
480
|
};
|
|
371
481
|
Draw.prototype.rotateContext = function (type, ctx) {
|
|
372
482
|
var parent = this.parent;
|
|
373
|
-
var
|
|
374
|
-
|
|
483
|
+
var _a = parent.activeObj, shape = _a.shape, rotatedAngle = _a.rotatedAngle;
|
|
484
|
+
var _b = parent.img, destLeft = _b.destLeft, destTop = _b.destTop, destWidth = _b.destWidth, destHeight = _b.destHeight;
|
|
485
|
+
var _c = parent.activeObj.activePoint, startX = _c.startX, startY = _c.startY, width = _c.width, height = _c.height;
|
|
486
|
+
if (shape === 'line' || shape === 'arrow') {
|
|
375
487
|
return;
|
|
376
488
|
}
|
|
377
|
-
var rotationAngle = (type === 'initial') ?
|
|
378
|
-
|
|
489
|
+
var rotationAngle = (type === 'initial') ? rotatedAngle : -rotatedAngle;
|
|
490
|
+
var translateX;
|
|
491
|
+
var translateY;
|
|
492
|
+
if (parent.transform.straighten === 0 && !parent.isCropTab) {
|
|
493
|
+
translateX = startX + (width / 2);
|
|
494
|
+
translateY = startY + (height / 2);
|
|
495
|
+
}
|
|
496
|
+
else {
|
|
497
|
+
translateX = destLeft + (destWidth / 2);
|
|
498
|
+
translateY = destTop + (destHeight / 2);
|
|
499
|
+
}
|
|
500
|
+
ctx.translate(translateX, translateY);
|
|
379
501
|
ctx.rotate(rotationAngle);
|
|
380
|
-
ctx.translate(-
|
|
502
|
+
ctx.translate(-translateX, -translateY);
|
|
381
503
|
};
|
|
382
504
|
Draw.prototype.setDragLimit = function () {
|
|
383
505
|
var parent = this.parent;
|
|
384
506
|
var actPoint = parent.activeObj.activePoint;
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
507
|
+
var _a = parent.activeObj, shape = _a.shape, rotatedAngle = _a.rotatedAngle;
|
|
508
|
+
if (actPoint && shape !== 'image' && shape !== 'line' && rotatedAngle === 0) {
|
|
509
|
+
var _b = parent.img, destLeft = _b.destLeft, destTop = _b.destTop, destWidth = _b.destWidth, destHeight = _b.destHeight;
|
|
510
|
+
if (actPoint.startX < destLeft) {
|
|
511
|
+
actPoint.startX = destLeft;
|
|
512
|
+
actPoint.endX = Math.min(actPoint.startX + actPoint.width, destLeft + destWidth);
|
|
389
513
|
}
|
|
390
|
-
else if (actPoint.endX >
|
|
391
|
-
actPoint.endX =
|
|
392
|
-
actPoint.startX = actPoint.endX - actPoint.width;
|
|
514
|
+
else if (actPoint.endX > destLeft + destWidth) {
|
|
515
|
+
actPoint.endX = destLeft + destWidth;
|
|
516
|
+
actPoint.startX = Math.max(actPoint.endX - actPoint.width, destLeft);
|
|
393
517
|
}
|
|
394
|
-
if (actPoint.startY <
|
|
395
|
-
actPoint.startY =
|
|
518
|
+
if (actPoint.startY < destTop) {
|
|
519
|
+
actPoint.startY = destTop;
|
|
396
520
|
}
|
|
397
|
-
else if (actPoint.endY >
|
|
398
|
-
actPoint.endY =
|
|
399
|
-
actPoint.startY = actPoint.endY - actPoint.height;
|
|
521
|
+
else if (actPoint.endY > destTop + destHeight) {
|
|
522
|
+
actPoint.endY = destTop + destHeight;
|
|
523
|
+
actPoint.startY = Math.max(actPoint.endY - actPoint.height, destTop);
|
|
400
524
|
}
|
|
401
525
|
parent.activeObj = this.updateWidthHeight(parent.activeObj);
|
|
402
526
|
}
|
|
@@ -408,26 +532,31 @@ var Draw = /** @class */ (function () {
|
|
|
408
532
|
var y;
|
|
409
533
|
var width;
|
|
410
534
|
var height;
|
|
535
|
+
var canvasWidth = parent.lowerCanvas.clientWidth;
|
|
536
|
+
var canvasHeight = parent.lowerCanvas.clientHeight;
|
|
537
|
+
var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
|
|
411
538
|
if (parent.transform.zoomFactor > 0 && this.currSelPoint) {
|
|
412
539
|
var activeObj = extend({}, parent.activeObj, {}, true);
|
|
413
540
|
this.drawCustomSelection('crop-custom', null, null, null, null);
|
|
541
|
+
if (parent.transform.straighten !== 0) {
|
|
542
|
+
actPoint = parent.activeObj.activePoint;
|
|
543
|
+
}
|
|
414
544
|
if (parent.transform.degree % 90 === 0 && parent.transform.degree % 180 !== 0) {
|
|
415
|
-
width =
|
|
416
|
-
parent.activeObj.activePoint.width : parent.activeObj.activePoint.height;
|
|
545
|
+
width = actPoint.width < actPoint.height ? actPoint.width : actPoint.height;
|
|
417
546
|
height = width;
|
|
418
547
|
}
|
|
419
548
|
else {
|
|
420
|
-
if (
|
|
549
|
+
if (destLeft + destLeft + destWidth <= canvasWidth) {
|
|
421
550
|
width = actPoint.width;
|
|
422
551
|
}
|
|
423
552
|
else {
|
|
424
|
-
width = parent.
|
|
553
|
+
width = parent.transform.straighten === 0 ? canvasWidth - destLeft : actPoint.width;
|
|
425
554
|
}
|
|
426
|
-
if (
|
|
555
|
+
if (destTop + destTop + destHeight <= canvasHeight) {
|
|
427
556
|
height = actPoint.height;
|
|
428
557
|
}
|
|
429
558
|
else {
|
|
430
|
-
height = parent.
|
|
559
|
+
height = parent.transform.straighten === 0 ? canvasHeight - destTop : actPoint.height;
|
|
431
560
|
}
|
|
432
561
|
}
|
|
433
562
|
parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
|
|
@@ -437,20 +566,20 @@ var Draw = /** @class */ (function () {
|
|
|
437
566
|
parent.currObjType.isCustomCrop = false;
|
|
438
567
|
}
|
|
439
568
|
else {
|
|
440
|
-
width =
|
|
441
|
-
height =
|
|
442
|
-
if (
|
|
443
|
-
width +=
|
|
569
|
+
width = destWidth;
|
|
570
|
+
height = destHeight;
|
|
571
|
+
if (destLeft < 0) {
|
|
572
|
+
width += destLeft;
|
|
444
573
|
}
|
|
445
|
-
if (
|
|
446
|
-
height +=
|
|
574
|
+
if (destTop < 0) {
|
|
575
|
+
height += destTop;
|
|
447
576
|
}
|
|
448
577
|
if (parent.currObjType.shape.toLowerCase() !== 'crop-square' && parent.currObjType.shape.toLowerCase() !== 'crop-circle') {
|
|
449
|
-
if (
|
|
450
|
-
width -= (
|
|
578
|
+
if (destLeft + destWidth > parent.lowerCanvas.width) {
|
|
579
|
+
width -= (destLeft + destWidth - parent.lowerCanvas.width);
|
|
451
580
|
}
|
|
452
|
-
if (
|
|
453
|
-
height -= (
|
|
581
|
+
if (destTop + destHeight > parent.lowerCanvas.height) {
|
|
582
|
+
height -= (destTop + destHeight - parent.lowerCanvas.height);
|
|
454
583
|
}
|
|
455
584
|
}
|
|
456
585
|
}
|
|
@@ -467,25 +596,21 @@ var Draw = /** @class */ (function () {
|
|
|
467
596
|
actPoint.startY = 7.5;
|
|
468
597
|
actPoint.endY = parent.lowerCanvas.height - 7.5;
|
|
469
598
|
}
|
|
470
|
-
if (width ===
|
|
471
|
-
actPoint.startX +=
|
|
472
|
-
actPoint.startY +=
|
|
473
|
-
|
|
474
|
-
actPoint.
|
|
475
|
-
actPoint.endY +=
|
|
476
|
-
parent.img.destTop;
|
|
599
|
+
if (width === destWidth && height === destHeight) {
|
|
600
|
+
actPoint.startX += destLeft;
|
|
601
|
+
actPoint.startY += destTop;
|
|
602
|
+
actPoint.endX += destLeft;
|
|
603
|
+
actPoint.endY += destTop;
|
|
477
604
|
}
|
|
478
605
|
if (parent.lowerCanvas.width > parent.lowerCanvas.height) {
|
|
479
606
|
actPoint.height = actPoint.endY - actPoint.startY;
|
|
480
607
|
actPoint.width = actPoint.height;
|
|
481
|
-
actPoint.endX = actPoint.startX +
|
|
482
|
-
actPoint.width;
|
|
608
|
+
actPoint.endX = actPoint.startX + actPoint.width;
|
|
483
609
|
}
|
|
484
610
|
else {
|
|
485
611
|
actPoint.width = actPoint.endX - actPoint.startX;
|
|
486
612
|
actPoint.height = actPoint.width;
|
|
487
|
-
actPoint.endY = actPoint.startY +
|
|
488
|
-
actPoint.height;
|
|
613
|
+
actPoint.endY = actPoint.startY + actPoint.height;
|
|
489
614
|
}
|
|
490
615
|
break;
|
|
491
616
|
case 'crop-3:2':
|
|
@@ -508,117 +633,205 @@ var Draw = /** @class */ (function () {
|
|
|
508
633
|
x = 16;
|
|
509
634
|
y = 9;
|
|
510
635
|
break;
|
|
636
|
+
case 'crop-2:3':
|
|
637
|
+
x = 2;
|
|
638
|
+
y = 3;
|
|
639
|
+
break;
|
|
640
|
+
case 'crop-3:4':
|
|
641
|
+
x = 3;
|
|
642
|
+
y = 4;
|
|
643
|
+
break;
|
|
644
|
+
case 'crop-4:5':
|
|
645
|
+
x = 4;
|
|
646
|
+
y = 5;
|
|
647
|
+
break;
|
|
648
|
+
case 'crop-5:7':
|
|
649
|
+
x = 5;
|
|
650
|
+
y = 7;
|
|
651
|
+
break;
|
|
652
|
+
case 'crop-9:16':
|
|
653
|
+
x = 9;
|
|
654
|
+
y = 16;
|
|
655
|
+
break;
|
|
511
656
|
}
|
|
512
657
|
if (x !== undefined && y !== undefined) {
|
|
513
658
|
parent.notify('selection', { prop: 'calcShapeRatio', onPropertyChange: false,
|
|
514
659
|
value: { x: x, y: y, imgWidth: width, imgHeight: height } });
|
|
515
|
-
if (width ===
|
|
660
|
+
if (width === destWidth && height === destHeight) {
|
|
516
661
|
this.updatePoints();
|
|
517
662
|
}
|
|
518
663
|
actPoint = parent.activeObj.activePoint;
|
|
519
664
|
}
|
|
520
|
-
if (actPoint.startX <
|
|
521
|
-
var diff = (
|
|
665
|
+
if (actPoint.startX < destLeft) {
|
|
666
|
+
var diff = (destLeft - actPoint.startX) + 7.5;
|
|
522
667
|
actPoint.startX += diff;
|
|
523
668
|
actPoint.endX += diff;
|
|
524
669
|
}
|
|
525
|
-
if (actPoint.startY <
|
|
526
|
-
var diff = (
|
|
670
|
+
if (actPoint.startY < destTop) {
|
|
671
|
+
var diff = (destTop - actPoint.startY) + 7.5;
|
|
527
672
|
actPoint.startY += diff;
|
|
528
673
|
actPoint.endY += diff;
|
|
529
674
|
}
|
|
530
675
|
parent.activeObj = this.updateWidthHeight(parent.activeObj);
|
|
531
676
|
this.adjToCenter();
|
|
677
|
+
this.enlargeToImg();
|
|
678
|
+
if (parent.transform.straighten !== 0) {
|
|
679
|
+
this.adjToStraighten();
|
|
680
|
+
this.updateActiveObject(parent.activeObj.activePoint, parent.activeObj);
|
|
681
|
+
}
|
|
682
|
+
var object = { isIntersect: null, arr: null };
|
|
683
|
+
var count = 0;
|
|
684
|
+
actPoint = parent.activeObj.activePoint;
|
|
685
|
+
if (parent.transform.straighten !== 0) {
|
|
686
|
+
while (this.isLinesIntersect(object) && count < 100) {
|
|
687
|
+
count++;
|
|
688
|
+
var diff = (actPoint.width * 1) / 100;
|
|
689
|
+
actPoint.startX += diff;
|
|
690
|
+
actPoint.endX -= diff;
|
|
691
|
+
diff = (actPoint.height * 1) / 100;
|
|
692
|
+
actPoint.startY += diff;
|
|
693
|
+
actPoint.endY -= diff;
|
|
694
|
+
actPoint.width = actPoint.endX - actPoint.startX;
|
|
695
|
+
actPoint.height = actPoint.endY - actPoint.startY;
|
|
696
|
+
this.updateActiveObject(actPoint, parent.activeObj);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
this.straightenInitZoom = parent.transform.zoomFactor;
|
|
700
|
+
this.straightenActObj = extend({}, parent.activeObj, {}, true);
|
|
701
|
+
parent.notify('draw', { prop: 'resetStraightenDestPoints' });
|
|
702
|
+
parent.notify('draw', { prop: 'setDestForStraighten' });
|
|
532
703
|
};
|
|
533
704
|
Draw.prototype.adjToCenter = function () {
|
|
534
705
|
var parent = this.parent;
|
|
535
|
-
var
|
|
536
|
-
|
|
537
|
-
var
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
if (
|
|
544
|
-
var diff = ((
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
}
|
|
548
|
-
else if (
|
|
549
|
-
var diff = (
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
}
|
|
553
|
-
if (
|
|
554
|
-
var diff = ((
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
}
|
|
558
|
-
else if (
|
|
559
|
-
var diff = (
|
|
560
|
-
|
|
561
|
-
|
|
706
|
+
var actPoint = parent.activeObj.activePoint;
|
|
707
|
+
var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
|
|
708
|
+
var diffX = ((parent.lowerCanvas.width) / 2) - (actPoint.endX - actPoint.width / 2);
|
|
709
|
+
var diffY = ((parent.lowerCanvas.height) / 2) - (actPoint.endY - actPoint.height / 2);
|
|
710
|
+
actPoint.startX += diffX;
|
|
711
|
+
actPoint.endX += diffX;
|
|
712
|
+
actPoint.startY += diffY;
|
|
713
|
+
actPoint.endY += diffY;
|
|
714
|
+
if (actPoint.startX < (destLeft >= 7.5 ? destLeft : 7.5)) {
|
|
715
|
+
var diff = ((destLeft >= 7.5 ? destLeft : 0) - actPoint.startX);
|
|
716
|
+
actPoint.startX += diff;
|
|
717
|
+
actPoint.endX += diff;
|
|
718
|
+
}
|
|
719
|
+
else if (actPoint.endX > destLeft + destWidth) {
|
|
720
|
+
var diff = (actPoint.endX - (destLeft + destWidth));
|
|
721
|
+
actPoint.startX -= diff;
|
|
722
|
+
actPoint.endX -= diff;
|
|
723
|
+
}
|
|
724
|
+
if (actPoint.startY < (destTop >= 7.5 ? destTop : 7.5)) {
|
|
725
|
+
var diff = ((destTop >= 7.5 ? destTop : 0) - actPoint.startY);
|
|
726
|
+
actPoint.startY += diff;
|
|
727
|
+
actPoint.endY += diff;
|
|
728
|
+
}
|
|
729
|
+
else if (actPoint.endY > destTop + destHeight) {
|
|
730
|
+
var diff = (actPoint.endY - (destTop + destHeight));
|
|
731
|
+
actPoint.startY -= diff;
|
|
732
|
+
actPoint.endY -= diff;
|
|
733
|
+
}
|
|
734
|
+
};
|
|
735
|
+
Draw.prototype.enlargeToImg = function () {
|
|
736
|
+
var parent = this.parent;
|
|
737
|
+
if (parent.transform.straighten === 0) {
|
|
738
|
+
return;
|
|
739
|
+
}
|
|
740
|
+
if (parent.transform.degree % 90 === 0 && parent.transform.degree % 180 !== 0) {
|
|
741
|
+
var actPoint = parent.activeObj.activePoint;
|
|
742
|
+
var tempActPoint = extend({}, actPoint, {}, true);
|
|
743
|
+
var count = 0;
|
|
744
|
+
while (true) {
|
|
745
|
+
// Increase width and height by 5% from center to enlarge the crop selection
|
|
746
|
+
count++;
|
|
747
|
+
var diff = (actPoint.width * 5) / 100;
|
|
748
|
+
actPoint.startX -= diff;
|
|
749
|
+
actPoint.endX += diff;
|
|
750
|
+
diff = (actPoint.height * 5) / 100;
|
|
751
|
+
actPoint.startY -= diff;
|
|
752
|
+
actPoint.endY += diff;
|
|
753
|
+
actPoint.width = actPoint.endX - actPoint.startX;
|
|
754
|
+
actPoint.height = actPoint.endY - actPoint.startY;
|
|
755
|
+
this.updateActiveObject(actPoint, parent.activeObj);
|
|
756
|
+
var object = { isIntersect: null, arr: null };
|
|
757
|
+
this.updateImgCanvasPoints();
|
|
758
|
+
this.isLinesIntersect(object);
|
|
759
|
+
if (object['arr'][0] || object['arr'][1] || object['arr'][2] || object['arr'][3] ||
|
|
760
|
+
actPoint.startX < 7.5 || actPoint.startY < 7.5 || count === 100) {
|
|
761
|
+
actPoint = extend({}, tempActPoint, {}, true);
|
|
762
|
+
diff = (actPoint.width * 1) / 100;
|
|
763
|
+
actPoint.startX += diff;
|
|
764
|
+
actPoint.endX -= diff;
|
|
765
|
+
diff = (actPoint.height * 1) / 100;
|
|
766
|
+
actPoint.startY += diff;
|
|
767
|
+
actPoint.endY -= diff;
|
|
768
|
+
actPoint.width = actPoint.endX - actPoint.startX;
|
|
769
|
+
actPoint.height = actPoint.endY - actPoint.startY;
|
|
770
|
+
this.updateActiveObject(actPoint, parent.activeObj);
|
|
771
|
+
break;
|
|
772
|
+
}
|
|
773
|
+
tempActPoint = extend({}, actPoint, {}, true);
|
|
774
|
+
}
|
|
562
775
|
}
|
|
563
776
|
};
|
|
564
777
|
Draw.prototype.updateActiveObject = function (actPoint, obj, isMouseMove, x, y) {
|
|
565
|
-
|
|
566
|
-
|
|
778
|
+
var parent = this.parent;
|
|
779
|
+
actPoint = actPoint ? actPoint : extend({}, parent.activeObj.activePoint, {}, true);
|
|
780
|
+
obj = obj ? obj : extend({}, parent.activeObj, {}, true);
|
|
567
781
|
actPoint.width = actPoint.endX - actPoint.startX;
|
|
568
782
|
actPoint.height = actPoint.endY - actPoint.startY;
|
|
783
|
+
var startX = actPoint.startX, startY = actPoint.startY, endX = actPoint.endX, endY = actPoint.endY, width = actPoint.width, height = actPoint.height;
|
|
569
784
|
x = x ? x : 0;
|
|
570
785
|
y = y ? y : 0;
|
|
571
|
-
var horCircleWidth =
|
|
572
|
-
var verCircleHeight =
|
|
786
|
+
var horCircleWidth = width / 2;
|
|
787
|
+
var verCircleHeight = height / 2;
|
|
573
788
|
var radius = 7.5;
|
|
574
|
-
obj.horTopLine = { startX:
|
|
575
|
-
endX:
|
|
576
|
-
obj.horBottomLine = { startX:
|
|
577
|
-
endX:
|
|
578
|
-
obj.verLeftLine = { startX:
|
|
579
|
-
endX:
|
|
580
|
-
obj.verRightLine = { startX:
|
|
581
|
-
endX:
|
|
582
|
-
obj.topLeftCircle = { startX:
|
|
789
|
+
obj.horTopLine = { startX: startX + x, startY: startY - y,
|
|
790
|
+
endX: endX + x, endY: endY + y };
|
|
791
|
+
obj.horBottomLine = { startX: startX - x, startY: endY - y,
|
|
792
|
+
endX: endX - x, endY: endY + y };
|
|
793
|
+
obj.verLeftLine = { startX: startX + x, startY: startY - y,
|
|
794
|
+
endX: startX - y, endY: endY - y };
|
|
795
|
+
obj.verRightLine = { startX: endX + x, startY: startY + y,
|
|
796
|
+
endX: endX - x, endY: endY + y };
|
|
797
|
+
obj.topLeftCircle = { startX: startX, startY: startY,
|
|
583
798
|
radius: obj.horTopLine.endX ? (radius) : 0 };
|
|
584
|
-
obj.topCenterCircle = { startX:
|
|
799
|
+
obj.topCenterCircle = { startX: startX + horCircleWidth, startY: startY,
|
|
585
800
|
radius: obj.horTopLine.endX ? (radius) : 0 };
|
|
586
|
-
obj.topRightCircle = { startX:
|
|
801
|
+
obj.topRightCircle = { startX: endX, startY: startY,
|
|
587
802
|
radius: obj.horTopLine.endX ? (radius) : 0 };
|
|
588
|
-
obj.centerLeftCircle = { startX:
|
|
803
|
+
obj.centerLeftCircle = { startX: startX, startY: startY + verCircleHeight,
|
|
589
804
|
radius: obj.horTopLine.endX ? (radius) : 0 };
|
|
590
|
-
obj.centerRightCircle = { startX:
|
|
805
|
+
obj.centerRightCircle = { startX: endX, startY: startY + verCircleHeight,
|
|
591
806
|
radius: obj.horTopLine.endX ? (radius) : 0 };
|
|
592
|
-
obj.bottomLeftCircle = { startX:
|
|
807
|
+
obj.bottomLeftCircle = { startX: startX, startY: endY,
|
|
593
808
|
radius: obj.horTopLine.endX ? (radius) : 0 };
|
|
594
|
-
obj.bottomCenterCircle = { startX:
|
|
809
|
+
obj.bottomCenterCircle = { startX: startX + horCircleWidth, startY: endY,
|
|
595
810
|
radius: obj.horTopLine.endX ? (radius) : 0 };
|
|
596
|
-
obj.bottomRightCircle = { startX:
|
|
811
|
+
obj.bottomRightCircle = { startX: endX, startY: endY,
|
|
597
812
|
radius: obj.horTopLine.endX ? (radius) : 0 };
|
|
598
813
|
if (obj.rotatedAngle === 0) {
|
|
599
814
|
obj.rotationCirclePoint = { x: obj.bottomCenterCircle.startX,
|
|
600
815
|
y: obj.bottomCenterCircle.startY + 25 };
|
|
601
|
-
obj.rotationCirclePoint.ratioX = (obj.rotationCirclePoint.x -
|
|
602
|
-
obj.rotationCirclePoint.ratioY = (obj.rotationCirclePoint.y -
|
|
816
|
+
obj.rotationCirclePoint.ratioX = (obj.rotationCirclePoint.x - parent.img.destLeft) / parent.img.destWidth;
|
|
817
|
+
obj.rotationCirclePoint.ratioY = (obj.rotationCirclePoint.y - parent.img.destTop) / parent.img.destHeight;
|
|
603
818
|
}
|
|
604
819
|
obj.activePoint = actPoint;
|
|
605
820
|
if (isNullOrUndefined(isMouseMove)) {
|
|
606
|
-
|
|
821
|
+
parent.activeObj = extend({}, obj, {}, true);
|
|
607
822
|
}
|
|
608
823
|
};
|
|
609
824
|
Draw.prototype.drawOuterSelection = function (canvasDraw, isCropCircle) {
|
|
610
825
|
var splitWords;
|
|
611
826
|
var parent = this.parent;
|
|
612
827
|
var actPoint = parent.activeObj.activePoint;
|
|
828
|
+
var actObj = parent.activeObj;
|
|
613
829
|
canvasDraw.lineWidth = (0.5);
|
|
614
|
-
|
|
615
|
-
|
|
830
|
+
var tempObj = extend({}, actObj, {}, true);
|
|
831
|
+
if (actObj.shape) {
|
|
832
|
+
splitWords = actObj.shape.split('-');
|
|
616
833
|
}
|
|
617
|
-
|
|
618
|
-
if (parent.activeObj.shape !== undefined) {
|
|
619
|
-
splitWords = parent.activeObj.shape.split('-');
|
|
620
|
-
}
|
|
621
|
-
if (((splitWords !== undefined && splitWords[0] === 'crop') || parent.activeObj.shape === undefined) && !isCropCircle) {
|
|
834
|
+
if (((splitWords && splitWords[0] === 'crop') || actObj.shape === undefined) && !isCropCircle) {
|
|
622
835
|
this.upperContext.fillStyle = 'rgb(0, 0, 0, 0.25)';
|
|
623
836
|
this.upperContext.fillRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
|
|
624
837
|
this.upperContext.clearRect(actPoint.startX, actPoint.startY, actPoint.width, actPoint.height);
|
|
@@ -635,79 +848,56 @@ var Draw = /** @class */ (function () {
|
|
|
635
848
|
if (degree < 0) {
|
|
636
849
|
degree = 360 + degree;
|
|
637
850
|
}
|
|
638
|
-
if (
|
|
851
|
+
if (actObj.shape === 'arrow' || actObj.shape === 'line') {
|
|
639
852
|
canvasDraw.beginPath();
|
|
640
853
|
canvasDraw.moveTo(actPoint.startX, actPoint.startY);
|
|
641
854
|
canvasDraw.lineTo(actPoint.endX, actPoint.endY);
|
|
642
855
|
canvasDraw.stroke();
|
|
643
856
|
}
|
|
644
|
-
else if (
|
|
857
|
+
else if (actObj.shape === 'path') {
|
|
645
858
|
canvasDraw.beginPath();
|
|
646
859
|
var activeObj = extend({}, parent.activeObj, {}, true);
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
860
|
+
if (activeObj.pointColl[0]) {
|
|
861
|
+
canvasDraw.moveTo(activeObj.pointColl[0].x, activeObj.pointColl[0].y);
|
|
862
|
+
if (activeObj.pointColl.length > 1) {
|
|
863
|
+
for (var i = 1, len = activeObj.pointColl.length; i < len; i++) {
|
|
864
|
+
actPoint.endX = activeObj.pointColl[i].x;
|
|
865
|
+
actPoint.endY = activeObj.pointColl[i].y;
|
|
866
|
+
canvasDraw.lineTo(actPoint.endX, actPoint.endY);
|
|
867
|
+
}
|
|
653
868
|
}
|
|
654
869
|
}
|
|
655
870
|
var obj = { shape: null };
|
|
656
871
|
parent.notify('selection', { prop: 'getCurrentDrawingShape', value: { obj: obj } });
|
|
657
872
|
if (obj['shape'] === 'path') {
|
|
658
|
-
parent.activeObj = activeObj;
|
|
873
|
+
parent.activeObj = actObj = activeObj;
|
|
659
874
|
}
|
|
660
875
|
canvasDraw.lineTo(actPoint.endX, actPoint.endY);
|
|
661
876
|
canvasDraw.stroke();
|
|
662
877
|
}
|
|
663
878
|
else {
|
|
664
|
-
|
|
665
|
-
canvasDraw.rect(tempObj.activePoint.startX, tempObj.activePoint.startY, tempObj.activePoint.width, tempObj.activePoint.height);
|
|
666
|
-
canvasDraw.stroke();
|
|
667
|
-
canvasDraw.closePath();
|
|
668
|
-
if (parent.selectionSettings.showCircle) {
|
|
669
|
-
var strokeColor = canvasDraw.strokeStyle;
|
|
670
|
-
var fillColor = canvasDraw.fillStyle;
|
|
671
|
-
canvasDraw.strokeStyle = parent.selectionSettings.strokeColor;
|
|
672
|
-
canvasDraw.fillStyle = parent.selectionSettings.fillColor;
|
|
673
|
-
canvasDraw.lineWidth *= 2;
|
|
674
|
-
canvasDraw.beginPath();
|
|
675
|
-
canvasDraw.moveTo(tempObj.topLeftCircle.startX, tempObj.topLeftCircle.startY);
|
|
676
|
-
canvasDraw.arc(tempObj.topLeftCircle.startX, tempObj.topLeftCircle.startY, tempObj.topLeftCircle.radius, 0, 2 * Math.PI);
|
|
677
|
-
canvasDraw.moveTo(tempObj.topRightCircle.startX, tempObj.topRightCircle.startY);
|
|
678
|
-
canvasDraw.arc(tempObj.topRightCircle.startX, tempObj.topRightCircle.startY, tempObj.topRightCircle.radius, 0, 2 * Math.PI);
|
|
679
|
-
canvasDraw.moveTo(tempObj.bottomLeftCircle.startX, tempObj.bottomLeftCircle.startY);
|
|
680
|
-
canvasDraw.arc(tempObj.bottomLeftCircle.startX, tempObj.bottomLeftCircle.startY, tempObj.bottomLeftCircle.radius, 0, 2 * Math.PI);
|
|
681
|
-
canvasDraw.moveTo(tempObj.bottomRightCircle.startX, tempObj.bottomRightCircle.startY);
|
|
682
|
-
canvasDraw.arc(tempObj.bottomRightCircle.startX, tempObj.bottomRightCircle.startY, tempObj.bottomRightCircle.radius, 0, 2 * Math.PI);
|
|
683
|
-
canvasDraw.stroke();
|
|
684
|
-
canvasDraw.fill();
|
|
685
|
-
canvasDraw.closePath();
|
|
686
|
-
canvasDraw.lineWidth /= 2;
|
|
687
|
-
canvasDraw.strokeStyle = strokeColor;
|
|
688
|
-
canvasDraw.fillStyle = fillColor;
|
|
689
|
-
}
|
|
879
|
+
this.drawCornerCircles(canvasDraw);
|
|
690
880
|
}
|
|
691
881
|
if (parent.selectionSettings.showCircle && (splitWords === undefined || splitWords[0] !== 'crop')) {
|
|
692
882
|
var strokeColor = canvasDraw.strokeStyle;
|
|
693
883
|
var fillColor = canvasDraw.fillStyle;
|
|
694
884
|
canvasDraw.strokeStyle = parent.selectionSettings.strokeColor;
|
|
695
885
|
canvasDraw.fillStyle = parent.selectionSettings.fillColor;
|
|
696
|
-
if (
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
886
|
+
if (actObj.shape === 'text') {
|
|
887
|
+
canvasDraw.lineWidth *= 2;
|
|
888
|
+
canvasDraw.beginPath();
|
|
889
|
+
this.drawRotationArcLine(canvasDraw);
|
|
890
|
+
canvasDraw.lineTo(actObj.rotationCirclePoint.x, actObj.rotationCirclePoint.y);
|
|
891
|
+
canvasDraw.stroke();
|
|
892
|
+
canvasDraw.fill();
|
|
893
|
+
canvasDraw.closePath();
|
|
894
|
+
canvasDraw.beginPath();
|
|
895
|
+
canvasDraw.moveTo(actObj.rotationCirclePoint.x, actObj.rotationCirclePoint.y);
|
|
896
|
+
canvasDraw.arc(actObj.rotationCirclePoint.x, actObj.rotationCirclePoint.y, actObj.bottomCenterCircle.radius, 0, 2 * Math.PI);
|
|
897
|
+
canvasDraw.stroke();
|
|
898
|
+
canvasDraw.fill();
|
|
899
|
+
canvasDraw.closePath();
|
|
900
|
+
canvasDraw.lineWidth /= 2;
|
|
711
901
|
}
|
|
712
902
|
else {
|
|
713
903
|
this.drawCenterCircles(canvasDraw);
|
|
@@ -715,7 +905,7 @@ var Draw = /** @class */ (function () {
|
|
|
715
905
|
canvasDraw.strokeStyle = strokeColor;
|
|
716
906
|
canvasDraw.fillStyle = fillColor;
|
|
717
907
|
}
|
|
718
|
-
tempObj.rotationCircleLine =
|
|
908
|
+
tempObj.rotationCircleLine = actObj.rotationCircleLine;
|
|
719
909
|
parent.activeObj = extend({}, tempObj, {}, true);
|
|
720
910
|
};
|
|
721
911
|
Draw.prototype.drawArrowHead = function (canvasDraw, isStartHead) {
|
|
@@ -751,6 +941,8 @@ var Draw = /** @class */ (function () {
|
|
|
751
941
|
Draw.prototype.drawShapeObj = function (canvas, shape, saveContext, isPreventSelection) {
|
|
752
942
|
var parent = this.parent;
|
|
753
943
|
var actPoint = parent.activeObj.activePoint;
|
|
944
|
+
var actObj = parent.activeObj;
|
|
945
|
+
var _a = actObj.strokeSettings, strokeColor = _a.strokeColor, fillColor = _a.fillColor, strokeWidth = _a.strokeWidth;
|
|
754
946
|
var currentShape = shape !== undefined ? shape : parent.currObjType.shape;
|
|
755
947
|
parent.currObjType.shape = currentShape;
|
|
756
948
|
var canvasDraw;
|
|
@@ -763,17 +955,17 @@ var Draw = /** @class */ (function () {
|
|
|
763
955
|
else if (saveContext) {
|
|
764
956
|
canvasDraw = saveContext;
|
|
765
957
|
}
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
958
|
+
var shapeType = parent.currObjType.shape.toLowerCase();
|
|
959
|
+
var shapeColl = ['rectangle', 'ellipse', 'line', 'arrow', 'path', 'image'];
|
|
960
|
+
if (shapeColl.indexOf(shapeType) !== -1) {
|
|
961
|
+
actObj.shape = parent.currObjType.shape;
|
|
770
962
|
}
|
|
771
|
-
canvasDraw.strokeStyle =
|
|
963
|
+
canvasDraw.strokeStyle = strokeColor;
|
|
772
964
|
if (shape === 'text' || shape === 'freehanddraw') {
|
|
773
|
-
canvasDraw.fillStyle =
|
|
965
|
+
canvasDraw.fillStyle = strokeColor;
|
|
774
966
|
}
|
|
775
967
|
else {
|
|
776
|
-
canvasDraw.fillStyle =
|
|
968
|
+
canvasDraw.fillStyle = fillColor;
|
|
777
969
|
}
|
|
778
970
|
var horLineWidth = actPoint.width / 3;
|
|
779
971
|
var verLineHeight = actPoint.height / 3;
|
|
@@ -795,12 +987,12 @@ var Draw = /** @class */ (function () {
|
|
|
795
987
|
selectionHeight = Math.abs(selectionHeight);
|
|
796
988
|
canvasDraw.beginPath();
|
|
797
989
|
canvasDraw.ellipse(actPoint.startX + (selectionWidth / 2), actPoint.startY + (selectionHeight / 2), selectionWidth / 2, selectionHeight / 2, 0, 0, 2 * Math.PI, false);
|
|
798
|
-
if (
|
|
799
|
-
canvasDraw.fillStyle =
|
|
990
|
+
if (fillColor !== '') {
|
|
991
|
+
canvasDraw.fillStyle = fillColor;
|
|
800
992
|
canvasDraw.fill();
|
|
801
993
|
}
|
|
802
|
-
canvasDraw.ellipse(actPoint.startX + (selectionWidth / 2), actPoint.startY + (selectionHeight / 2), Math.abs((selectionWidth / 2) - (
|
|
803
|
-
canvasDraw.fillStyle =
|
|
994
|
+
canvasDraw.ellipse(actPoint.startX + (selectionWidth / 2), actPoint.startY + (selectionHeight / 2), Math.abs((selectionWidth / 2) - (strokeWidth)), Math.abs((selectionHeight / 2) - (strokeWidth)), 0, 0, 2 * Math.PI, false);
|
|
995
|
+
canvasDraw.fillStyle = strokeColor;
|
|
804
996
|
canvasDraw.fill('evenodd');
|
|
805
997
|
canvasDraw.closePath();
|
|
806
998
|
if (isNullOrUndefined(isPreventSelection) && canvasDraw === this.upperContext) {
|
|
@@ -820,28 +1012,28 @@ var Draw = /** @class */ (function () {
|
|
|
820
1012
|
}
|
|
821
1013
|
break;
|
|
822
1014
|
case 'arrow':
|
|
823
|
-
if (
|
|
1015
|
+
if (actObj.shapeDegree === 0) {
|
|
824
1016
|
degree = parent.transform.degree;
|
|
825
1017
|
}
|
|
826
1018
|
else {
|
|
827
|
-
degree = parent.transform.degree -
|
|
1019
|
+
degree = parent.transform.degree - actObj.shapeDegree;
|
|
828
1020
|
}
|
|
829
1021
|
if (degree < 0) {
|
|
830
1022
|
degree = 360 + degree;
|
|
831
1023
|
}
|
|
832
1024
|
canvasDraw.fillStyle = canvasDraw.strokeStyle;
|
|
833
|
-
if (isNullOrUndefined(
|
|
834
|
-
|
|
1025
|
+
if (isNullOrUndefined(actObj.triangleDirection)) {
|
|
1026
|
+
actObj.triangleDirection = 'right';
|
|
835
1027
|
}
|
|
836
|
-
if (isNullOrUndefined(
|
|
837
|
-
|
|
1028
|
+
if (isNullOrUndefined(actObj.start)) {
|
|
1029
|
+
actObj.start = 'none';
|
|
838
1030
|
}
|
|
839
|
-
if (isNullOrUndefined(
|
|
840
|
-
|
|
1031
|
+
if (isNullOrUndefined(actObj.end)) {
|
|
1032
|
+
actObj.end = 'arrowSolid';
|
|
841
1033
|
}
|
|
842
1034
|
this.drawArrowHead(canvasDraw, true);
|
|
843
1035
|
this.drawArrowHead(canvasDraw, false);
|
|
844
|
-
if (
|
|
1036
|
+
if (actObj.end === 'none') {
|
|
845
1037
|
this.shapeLine(canvasDraw, actPoint.startX, actPoint.startY, actPoint.endX, actPoint.endY);
|
|
846
1038
|
}
|
|
847
1039
|
canvasDraw.fillStyle = tempFillStyle;
|
|
@@ -883,7 +1075,7 @@ var Draw = /** @class */ (function () {
|
|
|
883
1075
|
this.shapeLine(canvasDraw, actPoint.startX, actPoint.startY, actPoint.endX, actPoint.endY);
|
|
884
1076
|
}
|
|
885
1077
|
}
|
|
886
|
-
parent.activeObj = activeObj;
|
|
1078
|
+
parent.activeObj = actObj = activeObj;
|
|
887
1079
|
}
|
|
888
1080
|
else {
|
|
889
1081
|
this.shapeLine(canvasDraw, actPoint.startX, actPoint.startY, actPoint.endX, actPoint.endY);
|
|
@@ -922,29 +1114,63 @@ var Draw = /** @class */ (function () {
|
|
|
922
1114
|
};
|
|
923
1115
|
Draw.prototype.updatePoints = function () {
|
|
924
1116
|
var parent = this.parent;
|
|
925
|
-
parent.activeObj.activePoint
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
1117
|
+
var actPoint = parent.activeObj.activePoint;
|
|
1118
|
+
var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop;
|
|
1119
|
+
actPoint.startX += destLeft;
|
|
1120
|
+
actPoint.startY += destTop;
|
|
1121
|
+
actPoint.endX += destLeft;
|
|
1122
|
+
actPoint.endY += destTop;
|
|
929
1123
|
parent.activeObj = this.updateWidthHeight(parent.activeObj);
|
|
930
1124
|
};
|
|
931
1125
|
Draw.prototype.updateWidthHeight = function (obj) {
|
|
932
|
-
obj.activePoint.
|
|
933
|
-
obj.activePoint.
|
|
1126
|
+
var _a = obj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
|
|
1127
|
+
obj.activePoint.width = endX - startX;
|
|
1128
|
+
obj.activePoint.height = endY - startY;
|
|
934
1129
|
return obj;
|
|
935
1130
|
};
|
|
1131
|
+
Draw.prototype.drawCornerCircles = function (canvasDraw) {
|
|
1132
|
+
var parent = this.parent;
|
|
1133
|
+
var tempObj = parent.activeObj;
|
|
1134
|
+
canvasDraw.beginPath();
|
|
1135
|
+
canvasDraw.rect(tempObj.activePoint.startX, tempObj.activePoint.startY, tempObj.activePoint.width, tempObj.activePoint.height);
|
|
1136
|
+
canvasDraw.stroke();
|
|
1137
|
+
canvasDraw.closePath();
|
|
1138
|
+
if (parent.selectionSettings.showCircle) {
|
|
1139
|
+
var strokeColor = canvasDraw.strokeStyle;
|
|
1140
|
+
var fillColor = canvasDraw.fillStyle;
|
|
1141
|
+
canvasDraw.strokeStyle = parent.selectionSettings.strokeColor;
|
|
1142
|
+
canvasDraw.fillStyle = parent.selectionSettings.fillColor;
|
|
1143
|
+
canvasDraw.lineWidth *= 2;
|
|
1144
|
+
canvasDraw.beginPath();
|
|
1145
|
+
canvasDraw.moveTo(tempObj.topLeftCircle.startX, tempObj.topLeftCircle.startY);
|
|
1146
|
+
canvasDraw.arc(tempObj.topLeftCircle.startX, tempObj.topLeftCircle.startY, tempObj.topLeftCircle.radius, 0, 2 * Math.PI);
|
|
1147
|
+
canvasDraw.moveTo(tempObj.topRightCircle.startX, tempObj.topRightCircle.startY);
|
|
1148
|
+
canvasDraw.arc(tempObj.topRightCircle.startX, tempObj.topRightCircle.startY, tempObj.topRightCircle.radius, 0, 2 * Math.PI);
|
|
1149
|
+
canvasDraw.moveTo(tempObj.bottomLeftCircle.startX, tempObj.bottomLeftCircle.startY);
|
|
1150
|
+
canvasDraw.arc(tempObj.bottomLeftCircle.startX, tempObj.bottomLeftCircle.startY, tempObj.bottomLeftCircle.radius, 0, 2 * Math.PI);
|
|
1151
|
+
canvasDraw.moveTo(tempObj.bottomRightCircle.startX, tempObj.bottomRightCircle.startY);
|
|
1152
|
+
canvasDraw.arc(tempObj.bottomRightCircle.startX, tempObj.bottomRightCircle.startY, tempObj.bottomRightCircle.radius, 0, 2 * Math.PI);
|
|
1153
|
+
canvasDraw.stroke();
|
|
1154
|
+
canvasDraw.fill();
|
|
1155
|
+
canvasDraw.closePath();
|
|
1156
|
+
canvasDraw.lineWidth /= 2;
|
|
1157
|
+
canvasDraw.strokeStyle = strokeColor;
|
|
1158
|
+
canvasDraw.fillStyle = fillColor;
|
|
1159
|
+
}
|
|
1160
|
+
};
|
|
936
1161
|
Draw.prototype.drawCenterCircles = function (canvasDraw) {
|
|
937
1162
|
var parent = this.parent;
|
|
938
1163
|
var actPoint = parent.activeObj.activePoint;
|
|
1164
|
+
var actObj = parent.activeObj;
|
|
939
1165
|
canvasDraw.lineWidth *= 2;
|
|
940
1166
|
canvasDraw.beginPath();
|
|
941
|
-
if (
|
|
1167
|
+
if (actObj.shape === 'arrow' || actObj.shape === 'line') {
|
|
942
1168
|
canvasDraw.moveTo(actPoint.startX, actPoint.startY);
|
|
943
|
-
canvasDraw.arc(actPoint.startX, actPoint.startY,
|
|
1169
|
+
canvasDraw.arc(actPoint.startX, actPoint.startY, actObj.topCenterCircle.radius, 0, 2 * Math.PI);
|
|
944
1170
|
canvasDraw.moveTo(actPoint.endX, actPoint.endY);
|
|
945
|
-
canvasDraw.arc(actPoint.endX, actPoint.endY,
|
|
1171
|
+
canvasDraw.arc(actPoint.endX, actPoint.endY, actObj.bottomCenterCircle.radius, 0, 2 * Math.PI);
|
|
946
1172
|
}
|
|
947
|
-
else if (
|
|
1173
|
+
else if (actObj.shape === 'path') {
|
|
948
1174
|
var activeObj = extend({}, parent.activeObj, {}, true);
|
|
949
1175
|
if (activeObj.pointColl.length > 1) {
|
|
950
1176
|
for (var i = 1, len = activeObj.pointColl.length; i < len; i++) {
|
|
@@ -953,33 +1179,32 @@ var Draw = /** @class */ (function () {
|
|
|
953
1179
|
actPoint.endX = activeObj.pointColl[i].x;
|
|
954
1180
|
actPoint.endY = activeObj.pointColl[i].y;
|
|
955
1181
|
canvasDraw.moveTo(actPoint.startX, actPoint.startY);
|
|
956
|
-
canvasDraw.arc(actPoint.startX, actPoint.startY,
|
|
1182
|
+
canvasDraw.arc(actPoint.startX, actPoint.startY, actObj.topCenterCircle.radius, 0, 2 * Math.PI);
|
|
957
1183
|
canvasDraw.moveTo(actPoint.endX, actPoint.endY);
|
|
958
|
-
canvasDraw.arc(actPoint.endX, actPoint.endY,
|
|
1184
|
+
canvasDraw.arc(actPoint.endX, actPoint.endY, actObj.bottomCenterCircle.radius, 0, 2 * Math.PI);
|
|
959
1185
|
}
|
|
960
1186
|
}
|
|
961
1187
|
var obj = { shape: null };
|
|
962
1188
|
parent.notify('selection', { prop: 'getCurrentDrawingShape', value: { obj: obj } });
|
|
963
1189
|
if (obj['shape'] === 'path') {
|
|
964
|
-
parent.activeObj = activeObj;
|
|
1190
|
+
parent.activeObj = actObj = activeObj;
|
|
965
1191
|
}
|
|
966
1192
|
canvasDraw.moveTo(actPoint.startX, actPoint.startY);
|
|
967
|
-
canvasDraw.arc(actPoint.startX, actPoint.startY,
|
|
1193
|
+
canvasDraw.arc(actPoint.startX, actPoint.startY, actObj.topCenterCircle.radius, 0, 2 * Math.PI);
|
|
968
1194
|
canvasDraw.moveTo(actPoint.endX, actPoint.endY);
|
|
969
|
-
canvasDraw.arc(actPoint.endX, actPoint.endY,
|
|
1195
|
+
canvasDraw.arc(actPoint.endX, actPoint.endY, actObj.bottomCenterCircle.radius, 0, 2 * Math.PI);
|
|
970
1196
|
}
|
|
971
1197
|
else {
|
|
972
1198
|
this.drawRotationArcLine(canvasDraw);
|
|
973
|
-
canvasDraw.lineTo(
|
|
1199
|
+
canvasDraw.lineTo(actObj.rotationCirclePoint.x, actObj.rotationCirclePoint.y);
|
|
974
1200
|
}
|
|
975
1201
|
canvasDraw.stroke();
|
|
976
1202
|
canvasDraw.fill();
|
|
977
1203
|
canvasDraw.closePath();
|
|
978
|
-
if (
|
|
979
|
-
parent.activeObj.shape !== 'path') {
|
|
1204
|
+
if (actObj.shape !== 'arrow' && actObj.shape !== 'line' && actObj.shape !== 'path') {
|
|
980
1205
|
canvasDraw.beginPath();
|
|
981
|
-
canvasDraw.moveTo(
|
|
982
|
-
canvasDraw.arc(
|
|
1206
|
+
canvasDraw.moveTo(actObj.rotationCirclePoint.x, actObj.rotationCirclePoint.y);
|
|
1207
|
+
canvasDraw.arc(actObj.rotationCirclePoint.x, actObj.rotationCirclePoint.y, actObj.bottomCenterCircle.radius, 0, 2 * Math.PI);
|
|
983
1208
|
canvasDraw.stroke();
|
|
984
1209
|
canvasDraw.fill();
|
|
985
1210
|
canvasDraw.closePath();
|
|
@@ -988,27 +1213,29 @@ var Draw = /** @class */ (function () {
|
|
|
988
1213
|
};
|
|
989
1214
|
Draw.prototype.drawRotationArcLine = function (canvasDraw) {
|
|
990
1215
|
var parent = this.parent;
|
|
991
|
-
|
|
992
|
-
|
|
1216
|
+
var actObj = parent.activeObj;
|
|
1217
|
+
if (isNullOrUndefined(actObj.rotationCircleLine)) {
|
|
1218
|
+
actObj.rotationCircleLine = 22.5;
|
|
993
1219
|
}
|
|
994
1220
|
var degree;
|
|
995
1221
|
var isHorizontalflip = false;
|
|
996
1222
|
var isVerticalflip = false;
|
|
997
|
-
if (
|
|
1223
|
+
if (actObj.shapeDegree === 0) {
|
|
998
1224
|
degree = parent.transform.degree;
|
|
999
1225
|
}
|
|
1000
1226
|
else {
|
|
1001
|
-
degree = parent.transform.degree -
|
|
1227
|
+
degree = parent.transform.degree - actObj.shapeDegree;
|
|
1002
1228
|
}
|
|
1003
1229
|
if (degree < 0) {
|
|
1004
1230
|
degree = 360 + degree;
|
|
1005
1231
|
}
|
|
1006
|
-
if (
|
|
1007
|
-
for (var i = 0, len =
|
|
1008
|
-
|
|
1232
|
+
if (actObj.flipObjColl) {
|
|
1233
|
+
for (var i = 0, len = actObj.flipObjColl.length; i < len; i++) {
|
|
1234
|
+
var flipStr = actObj.flipObjColl[i].toLowerCase();
|
|
1235
|
+
if (flipStr === 'horizontal') {
|
|
1009
1236
|
isHorizontalflip = true;
|
|
1010
1237
|
}
|
|
1011
|
-
else if (
|
|
1238
|
+
else if (flipStr === 'vertical') {
|
|
1012
1239
|
isVerticalflip = true;
|
|
1013
1240
|
}
|
|
1014
1241
|
}
|
|
@@ -1017,53 +1244,53 @@ var Draw = /** @class */ (function () {
|
|
|
1017
1244
|
case 0:
|
|
1018
1245
|
case 360:
|
|
1019
1246
|
if (isVerticalflip) {
|
|
1020
|
-
|
|
1021
|
-
y:
|
|
1022
|
-
canvasDraw.moveTo(
|
|
1247
|
+
actObj.rotationCirclePoint = { x: actObj.topCenterCircle.startX,
|
|
1248
|
+
y: actObj.topCenterCircle.startY - actObj.rotationCircleLine };
|
|
1249
|
+
canvasDraw.moveTo(actObj.rotationCirclePoint.x, actObj.rotationCirclePoint.y + actObj.rotationCircleLine);
|
|
1023
1250
|
}
|
|
1024
1251
|
else {
|
|
1025
|
-
|
|
1026
|
-
y:
|
|
1027
|
-
canvasDraw.moveTo(
|
|
1252
|
+
actObj.rotationCirclePoint = { x: actObj.bottomCenterCircle.startX,
|
|
1253
|
+
y: actObj.bottomCenterCircle.startY + actObj.rotationCircleLine };
|
|
1254
|
+
canvasDraw.moveTo(actObj.rotationCirclePoint.x, actObj.rotationCirclePoint.y - actObj.rotationCircleLine);
|
|
1028
1255
|
}
|
|
1029
1256
|
break;
|
|
1030
1257
|
case 90:
|
|
1031
1258
|
case -270:
|
|
1032
1259
|
if (isHorizontalflip) {
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
canvasDraw.moveTo(
|
|
1260
|
+
actObj.rotationCirclePoint = { x: actObj.centerRightCircle.startX +
|
|
1261
|
+
actObj.rotationCircleLine, y: actObj.centerLeftCircle.startY };
|
|
1262
|
+
canvasDraw.moveTo(actObj.rotationCirclePoint.x - actObj.rotationCircleLine, actObj.rotationCirclePoint.y);
|
|
1036
1263
|
}
|
|
1037
1264
|
else {
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
canvasDraw.moveTo(
|
|
1265
|
+
actObj.rotationCirclePoint = { x: actObj.centerLeftCircle.startX -
|
|
1266
|
+
actObj.rotationCircleLine, y: actObj.centerLeftCircle.startY };
|
|
1267
|
+
canvasDraw.moveTo(actObj.rotationCirclePoint.x + actObj.rotationCircleLine, actObj.rotationCirclePoint.y);
|
|
1041
1268
|
}
|
|
1042
1269
|
break;
|
|
1043
1270
|
case 180:
|
|
1044
1271
|
case -180:
|
|
1045
1272
|
if (isVerticalflip) {
|
|
1046
|
-
|
|
1047
|
-
y:
|
|
1048
|
-
canvasDraw.moveTo(
|
|
1273
|
+
actObj.rotationCirclePoint = { x: actObj.bottomCenterCircle.startX,
|
|
1274
|
+
y: actObj.bottomCenterCircle.startY + actObj.rotationCircleLine };
|
|
1275
|
+
canvasDraw.moveTo(actObj.rotationCirclePoint.x, actObj.rotationCirclePoint.y - actObj.rotationCircleLine);
|
|
1049
1276
|
}
|
|
1050
1277
|
else {
|
|
1051
|
-
|
|
1052
|
-
y:
|
|
1053
|
-
canvasDraw.moveTo(
|
|
1278
|
+
actObj.rotationCirclePoint = { x: actObj.topCenterCircle.startX,
|
|
1279
|
+
y: actObj.topCenterCircle.startY - actObj.rotationCircleLine };
|
|
1280
|
+
canvasDraw.moveTo(actObj.rotationCirclePoint.x, actObj.rotationCirclePoint.y + actObj.rotationCircleLine);
|
|
1054
1281
|
}
|
|
1055
1282
|
break;
|
|
1056
1283
|
case 270:
|
|
1057
1284
|
case -90:
|
|
1058
1285
|
if (isHorizontalflip) {
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
canvasDraw.moveTo(
|
|
1286
|
+
actObj.rotationCirclePoint = { x: actObj.centerLeftCircle.startX -
|
|
1287
|
+
actObj.rotationCircleLine, y: actObj.centerLeftCircle.startY };
|
|
1288
|
+
canvasDraw.moveTo(actObj.rotationCirclePoint.x + actObj.rotationCircleLine, actObj.rotationCirclePoint.y);
|
|
1062
1289
|
}
|
|
1063
1290
|
else {
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
canvasDraw.moveTo(
|
|
1291
|
+
actObj.rotationCirclePoint = { x: actObj.centerRightCircle.startX +
|
|
1292
|
+
actObj.rotationCircleLine, y: actObj.centerLeftCircle.startY };
|
|
1293
|
+
canvasDraw.moveTo(actObj.rotationCirclePoint.x - actObj.rotationCircleLine, actObj.rotationCirclePoint.y);
|
|
1067
1294
|
}
|
|
1068
1295
|
break;
|
|
1069
1296
|
}
|
|
@@ -1071,55 +1298,56 @@ var Draw = /** @class */ (function () {
|
|
|
1071
1298
|
Draw.prototype.drawSquareLines = function (canvasDraw) {
|
|
1072
1299
|
var splitWords;
|
|
1073
1300
|
var parent = this.parent;
|
|
1074
|
-
var
|
|
1075
|
-
|
|
1076
|
-
|
|
1301
|
+
var actObj = parent.activeObj;
|
|
1302
|
+
var _a = actObj.activePoint, startX = _a.startX, startY = _a.startY, width = _a.width, height = _a.height;
|
|
1303
|
+
var _b = actObj.strokeSettings, fillColor = _b.fillColor, strokeColor = _b.strokeColor, strokeWidth = _b.strokeWidth;
|
|
1304
|
+
if (actObj.shape) {
|
|
1305
|
+
splitWords = actObj.shape.split('-');
|
|
1077
1306
|
}
|
|
1078
1307
|
if (splitWords[0] === 'crop') {
|
|
1079
1308
|
canvasDraw.strokeStyle = '#fff';
|
|
1080
1309
|
}
|
|
1081
1310
|
else {
|
|
1082
|
-
canvasDraw.strokeStyle =
|
|
1311
|
+
canvasDraw.strokeStyle = strokeColor;
|
|
1083
1312
|
}
|
|
1084
1313
|
canvasDraw.beginPath();
|
|
1085
|
-
canvasDraw.rect(
|
|
1086
|
-
if (
|
|
1087
|
-
canvasDraw.fillStyle =
|
|
1314
|
+
canvasDraw.rect(startX, startY, width, height);
|
|
1315
|
+
if (fillColor !== '') {
|
|
1316
|
+
canvasDraw.fillStyle = fillColor;
|
|
1088
1317
|
canvasDraw.fill();
|
|
1089
1318
|
}
|
|
1090
|
-
canvasDraw.rect(
|
|
1091
|
-
canvasDraw.fillStyle =
|
|
1319
|
+
canvasDraw.rect(startX + strokeWidth, startY + strokeWidth, width - (2 * strokeWidth), height - (2 * strokeWidth));
|
|
1320
|
+
canvasDraw.fillStyle = strokeColor;
|
|
1092
1321
|
canvasDraw.fill('evenodd');
|
|
1093
1322
|
canvasDraw.closePath();
|
|
1094
1323
|
};
|
|
1095
1324
|
Draw.prototype.drawSelection = function (horLineWidth, verLineHeight) {
|
|
1096
1325
|
var parent = this.parent;
|
|
1097
|
-
var
|
|
1326
|
+
var actObj = parent.activeObj;
|
|
1327
|
+
var _a = actObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
|
|
1098
1328
|
this.upperContext.strokeStyle = parent.themeColl[parent.theme]['primaryColor'];
|
|
1099
1329
|
this.upperContext.beginPath();
|
|
1100
|
-
|
|
1101
|
-
verLineHeight, endX:
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
startY:
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
this.upperContext.moveTo(
|
|
1110
|
-
this.upperContext.lineTo(
|
|
1111
|
-
this.upperContext.moveTo(
|
|
1112
|
-
this.upperContext.lineTo(
|
|
1113
|
-
this.upperContext.moveTo(
|
|
1114
|
-
this.upperContext.lineTo(
|
|
1115
|
-
this.upperContext.moveTo(parent.activeObj.verRightInnerLine.startX, parent.activeObj.verRightInnerLine.startY);
|
|
1116
|
-
this.upperContext.lineTo(parent.activeObj.verRightInnerLine.endX, parent.activeObj.verRightInnerLine.endY);
|
|
1330
|
+
actObj.horTopInnerLine = { startX: startX, startY: startY +
|
|
1331
|
+
verLineHeight, endX: endX, endY: endY + verLineHeight };
|
|
1332
|
+
actObj.horBottomInnerLine = { startX: startX, startY: startY + (2 * verLineHeight), endX: endX, endY: endY + (2 * verLineHeight) };
|
|
1333
|
+
actObj.verLeftInnerLine = { startX: startX + horLineWidth,
|
|
1334
|
+
startY: startY, endX: startX + horLineWidth, endY: endY };
|
|
1335
|
+
actObj.verRightInnerLine = { startX: startX + (2 * horLineWidth),
|
|
1336
|
+
startY: startY, endX: startX + (2 * horLineWidth), endY: endY };
|
|
1337
|
+
this.upperContext.moveTo(actObj.horTopInnerLine.startX, actObj.horTopInnerLine.startY);
|
|
1338
|
+
this.upperContext.lineTo(actObj.horTopInnerLine.endX, actObj.horTopInnerLine.startY);
|
|
1339
|
+
this.upperContext.moveTo(actObj.horBottomInnerLine.startX, actObj.horBottomInnerLine.startY);
|
|
1340
|
+
this.upperContext.lineTo(actObj.horBottomInnerLine.endX, actObj.horBottomInnerLine.startY);
|
|
1341
|
+
this.upperContext.moveTo(actObj.verLeftInnerLine.startX, actObj.verLeftInnerLine.startY);
|
|
1342
|
+
this.upperContext.lineTo(actObj.verLeftInnerLine.endX, actObj.verLeftInnerLine.endY);
|
|
1343
|
+
this.upperContext.moveTo(actObj.verRightInnerLine.startX, actObj.verRightInnerLine.startY);
|
|
1344
|
+
this.upperContext.lineTo(actObj.verRightInnerLine.endX, actObj.verRightInnerLine.endY);
|
|
1117
1345
|
this.upperContext.stroke();
|
|
1118
1346
|
this.upperContext.closePath();
|
|
1119
1347
|
};
|
|
1120
1348
|
Draw.prototype.shapeCircle = function (canvasDraw, selectionWidth, selectionHeight) {
|
|
1121
1349
|
var parent = this.parent;
|
|
1122
|
-
var
|
|
1350
|
+
var _a = parent.activeObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY, width = _a.width;
|
|
1123
1351
|
canvasDraw.strokeStyle = parent.themeColl[parent.theme]['primaryColor'];
|
|
1124
1352
|
canvasDraw.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
|
|
1125
1353
|
canvasDraw.fillStyle = 'rgb(0, 0, 0, 0.25)';
|
|
@@ -1133,7 +1361,7 @@ var Draw = /** @class */ (function () {
|
|
|
1133
1361
|
canvasDraw.closePath();
|
|
1134
1362
|
canvasDraw.save();
|
|
1135
1363
|
canvasDraw.beginPath();
|
|
1136
|
-
canvasDraw.arc(((
|
|
1364
|
+
canvasDraw.arc(((endX - startX) / 2) + startX, ((endY - startY) / 2) + startY, (width / 2), 0, Math.PI * 2);
|
|
1137
1365
|
canvasDraw.closePath();
|
|
1138
1366
|
canvasDraw.clip();
|
|
1139
1367
|
canvasDraw.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
|
|
@@ -1168,258 +1396,262 @@ var Draw = /** @class */ (function () {
|
|
|
1168
1396
|
};
|
|
1169
1397
|
Draw.prototype.arrow = function (canvasDraw, start) {
|
|
1170
1398
|
var parent = this.parent;
|
|
1171
|
-
var
|
|
1172
|
-
|
|
1399
|
+
var actObj = parent.activeObj;
|
|
1400
|
+
var _a = actObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
|
|
1401
|
+
var strWidth = actObj.strokeSettings.strokeWidth;
|
|
1402
|
+
canvasDraw.lineWidth = strWidth;
|
|
1173
1403
|
var x = this.arrowDimension['arrow']['width'];
|
|
1174
1404
|
var y = this.arrowDimension['arrow']['height'];
|
|
1175
1405
|
var point = this.manipulateSaveCtx(canvasDraw, x, y);
|
|
1176
|
-
x = point.x +
|
|
1177
|
-
y = point.y +
|
|
1178
|
-
this.dx =
|
|
1179
|
-
this.dy =
|
|
1180
|
-
canvasDraw.fillStyle =
|
|
1406
|
+
x = point.x + strWidth;
|
|
1407
|
+
y = point.y + strWidth;
|
|
1408
|
+
this.dx = endX - startX;
|
|
1409
|
+
this.dy = endY - startY;
|
|
1410
|
+
canvasDraw.fillStyle = actObj.strokeSettings.strokeColor;
|
|
1181
1411
|
var angle = Math.atan2(this.dy, this.dx);
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
(
|
|
1187
|
-
|
|
1188
|
-
this.shapeLine(canvasDraw,
|
|
1189
|
-
}
|
|
1190
|
-
if ((start &&
|
|
1191
|
-
(
|
|
1192
|
-
canvasDraw.translate(actPoint.endX, actPoint.endY);
|
|
1412
|
+
var isStartArrow = actObj.start === 'arrow';
|
|
1413
|
+
var isEndArrow = actObj.end === 'arrow';
|
|
1414
|
+
var isEndCircleOrSquare = actObj.end === 'circle' || actObj.end === 'square';
|
|
1415
|
+
if ((start && actObj.triangleDirection === 'left' || actObj.triangleDirection === 'right') &&
|
|
1416
|
+
((isStartArrow && actObj.end === 'none') || (isStartArrow && !isEndCircleOrSquare)) ||
|
|
1417
|
+
(!start && (isEndArrow && actObj.start === 'none' || !isStartArrow && !isEndCircleOrSquare))) {
|
|
1418
|
+
this.shapeLine(canvasDraw, startX, startY, endX, endY);
|
|
1419
|
+
}
|
|
1420
|
+
if ((start && actObj.triangleDirection === 'left') || (!start && actObj.triangleDirection === 'right')) {
|
|
1421
|
+
canvasDraw.translate(endX, endY);
|
|
1193
1422
|
canvasDraw.rotate(angle);
|
|
1194
1423
|
this.shapeLine(canvasDraw, 0, 0, -x, y / 2);
|
|
1195
1424
|
this.shapeLine(canvasDraw, 0, 0, -x, -y / 2);
|
|
1196
1425
|
canvasDraw.rotate(-angle);
|
|
1197
|
-
canvasDraw.translate(-
|
|
1426
|
+
canvasDraw.translate(-endX, -endY);
|
|
1198
1427
|
}
|
|
1199
|
-
else if ((start &&
|
|
1200
|
-
(
|
|
1201
|
-
canvasDraw.translate(actPoint.startX, actPoint.startY);
|
|
1428
|
+
else if ((start && actObj.triangleDirection === 'right') || (!start && actObj.triangleDirection === 'left')) {
|
|
1429
|
+
canvasDraw.translate(startX, startY);
|
|
1202
1430
|
canvasDraw.rotate(angle);
|
|
1203
1431
|
this.shapeLine(canvasDraw, 0, 0, x, y / 2);
|
|
1204
1432
|
this.shapeLine(canvasDraw, 0, 0, x, -y / 2);
|
|
1205
1433
|
canvasDraw.rotate(-angle);
|
|
1206
|
-
canvasDraw.translate(-
|
|
1434
|
+
canvasDraw.translate(-startX, -startY);
|
|
1207
1435
|
}
|
|
1208
1436
|
};
|
|
1209
1437
|
Draw.prototype.arrowSolid = function (canvasDraw, start) {
|
|
1210
1438
|
var parent = this.parent;
|
|
1211
|
-
var
|
|
1439
|
+
var actObj = parent.activeObj;
|
|
1440
|
+
var strWidth = actObj.strokeSettings.strokeWidth;
|
|
1441
|
+
var _a = actObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
|
|
1212
1442
|
var x = this.arrowDimension['arrowSolid']['width'];
|
|
1213
1443
|
var y = this.arrowDimension['arrowSolid']['height'];
|
|
1214
1444
|
var point = this.manipulateSaveCtx(canvasDraw, x, y);
|
|
1215
|
-
x = point.x +
|
|
1216
|
-
y = point.y +
|
|
1217
|
-
this.dx =
|
|
1218
|
-
this.dy =
|
|
1445
|
+
x = point.x + strWidth;
|
|
1446
|
+
y = point.y + strWidth;
|
|
1447
|
+
this.dx = endX - startX;
|
|
1448
|
+
this.dy = endY - startY;
|
|
1219
1449
|
var angle = Math.atan2(this.dy, this.dx);
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
canvasDraw.translate(
|
|
1450
|
+
var isStartArrowSolid = actObj.start === 'arrowSolid';
|
|
1451
|
+
var isEndArrowSolid = actObj.end === 'arrowSolid';
|
|
1452
|
+
var isEndCircleOrSquare = actObj.end === 'circle' || actObj.end === 'square';
|
|
1453
|
+
if ((start && (isStartArrowSolid && actObj.end === 'none') || (isStartArrowSolid && !isEndCircleOrSquare)) ||
|
|
1454
|
+
(!start && (isEndArrowSolid && actObj.start === 'none' || !isStartArrowSolid && !isEndCircleOrSquare))) {
|
|
1455
|
+
this.shapeLine(canvasDraw, startX, startY, endX, endY);
|
|
1456
|
+
}
|
|
1457
|
+
if ((start && actObj.triangleDirection === 'left') || (!start && actObj.triangleDirection === 'right')) {
|
|
1458
|
+
canvasDraw.translate(endX, endY);
|
|
1229
1459
|
canvasDraw.rotate(angle);
|
|
1230
1460
|
canvasDraw.beginPath();
|
|
1231
|
-
canvasDraw.moveTo(
|
|
1461
|
+
canvasDraw.moveTo(strWidth, 0);
|
|
1232
1462
|
canvasDraw.lineTo(-x + y / 2, y / 2);
|
|
1233
1463
|
canvasDraw.lineTo(-x + y / 2, -y / 2);
|
|
1234
1464
|
canvasDraw.closePath();
|
|
1235
1465
|
canvasDraw.fill();
|
|
1236
1466
|
canvasDraw.rotate(-angle);
|
|
1237
|
-
canvasDraw.translate(-
|
|
1238
|
-
|
|
1467
|
+
canvasDraw.translate(-endX, -endY);
|
|
1468
|
+
actObj.rotatedAngle = angle;
|
|
1239
1469
|
}
|
|
1240
|
-
else if ((start &&
|
|
1241
|
-
(
|
|
1242
|
-
canvasDraw.translate(actPoint.startX, actPoint.startY);
|
|
1470
|
+
else if ((start && actObj.triangleDirection === 'right') || (!start && actObj.triangleDirection === 'left')) {
|
|
1471
|
+
canvasDraw.translate(startX, startY);
|
|
1243
1472
|
canvasDraw.rotate(angle);
|
|
1244
1473
|
canvasDraw.beginPath();
|
|
1245
|
-
canvasDraw.moveTo(0 -
|
|
1474
|
+
canvasDraw.moveTo(0 - strWidth, 0);
|
|
1246
1475
|
canvasDraw.lineTo(x - y / 2, y / 2);
|
|
1247
1476
|
canvasDraw.lineTo(x - y / 2, -y / 2);
|
|
1248
1477
|
canvasDraw.closePath();
|
|
1249
1478
|
canvasDraw.fill();
|
|
1250
1479
|
canvasDraw.rotate(-angle);
|
|
1251
|
-
canvasDraw.translate(-
|
|
1252
|
-
|
|
1480
|
+
canvasDraw.translate(-startX, -startY);
|
|
1481
|
+
actObj.rotatedAngle = angle;
|
|
1253
1482
|
}
|
|
1254
1483
|
};
|
|
1255
1484
|
Draw.prototype.arrowSquareStart = function (canvasDraw) {
|
|
1256
1485
|
var parent = this.parent;
|
|
1257
|
-
var
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1486
|
+
var actObj = parent.activeObj;
|
|
1487
|
+
var strWidth = actObj.strokeSettings.strokeWidth;
|
|
1488
|
+
var _a = actObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
|
|
1489
|
+
var isStartSquare = actObj.start === 'square';
|
|
1490
|
+
var isEndCircle = actObj.end === 'circle';
|
|
1491
|
+
var isStartSquareSolid = actObj.start === 'squareSolid';
|
|
1492
|
+
var isEndCircleSolid = actObj.end === 'circleSolid';
|
|
1493
|
+
if ((isStartSquare && actObj.end === 'none') || (isStartSquare && !isEndCircle && actObj.start !== 'square') ||
|
|
1494
|
+
(isStartSquareSolid && isEndCircleSolid)) {
|
|
1495
|
+
this.shapeLine(canvasDraw, startX, startY, endX, endY);
|
|
1496
|
+
}
|
|
1497
|
+
canvasDraw.lineWidth = (strWidth);
|
|
1264
1498
|
canvasDraw.beginPath();
|
|
1265
|
-
canvasDraw.fillStyle =
|
|
1499
|
+
canvasDraw.fillStyle = actObj.strokeSettings.strokeColor;
|
|
1266
1500
|
var x = this.arrowDimension['square']['width'];
|
|
1267
1501
|
var y = this.arrowDimension['square']['height'];
|
|
1268
1502
|
var point = this.manipulateSaveCtx(canvasDraw, x, y);
|
|
1269
|
-
x = point.x +
|
|
1270
|
-
y = point.y +
|
|
1271
|
-
this.dx =
|
|
1272
|
-
this.dy =
|
|
1503
|
+
x = point.x + strWidth;
|
|
1504
|
+
y = point.y + strWidth;
|
|
1505
|
+
this.dx = endX - startX;
|
|
1506
|
+
this.dy = endY - startY;
|
|
1273
1507
|
var angle = Math.atan2(this.dy, this.dx);
|
|
1274
|
-
if (
|
|
1275
|
-
canvasDraw.translate(
|
|
1508
|
+
if (actObj.triangleDirection === 'left') {
|
|
1509
|
+
canvasDraw.translate(endX, endY);
|
|
1276
1510
|
canvasDraw.rotate(angle);
|
|
1277
|
-
if (
|
|
1511
|
+
if (actObj.start === 'squareSolid') {
|
|
1278
1512
|
canvasDraw.fillRect(-x + y / 2, -y / 2, x, y);
|
|
1279
1513
|
}
|
|
1280
1514
|
canvasDraw.strokeRect(-x + y / 2, -y / 2, x, y);
|
|
1281
1515
|
canvasDraw.rotate(-angle);
|
|
1282
|
-
canvasDraw.translate(-
|
|
1283
|
-
this.squareStartIntersectX1 =
|
|
1284
|
-
this.squareStartIntersectY1 =
|
|
1285
|
-
if (
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
if (parent.activeObj.start === 'square' && parent.activeObj.end === 'circle') {
|
|
1516
|
+
canvasDraw.translate(-endX, -endY);
|
|
1517
|
+
this.squareStartIntersectX1 = endX - (y / 2) * Math.cos(angle);
|
|
1518
|
+
this.squareStartIntersectY1 = endY - (y / 2) * Math.sin(angle);
|
|
1519
|
+
if (actObj.start === 'square' && actObj.end !== 'square' && actObj.end !== 'circle') {
|
|
1520
|
+
this.shapeLine(canvasDraw, startX, startY, this.squareStartIntersectX1, this.squareStartIntersectY1);
|
|
1521
|
+
}
|
|
1522
|
+
else if (actObj.start === 'square' && actObj.end === 'circle') {
|
|
1290
1523
|
this.shapeLine(canvasDraw, this.endCircleIntersectX1, this.endCircleIntersectY1, this.squareStartIntersectX1, this.squareStartIntersectY1);
|
|
1291
1524
|
}
|
|
1292
|
-
if (
|
|
1293
|
-
this.shapeLine(canvasDraw,
|
|
1525
|
+
else if (actObj.start === 'squareSolid' && actObj.end === 'squareSolid') {
|
|
1526
|
+
this.shapeLine(canvasDraw, startX, startY, endX, endY);
|
|
1294
1527
|
}
|
|
1295
1528
|
}
|
|
1296
|
-
else if (
|
|
1297
|
-
canvasDraw.lineWidth = (
|
|
1298
|
-
canvasDraw.fillStyle =
|
|
1299
|
-
if (
|
|
1300
|
-
this.shapeLine(canvasDraw,
|
|
1529
|
+
else if (actObj.triangleDirection === 'right') {
|
|
1530
|
+
canvasDraw.lineWidth = (strWidth);
|
|
1531
|
+
canvasDraw.fillStyle = actObj.strokeSettings.strokeColor;
|
|
1532
|
+
if (actObj.start === 'squareSolid' && actObj.end === 'squareSolid') {
|
|
1533
|
+
this.shapeLine(canvasDraw, startX, startY, endX, endY);
|
|
1301
1534
|
}
|
|
1302
|
-
canvasDraw.translate(
|
|
1535
|
+
canvasDraw.translate(startX, startY);
|
|
1303
1536
|
canvasDraw.rotate(angle);
|
|
1304
|
-
if (
|
|
1537
|
+
if (actObj.start === 'squareSolid') {
|
|
1305
1538
|
canvasDraw.fillRect(y / 2 - x, -y / 2, x, y);
|
|
1306
1539
|
}
|
|
1307
1540
|
canvasDraw.strokeRect(y / 2 - x, -y / 2, x, y);
|
|
1308
1541
|
canvasDraw.rotate(-angle);
|
|
1309
|
-
canvasDraw.translate(-
|
|
1310
|
-
|
|
1311
|
-
this.squareStartIntersectX1 =
|
|
1312
|
-
this.squareStartIntersectY1 =
|
|
1313
|
-
if (
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
if (parent.activeObj.start === 'square' && parent.activeObj.end === 'circle') {
|
|
1542
|
+
canvasDraw.translate(-startX, -startY);
|
|
1543
|
+
actObj.rotatedAngle = angle;
|
|
1544
|
+
this.squareStartIntersectX1 = startX + (y / 2) * Math.cos(angle);
|
|
1545
|
+
this.squareStartIntersectY1 = startY + (y / 2) * Math.sin(angle);
|
|
1546
|
+
if (actObj.start === 'square' && actObj.end !== 'square' && actObj.end !== 'circle') {
|
|
1547
|
+
this.shapeLine(canvasDraw, endX, endY, this.squareStartIntersectX1, this.squareStartIntersectY1);
|
|
1548
|
+
}
|
|
1549
|
+
if (actObj.start === 'square' && actObj.end === 'circle') {
|
|
1318
1550
|
this.shapeLine(canvasDraw, this.endCircleIntersectX1, this.endCircleIntersectY1, this.squareStartIntersectX1, this.squareStartIntersectY1);
|
|
1319
1551
|
}
|
|
1320
1552
|
}
|
|
1321
1553
|
};
|
|
1322
1554
|
Draw.prototype.arrowSquareEnd = function (canvasDraw) {
|
|
1323
1555
|
var parent = this.parent;
|
|
1324
|
-
var
|
|
1556
|
+
var actObj = parent.activeObj;
|
|
1557
|
+
var _a = actObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
|
|
1558
|
+
var strWidth = actObj.strokeSettings.strokeWidth;
|
|
1325
1559
|
var x = this.arrowDimension['square']['width'];
|
|
1326
1560
|
var y = this.arrowDimension['square']['height'];
|
|
1327
1561
|
var point = this.manipulateSaveCtx(canvasDraw, x, y);
|
|
1328
|
-
x = point.x +
|
|
1329
|
-
y = point.y +
|
|
1330
|
-
this.dx =
|
|
1331
|
-
this.dy =
|
|
1562
|
+
x = point.x + strWidth;
|
|
1563
|
+
y = point.y + strWidth;
|
|
1564
|
+
this.dx = endX - startX;
|
|
1565
|
+
this.dy = endY - startY;
|
|
1332
1566
|
var angle = Math.atan2(this.dy, this.dx);
|
|
1333
|
-
canvasDraw.lineWidth = (
|
|
1334
|
-
if (
|
|
1335
|
-
canvasDraw.fillStyle =
|
|
1336
|
-
if (
|
|
1337
|
-
this.shapeLine(canvasDraw,
|
|
1567
|
+
canvasDraw.lineWidth = (strWidth);
|
|
1568
|
+
if (actObj.triangleDirection === 'right') {
|
|
1569
|
+
canvasDraw.fillStyle = actObj.strokeSettings.strokeColor;
|
|
1570
|
+
if (actObj.end === 'squareSolid' && actObj.start === 'none') {
|
|
1571
|
+
this.shapeLine(canvasDraw, startX, startY, endX, endY);
|
|
1338
1572
|
}
|
|
1339
|
-
canvasDraw.translate(
|
|
1573
|
+
canvasDraw.translate(endX, endY);
|
|
1340
1574
|
canvasDraw.rotate(angle);
|
|
1341
|
-
if (
|
|
1575
|
+
if (actObj.end === 'squareSolid') {
|
|
1342
1576
|
canvasDraw.fillRect(-x + y / 2, -y / 2, x, y);
|
|
1343
1577
|
}
|
|
1344
1578
|
canvasDraw.strokeRect(-x + y / 2, -y / 2, x, y);
|
|
1345
1579
|
canvasDraw.rotate(-angle);
|
|
1346
|
-
canvasDraw.translate(-
|
|
1347
|
-
|
|
1348
|
-
this.squareEndIntersectX1 =
|
|
1349
|
-
this.squareEndIntersectY1 =
|
|
1350
|
-
if (
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
else if ((parent.activeObj.start === 'circle') && parent.activeObj.end === 'square') {
|
|
1580
|
+
canvasDraw.translate(-endX, -endY);
|
|
1581
|
+
actObj.rotatedAngle = angle;
|
|
1582
|
+
this.squareEndIntersectX1 = endX - (y / 2) * Math.cos(angle);
|
|
1583
|
+
this.squareEndIntersectY1 = endY - (y / 2) * Math.sin(angle);
|
|
1584
|
+
if (actObj.end === 'square' && actObj.start !== 'square' && actObj.start !== 'circle') {
|
|
1585
|
+
this.shapeLine(canvasDraw, startX, startY, this.squareEndIntersectX1, this.squareEndIntersectY1);
|
|
1586
|
+
}
|
|
1587
|
+
else if (actObj.start === 'circle' && actObj.end === 'square') {
|
|
1355
1588
|
this.shapeLine(canvasDraw, this.squareEndIntersectX1, this.squareEndIntersectY1, this.startCircleIntersectX1, this.startCircleIntersectY1);
|
|
1356
1589
|
}
|
|
1357
|
-
else if (
|
|
1590
|
+
else if (actObj.start === 'square' && actObj.end === 'square') {
|
|
1358
1591
|
this.shapeLine(canvasDraw, this.squareEndIntersectX1, this.squareEndIntersectY1, this.squareStartIntersectX1, this.squareStartIntersectY1);
|
|
1359
1592
|
}
|
|
1360
1593
|
}
|
|
1361
|
-
else if (
|
|
1362
|
-
canvasDraw.translate(
|
|
1594
|
+
else if (actObj.triangleDirection === 'left') {
|
|
1595
|
+
canvasDraw.translate(startX, startY);
|
|
1363
1596
|
canvasDraw.rotate(angle);
|
|
1364
|
-
if (
|
|
1597
|
+
if (actObj.end === 'squareSolid') {
|
|
1365
1598
|
canvasDraw.fillRect(y / 2 - x, -y / 2, x, y);
|
|
1366
1599
|
}
|
|
1367
1600
|
canvasDraw.strokeRect(y / 2 - x, -y / 2, x, y);
|
|
1368
1601
|
canvasDraw.rotate(-angle);
|
|
1369
|
-
canvasDraw.translate(-
|
|
1370
|
-
|
|
1371
|
-
this.squareEndIntersectX1 =
|
|
1372
|
-
this.squareEndIntersectY1 =
|
|
1373
|
-
if (
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
else if ((parent.activeObj.start === 'circle') && parent.activeObj.end === 'square') {
|
|
1602
|
+
canvasDraw.translate(-startX, -startY);
|
|
1603
|
+
actObj.rotatedAngle = angle;
|
|
1604
|
+
this.squareEndIntersectX1 = startX + (y / 2) * Math.cos(angle);
|
|
1605
|
+
this.squareEndIntersectY1 = startY + (y / 2) * Math.sin(angle);
|
|
1606
|
+
if (actObj.end === 'square' && actObj.start !== 'square' && actObj.start !== 'circle') {
|
|
1607
|
+
this.shapeLine(canvasDraw, endX, endY, this.squareEndIntersectX1, this.squareEndIntersectY1);
|
|
1608
|
+
}
|
|
1609
|
+
else if (actObj.start === 'circle' && actObj.end === 'square') {
|
|
1378
1610
|
this.shapeLine(canvasDraw, this.squareEndIntersectX1, this.squareEndIntersectY1, this.startCircleIntersectX1, this.startCircleIntersectY1);
|
|
1379
1611
|
}
|
|
1380
|
-
else if (
|
|
1612
|
+
else if (actObj.start === 'square' && actObj.end === 'square') {
|
|
1381
1613
|
this.shapeLine(canvasDraw, this.squareEndIntersectX1, this.squareEndIntersectY1, this.squareStartIntersectX1, this.squareStartIntersectY1);
|
|
1382
1614
|
}
|
|
1383
1615
|
}
|
|
1384
1616
|
};
|
|
1385
1617
|
Draw.prototype.arrowCircle = function (canvasDraw, start) {
|
|
1386
1618
|
var parent = this.parent;
|
|
1387
|
-
var
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1619
|
+
var actObj = parent.activeObj;
|
|
1620
|
+
var _a = actObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
|
|
1621
|
+
var strWidth = actObj.strokeSettings.strokeWidth;
|
|
1622
|
+
if ((start && actObj.triangleDirection === 'left') ||
|
|
1623
|
+
(!start && actObj.triangleDirection === 'right')) {
|
|
1624
|
+
canvasDraw.lineWidth = strWidth;
|
|
1391
1625
|
var circleRadius = this.arrowDimension['circle']['width'];
|
|
1392
1626
|
var point = this.manipulateSaveCtx(canvasDraw, circleRadius, null);
|
|
1393
|
-
circleRadius = point.x +
|
|
1627
|
+
circleRadius = point.x + strWidth;
|
|
1394
1628
|
canvasDraw.beginPath();
|
|
1395
|
-
canvasDraw.arc(
|
|
1629
|
+
canvasDraw.arc(endX, endY, circleRadius, 0, 2 * Math.PI);
|
|
1396
1630
|
canvasDraw.stroke();
|
|
1397
1631
|
canvasDraw.closePath();
|
|
1398
|
-
this.dx =
|
|
1399
|
-
this.dy =
|
|
1632
|
+
this.dx = endX - startX;
|
|
1633
|
+
this.dy = endY - startY;
|
|
1400
1634
|
var a = this.dx * this.dx + this.dy * this.dy;
|
|
1401
|
-
var b = 2 * (this.dx * (
|
|
1402
|
-
var c = (
|
|
1403
|
-
(
|
|
1404
|
-
(actPoint.startY - actPoint.endY) *
|
|
1405
|
-
(actPoint.startY - actPoint.endY) - circleRadius * circleRadius;
|
|
1635
|
+
var b = 2 * (this.dx * (startX - endX) + this.dy * (startY - endY));
|
|
1636
|
+
var c = (startX - endX) * (startX - endX) + (startY - endY) *
|
|
1637
|
+
(startY - endY) - circleRadius * circleRadius;
|
|
1406
1638
|
var intersect = b * b - 4 * a * c;
|
|
1407
1639
|
if (intersect >= 0) {
|
|
1408
|
-
canvasDraw.fillStyle =
|
|
1640
|
+
canvasDraw.fillStyle = actObj.strokeSettings.strokeColor;
|
|
1409
1641
|
var t2 = (-b - Math.sqrt(intersect)) / (2 * a);
|
|
1410
|
-
var intersectionX1 =
|
|
1411
|
-
var intersectionY1 =
|
|
1642
|
+
var intersectionX1 = startX + this.dx * t2;
|
|
1643
|
+
var intersectionY1 = startY + this.dy * t2;
|
|
1412
1644
|
if (start) {
|
|
1413
1645
|
this.startCircleIntersectX1 = intersectionX1;
|
|
1414
1646
|
this.startCircleIntersectY1 = intersectionY1;
|
|
1415
1647
|
canvasDraw.beginPath();
|
|
1416
1648
|
canvasDraw.fill();
|
|
1417
1649
|
canvasDraw.beginPath();
|
|
1418
|
-
if (
|
|
1650
|
+
if (actObj.start === 'circle' && actObj.end === 'circle') {
|
|
1419
1651
|
this.shapeLine(canvasDraw, this.startCircleIntersectX1, this.startCircleIntersectY1, this.endCircleIntersectX1, this.endCircleIntersectY1);
|
|
1420
1652
|
}
|
|
1421
|
-
else if (
|
|
1422
|
-
this.shapeLine(canvasDraw,
|
|
1653
|
+
else if (actObj.start === 'circle' && actObj.end !== 'circle' && actObj.end !== 'square') {
|
|
1654
|
+
this.shapeLine(canvasDraw, startX, startY, this.startCircleIntersectX1, this.startCircleIntersectY1);
|
|
1423
1655
|
}
|
|
1424
1656
|
canvasDraw.stroke();
|
|
1425
1657
|
canvasDraw.closePath();
|
|
@@ -1427,47 +1659,44 @@ var Draw = /** @class */ (function () {
|
|
|
1427
1659
|
else {
|
|
1428
1660
|
this.endCircleIntersectX1 = intersectionX1;
|
|
1429
1661
|
this.endCircleIntersectY1 = intersectionY1;
|
|
1430
|
-
if (
|
|
1431
|
-
this.shapeLine(canvasDraw,
|
|
1662
|
+
if (actObj.end === 'circle' && (actObj.start !== 'circle' && actObj.start !== 'square')) {
|
|
1663
|
+
this.shapeLine(canvasDraw, startX, startY, this.endCircleIntersectX1, this.endCircleIntersectY1);
|
|
1432
1664
|
}
|
|
1433
1665
|
}
|
|
1434
1666
|
}
|
|
1435
1667
|
var angle = Math.atan2(this.dy, this.dx);
|
|
1436
1668
|
parent.activeObj.rotatedAngle = angle;
|
|
1437
1669
|
}
|
|
1438
|
-
else if ((start &&
|
|
1439
|
-
(!start &&
|
|
1440
|
-
canvasDraw.lineWidth =
|
|
1670
|
+
else if ((start && actObj.triangleDirection === 'right') ||
|
|
1671
|
+
(!start && actObj.triangleDirection === 'left')) {
|
|
1672
|
+
canvasDraw.lineWidth = strWidth;
|
|
1441
1673
|
var circleRadius = this.arrowDimension['circle']['width'];
|
|
1442
1674
|
var point = this.manipulateSaveCtx(canvasDraw, circleRadius, null);
|
|
1443
|
-
circleRadius = point.x +
|
|
1675
|
+
circleRadius = point.x + strWidth;
|
|
1444
1676
|
canvasDraw.beginPath();
|
|
1445
|
-
canvasDraw.arc(
|
|
1677
|
+
canvasDraw.arc(startX, startY, circleRadius, 0, 2 * Math.PI);
|
|
1446
1678
|
canvasDraw.stroke();
|
|
1447
1679
|
canvasDraw.closePath();
|
|
1448
|
-
this.dx =
|
|
1449
|
-
this.dy =
|
|
1680
|
+
this.dx = startX - endX;
|
|
1681
|
+
this.dy = startY - endY;
|
|
1450
1682
|
var a = this.dx * this.dx + this.dy * this.dy;
|
|
1451
|
-
var b = 2 * (this.dx * (
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
(actPoint.endX - actPoint.startX) +
|
|
1455
|
-
(actPoint.endY - actPoint.startY) *
|
|
1456
|
-
(actPoint.endY - actPoint.startY) - circleRadius * circleRadius;
|
|
1683
|
+
var b = 2 * (this.dx * (endX - startX) + this.dy * (endY - startY));
|
|
1684
|
+
var c = (endX - startX) * (endX - startX) + (endY - startY) *
|
|
1685
|
+
(endY - startY) - circleRadius * circleRadius;
|
|
1457
1686
|
var intersect = b * b - 4 * a * c;
|
|
1458
1687
|
if (intersect >= 0) {
|
|
1459
|
-
canvasDraw.fillStyle =
|
|
1688
|
+
canvasDraw.fillStyle = actObj.strokeSettings.strokeColor;
|
|
1460
1689
|
var t2 = (-b - Math.sqrt(intersect)) / (2 * a);
|
|
1461
|
-
var intersectionX1 =
|
|
1462
|
-
var intersectionY1 =
|
|
1690
|
+
var intersectionX1 = endX + this.dx * t2;
|
|
1691
|
+
var intersectionY1 = endY + this.dy * t2;
|
|
1463
1692
|
if (start) {
|
|
1464
1693
|
this.startCircleIntersectX1 = intersectionX1;
|
|
1465
1694
|
this.startCircleIntersectY1 = intersectionY1;
|
|
1466
|
-
if (
|
|
1695
|
+
if (actObj.start === 'circle' && actObj.end === 'circle') {
|
|
1467
1696
|
this.shapeLine(canvasDraw, this.endCircleIntersectX1, this.endCircleIntersectY1, this.startCircleIntersectX1, this.startCircleIntersectY1);
|
|
1468
1697
|
}
|
|
1469
|
-
else if (
|
|
1470
|
-
this.shapeLine(canvasDraw,
|
|
1698
|
+
else if (actObj.start === 'circle' && actObj.end !== 'circle' && actObj.end !== 'square') {
|
|
1699
|
+
this.shapeLine(canvasDraw, endX, endY, this.startCircleIntersectX1, this.startCircleIntersectY1);
|
|
1471
1700
|
}
|
|
1472
1701
|
}
|
|
1473
1702
|
else {
|
|
@@ -1476,8 +1705,8 @@ var Draw = /** @class */ (function () {
|
|
|
1476
1705
|
canvasDraw.beginPath();
|
|
1477
1706
|
canvasDraw.fill();
|
|
1478
1707
|
canvasDraw.beginPath();
|
|
1479
|
-
if (
|
|
1480
|
-
this.shapeLine(canvasDraw,
|
|
1708
|
+
if (actObj.end === 'circle' && (actObj.start !== 'circle' && actObj.start !== 'square')) {
|
|
1709
|
+
this.shapeLine(canvasDraw, endX, endY, this.endCircleIntersectX1, this.endCircleIntersectY1);
|
|
1481
1710
|
}
|
|
1482
1711
|
}
|
|
1483
1712
|
}
|
|
@@ -1487,121 +1716,122 @@ var Draw = /** @class */ (function () {
|
|
|
1487
1716
|
};
|
|
1488
1717
|
Draw.prototype.arrowCircleSolid = function (canvasDraw, start) {
|
|
1489
1718
|
var parent = this.parent;
|
|
1490
|
-
var
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1719
|
+
var actObj = parent.activeObj;
|
|
1720
|
+
var _a = actObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
|
|
1721
|
+
var isStartCircleSolid = actObj.start === 'circleSolid';
|
|
1722
|
+
var strWidth = actObj.strokeSettings.strokeWidth;
|
|
1723
|
+
if ((start && actObj.triangleDirection === 'left') || (!start && actObj.triangleDirection === 'right')) {
|
|
1724
|
+
canvasDraw.lineWidth = strWidth;
|
|
1494
1725
|
canvasDraw.beginPath();
|
|
1495
|
-
canvasDraw.fillStyle =
|
|
1496
|
-
if ((start && (
|
|
1497
|
-
(
|
|
1498
|
-
(!start && (
|
|
1499
|
-
this.shapeLine(canvasDraw,
|
|
1726
|
+
canvasDraw.fillStyle = actObj.strokeSettings.strokeColor;
|
|
1727
|
+
if ((start && (isStartCircleSolid && actObj.end === 'none') ||
|
|
1728
|
+
(isStartCircleSolid && actObj.end !== 'circle' && actObj.end !== 'square')) ||
|
|
1729
|
+
(!start && (actObj.end === 'circleSolid' && actObj.start === 'none'))) {
|
|
1730
|
+
this.shapeLine(canvasDraw, startX, startY, endX, endY);
|
|
1500
1731
|
}
|
|
1501
1732
|
var circleRadius = this.arrowDimension['circle']['width'];
|
|
1502
1733
|
var point = this.manipulateSaveCtx(canvasDraw, circleRadius, null);
|
|
1503
|
-
circleRadius = point.x +
|
|
1504
|
-
this.dx =
|
|
1505
|
-
this.dy =
|
|
1734
|
+
circleRadius = point.x + strWidth;
|
|
1735
|
+
this.dx = endX - startX;
|
|
1736
|
+
this.dy = endY - startY;
|
|
1506
1737
|
canvasDraw.save();
|
|
1507
1738
|
canvasDraw.beginPath();
|
|
1508
|
-
canvasDraw.arc(
|
|
1739
|
+
canvasDraw.arc(endX, endY, circleRadius, 0, 2 * Math.PI);
|
|
1509
1740
|
canvasDraw.stroke();
|
|
1510
1741
|
canvasDraw.fill();
|
|
1511
1742
|
canvasDraw.closePath();
|
|
1512
|
-
|
|
1743
|
+
actObj.rotatedAngle = Math.atan2(this.dy, this.dx);
|
|
1513
1744
|
}
|
|
1514
|
-
else if ((start &&
|
|
1515
|
-
|
|
1516
|
-
canvasDraw.lineWidth = (parent.activeObj.strokeSettings.strokeWidth);
|
|
1745
|
+
else if ((start && actObj.triangleDirection === 'right') || (!start && actObj.triangleDirection === 'left')) {
|
|
1746
|
+
canvasDraw.lineWidth = strWidth;
|
|
1517
1747
|
canvasDraw.beginPath();
|
|
1518
|
-
canvasDraw.fillStyle =
|
|
1519
|
-
if ((start && (
|
|
1520
|
-
(
|
|
1521
|
-
!start && (
|
|
1522
|
-
this.shapeLine(canvasDraw,
|
|
1748
|
+
canvasDraw.fillStyle = actObj.strokeSettings.strokeColor;
|
|
1749
|
+
if ((start && (isStartCircleSolid && actObj.end === 'none') ||
|
|
1750
|
+
(isStartCircleSolid && actObj.end !== 'circle' && actObj.end !== 'square')) ||
|
|
1751
|
+
!start && (actObj.end === 'circleSolid' && actObj.start === 'none')) {
|
|
1752
|
+
this.shapeLine(canvasDraw, startX, startY, endX, endY);
|
|
1523
1753
|
}
|
|
1524
1754
|
var circleRadius = this.arrowDimension['circle']['width'];
|
|
1525
1755
|
var point = this.manipulateSaveCtx(canvasDraw, circleRadius, null);
|
|
1526
|
-
circleRadius = point.x +
|
|
1527
|
-
this.dx =
|
|
1528
|
-
this.dy =
|
|
1756
|
+
circleRadius = point.x + strWidth;
|
|
1757
|
+
this.dx = endX - startX;
|
|
1758
|
+
this.dy = endY - startY;
|
|
1529
1759
|
canvasDraw.save();
|
|
1530
1760
|
canvasDraw.beginPath();
|
|
1531
|
-
canvasDraw.arc(
|
|
1761
|
+
canvasDraw.arc(startX, startY, circleRadius, 0, 2 * Math.PI);
|
|
1532
1762
|
canvasDraw.stroke();
|
|
1533
1763
|
canvasDraw.fill();
|
|
1534
1764
|
canvasDraw.closePath();
|
|
1535
|
-
|
|
1765
|
+
actObj.rotatedAngle = Math.atan2(this.dy, this.dx);
|
|
1536
1766
|
}
|
|
1537
1767
|
};
|
|
1538
1768
|
Draw.prototype.arrowBar = function (canvasDraw, start) {
|
|
1539
1769
|
var parent = this.parent;
|
|
1540
|
-
var
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1770
|
+
var actObj = parent.activeObj;
|
|
1771
|
+
var _a = actObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
|
|
1772
|
+
var strWidth = actObj.strokeSettings.strokeWidth;
|
|
1773
|
+
if ((start && actObj.triangleDirection === 'left') || (!start && actObj.triangleDirection === 'right')) {
|
|
1774
|
+
canvasDraw.lineWidth = strWidth;
|
|
1544
1775
|
canvasDraw.beginPath();
|
|
1545
|
-
canvasDraw.fillStyle =
|
|
1546
|
-
if ((start && (
|
|
1547
|
-
(
|
|
1548
|
-
(!start && ((
|
|
1549
|
-
(
|
|
1550
|
-
this.shapeLine(canvasDraw,
|
|
1776
|
+
canvasDraw.fillStyle = actObj.strokeSettings.strokeColor;
|
|
1777
|
+
if ((start && (actObj.start === 'bar' && actObj.end === 'none') ||
|
|
1778
|
+
(actObj.start === 'bar' && (actObj.end !== 'circle' && actObj.end !== 'square'))) ||
|
|
1779
|
+
(!start && ((actObj.end === 'bar' && actObj.start === 'none') ||
|
|
1780
|
+
(actObj.end === 'bar' && (actObj.start !== 'circle' && actObj.start !== 'square'))))) {
|
|
1781
|
+
this.shapeLine(canvasDraw, startX, startY, endX, endY);
|
|
1551
1782
|
}
|
|
1552
1783
|
var x = this.arrowDimension['bar']['width'];
|
|
1553
1784
|
var y = this.arrowDimension['bar']['height'];
|
|
1554
1785
|
var point = this.manipulateSaveCtx(canvasDraw, x, y);
|
|
1555
|
-
x = point.x +
|
|
1556
|
-
y = point.y +
|
|
1557
|
-
this.dx =
|
|
1558
|
-
this.dy =
|
|
1786
|
+
x = point.x + strWidth;
|
|
1787
|
+
y = point.y + strWidth;
|
|
1788
|
+
this.dx = endX - startX;
|
|
1789
|
+
this.dy = endY - startY;
|
|
1559
1790
|
var angle = Math.atan2(this.dy, this.dx);
|
|
1560
|
-
canvasDraw.translate(
|
|
1791
|
+
canvasDraw.translate(endX, endY);
|
|
1561
1792
|
canvasDraw.rotate(angle);
|
|
1562
1793
|
canvasDraw.fillRect(-x + y / 4, -y / 2, x, y);
|
|
1563
1794
|
canvasDraw.rotate(-angle);
|
|
1564
|
-
canvasDraw.translate(-
|
|
1565
|
-
|
|
1795
|
+
canvasDraw.translate(-endX, -endY);
|
|
1796
|
+
actObj.rotatedAngle = angle;
|
|
1566
1797
|
}
|
|
1567
|
-
else if ((start &&
|
|
1568
|
-
|
|
1569
|
-
canvasDraw.lineWidth = (parent.activeObj.strokeSettings.strokeWidth);
|
|
1798
|
+
else if ((start && actObj.triangleDirection === 'right') || (!start && actObj.triangleDirection === 'left')) {
|
|
1799
|
+
canvasDraw.lineWidth = strWidth;
|
|
1570
1800
|
canvasDraw.beginPath();
|
|
1571
|
-
canvasDraw.fillStyle =
|
|
1572
|
-
if ((start && (
|
|
1573
|
-
|| (
|
|
1574
|
-
(!start && (
|
|
1575
|
-
this.shapeLine(canvasDraw,
|
|
1801
|
+
canvasDraw.fillStyle = actObj.strokeSettings.strokeColor;
|
|
1802
|
+
if ((start && (actObj.start === 'bar' && actObj.end === 'none')
|
|
1803
|
+
|| (actObj.start === 'bar' && (actObj.end !== 'circle' && actObj.end !== 'square'))) ||
|
|
1804
|
+
(!start && (actObj.end === 'bar' && actObj.start === 'none'))) {
|
|
1805
|
+
this.shapeLine(canvasDraw, startX, startY, endX, endY);
|
|
1576
1806
|
}
|
|
1577
1807
|
var x = this.arrowDimension['bar']['width'];
|
|
1578
1808
|
var y = this.arrowDimension['bar']['height'];
|
|
1579
1809
|
var point = this.manipulateSaveCtx(canvasDraw, x, y);
|
|
1580
|
-
x = point.x +
|
|
1581
|
-
y = point.y +
|
|
1582
|
-
this.dx =
|
|
1583
|
-
this.dy =
|
|
1810
|
+
x = point.x + strWidth;
|
|
1811
|
+
y = point.y + strWidth;
|
|
1812
|
+
this.dx = endX - startX;
|
|
1813
|
+
this.dy = endY - startY;
|
|
1584
1814
|
var angle = Math.atan2(this.dy, this.dx);
|
|
1585
|
-
canvasDraw.translate(
|
|
1815
|
+
canvasDraw.translate(startX, startY);
|
|
1586
1816
|
canvasDraw.rotate(angle);
|
|
1587
1817
|
canvasDraw.fillRect(y / 4 - x, -y / 2, x, y);
|
|
1588
1818
|
canvasDraw.rotate(-angle);
|
|
1589
|
-
canvasDraw.translate(-
|
|
1819
|
+
canvasDraw.translate(-startX, -startY);
|
|
1590
1820
|
parent.activeObj.rotatedAngle = angle;
|
|
1591
1821
|
}
|
|
1592
1822
|
};
|
|
1593
1823
|
Draw.prototype.shapeImage = function (canvasDraw) {
|
|
1594
1824
|
var parent = this.parent;
|
|
1595
|
-
var actObj =
|
|
1596
|
-
var
|
|
1825
|
+
var actObj = parent.activeObj;
|
|
1826
|
+
var _a = actObj.activePoint, startX = _a.startX, startY = _a.startY, width = _a.width, height = _a.height;
|
|
1827
|
+
var ctx = actObj.imageCanvas.getContext('2d');
|
|
1597
1828
|
if (canvasDraw === this.lowerContext && this.isImageApply) {
|
|
1598
1829
|
var dimObj = { width: 0, height: 0 };
|
|
1599
|
-
parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
|
|
1600
|
-
|
|
1601
|
-
if (
|
|
1602
|
-
ctx.clearRect(0, 0,
|
|
1603
|
-
parent.notify('
|
|
1604
|
-
value: { ctx: ctx, isImgAnnotation: true, isHFlip: null, isVFlip: null } });
|
|
1830
|
+
parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false, value: { width: actObj
|
|
1831
|
+
.imageElement.width, height: actObj.imageElement.height, obj: dimObj, isImgShape: null } });
|
|
1832
|
+
if (width < (dimObj['width'] / 5) || height < (dimObj['height'] / 5)) {
|
|
1833
|
+
ctx.clearRect(0, 0, actObj.imageCanvas.width, actObj.imageCanvas.height);
|
|
1834
|
+
parent.notify('selection', { prop: 'applyTransformToImg', onPropertyChange: false, value: { ctx: ctx } });
|
|
1605
1835
|
parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate' } });
|
|
1606
1836
|
this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
|
|
1607
1837
|
parent.notify('selection', { prop: 'setImageClarity', onPropertyChange: false, value: { bool: false } });
|
|
@@ -1609,75 +1839,74 @@ var Draw = /** @class */ (function () {
|
|
|
1609
1839
|
}
|
|
1610
1840
|
}
|
|
1611
1841
|
var imgPoint = { startX: 0, startY: 0, width: 0, height: 0 };
|
|
1612
|
-
imgPoint.width =
|
|
1613
|
-
imgPoint.height =
|
|
1614
|
-
if (
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
}
|
|
1618
|
-
imgPoint.startX = ((
|
|
1619
|
-
imgPoint.startY = ((
|
|
1842
|
+
imgPoint.width = width;
|
|
1843
|
+
imgPoint.height = height;
|
|
1844
|
+
if (actObj.flipObjColl.length === 4) {
|
|
1845
|
+
actObj.flipObjColl = [];
|
|
1846
|
+
actObj.shapeFlip = '';
|
|
1847
|
+
}
|
|
1848
|
+
imgPoint.startX = ((width - imgPoint.width) / 2) + startX;
|
|
1849
|
+
imgPoint.startY = ((height - imgPoint.height) / 2) + startY;
|
|
1620
1850
|
var temp = canvasDraw.globalAlpha;
|
|
1621
|
-
canvasDraw.globalAlpha =
|
|
1851
|
+
canvasDraw.globalAlpha = actObj.opacity;
|
|
1622
1852
|
if (actObj.rotateFlipColl && actObj.rotateFlipColl.length > 0) {
|
|
1623
1853
|
this.rotateImage(canvasDraw);
|
|
1624
1854
|
}
|
|
1625
1855
|
else {
|
|
1626
|
-
canvasDraw.drawImage(
|
|
1856
|
+
canvasDraw.drawImage(actObj.imageCanvas, imgPoint.startX, imgPoint.startY, imgPoint.width, imgPoint.height);
|
|
1627
1857
|
}
|
|
1628
1858
|
canvasDraw.globalAlpha = temp;
|
|
1629
1859
|
parent.currObjType.isText = false;
|
|
1630
1860
|
};
|
|
1631
1861
|
Draw.prototype.shapeText = function (canvasDraw) {
|
|
1862
|
+
var parent = this.parent;
|
|
1632
1863
|
var filter = canvasDraw.filter;
|
|
1864
|
+
var actObj = parent.activeObj;
|
|
1865
|
+
var _a = actObj.activePoint, startX = _a.startX, startY = _a.startY, width = _a.width, height = _a.height;
|
|
1866
|
+
var rows = actObj.keyHistory.split('\n');
|
|
1867
|
+
var _b = actObj.textSettings, fontFamily = _b.fontFamily, bold = _b.bold, italic = _b.italic;
|
|
1868
|
+
var fontSize = actObj.textSettings.fontSize;
|
|
1869
|
+
var lHeight = fontSize + fontSize * 0.25;
|
|
1870
|
+
var lineHeight = ((lHeight * rows.length) - (fontSize * rows.length)) / rows.length;
|
|
1633
1871
|
canvasDraw.filter = 'none';
|
|
1634
|
-
var parent = this.parent;
|
|
1635
|
-
var actPoint = parent.activeObj.activePoint;
|
|
1636
|
-
var actObj = extend({}, parent.activeObj);
|
|
1637
|
-
var rows = parent.activeObj.keyHistory.split('\n');
|
|
1638
|
-
var height = parent.activeObj.textSettings.fontSize + parent.activeObj.textSettings.fontSize * 0.25;
|
|
1639
|
-
var lineHeight = ((height * rows.length) - (parent.activeObj.textSettings.fontSize * rows.length)) / rows.length;
|
|
1640
1872
|
for (var i = 0; i < rows.length; i++) {
|
|
1641
1873
|
var text = rows[i];
|
|
1642
|
-
var yPoint = ((i + 1) *
|
|
1874
|
+
var yPoint = ((i + 1) * fontSize * 0.85) + (i * lineHeight);
|
|
1643
1875
|
if (parent.transform.degree === -360) {
|
|
1644
1876
|
parent.transform.degree = 0;
|
|
1645
1877
|
}
|
|
1646
1878
|
if (parent.transform.degree === 0 || parent.transform.degree === 180) {
|
|
1647
|
-
if (
|
|
1648
|
-
|
|
1649
|
-
(actPoint.height * 0.1);
|
|
1879
|
+
if (fontSize > height) {
|
|
1880
|
+
fontSize = actObj.textSettings.fontSize = height - (height * 0.1);
|
|
1650
1881
|
}
|
|
1651
1882
|
}
|
|
1652
1883
|
else {
|
|
1653
|
-
if (
|
|
1654
|
-
|
|
1655
|
-
(actPoint.width * 0.1);
|
|
1884
|
+
if (fontSize > width) {
|
|
1885
|
+
fontSize = actObj.textSettings.fontSize = width - (width * 0.1);
|
|
1656
1886
|
}
|
|
1657
1887
|
}
|
|
1658
|
-
canvasDraw.strokeStyle =
|
|
1659
|
-
canvasDraw.fillStyle =
|
|
1888
|
+
canvasDraw.strokeStyle = actObj.strokeSettings.strokeColor;
|
|
1889
|
+
canvasDraw.fillStyle = actObj.strokeSettings.strokeColor;
|
|
1660
1890
|
var textStyle = '';
|
|
1661
|
-
if (
|
|
1891
|
+
if (bold) {
|
|
1662
1892
|
textStyle = 'bold ';
|
|
1663
1893
|
}
|
|
1664
|
-
if (
|
|
1894
|
+
if (italic) {
|
|
1665
1895
|
textStyle = 'italic ';
|
|
1666
1896
|
}
|
|
1667
|
-
if (
|
|
1897
|
+
if (bold && italic) {
|
|
1668
1898
|
textStyle = 'italic bold ';
|
|
1669
1899
|
}
|
|
1670
|
-
canvasDraw.font = textStyle +
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
parent.activeObj.shapeFlip = '';
|
|
1900
|
+
canvasDraw.font = textStyle + fontSize + 'px' + ' ' + fontFamily;
|
|
1901
|
+
if (actObj.flipObjColl.length === 4) {
|
|
1902
|
+
actObj.flipObjColl = [];
|
|
1903
|
+
actObj.shapeFlip = '';
|
|
1675
1904
|
}
|
|
1676
1905
|
if (actObj.rotateFlipColl && actObj.rotateFlipColl.length > 0) {
|
|
1677
1906
|
this.rotateText(canvasDraw);
|
|
1678
1907
|
}
|
|
1679
1908
|
else {
|
|
1680
|
-
canvasDraw.fillText(text,
|
|
1909
|
+
canvasDraw.fillText(text, startX + fontSize * 0.1, startY + yPoint);
|
|
1681
1910
|
}
|
|
1682
1911
|
}
|
|
1683
1912
|
canvasDraw.filter = filter;
|
|
@@ -1685,32 +1914,34 @@ var Draw = /** @class */ (function () {
|
|
|
1685
1914
|
};
|
|
1686
1915
|
Draw.prototype.updateActPoint = function (degree, canvasDraw) {
|
|
1687
1916
|
var parent = this.parent;
|
|
1688
|
-
var
|
|
1917
|
+
var actObj = parent.activeObj;
|
|
1918
|
+
var actPoint = actObj.activePoint;
|
|
1689
1919
|
if (degree.toLowerCase() === 'horizontal') {
|
|
1690
1920
|
if (actPoint.startX <= canvasDraw.canvas.width / 2) {
|
|
1691
|
-
actPoint.startX = canvasDraw.canvas.width / 2 + ((canvasDraw.canvas.width / 2) -
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
this.updateActiveObject(actPoint, parent.activeObj);
|
|
1921
|
+
actPoint.startX = canvasDraw.canvas.width / 2 + ((canvasDraw.canvas.width / 2) - actPoint.endX);
|
|
1922
|
+
actPoint.endX = actPoint.startX + actPoint.width;
|
|
1923
|
+
this.updateActiveObject(actPoint, actObj);
|
|
1924
|
+
parent.activeObj = actObj;
|
|
1696
1925
|
}
|
|
1697
1926
|
else if (actPoint.startX >= canvasDraw.canvas.width / 2) {
|
|
1698
1927
|
actPoint.startX = canvasDraw.canvas.width - actPoint.endX;
|
|
1699
|
-
actPoint.endX = actPoint.startX +
|
|
1700
|
-
|
|
1701
|
-
|
|
1928
|
+
actPoint.endX = actPoint.startX + actPoint.width;
|
|
1929
|
+
this.updateActiveObject(actPoint, actObj);
|
|
1930
|
+
parent.activeObj = actObj;
|
|
1702
1931
|
}
|
|
1703
1932
|
}
|
|
1704
1933
|
else if (degree.toLowerCase() === 'vertical') {
|
|
1705
1934
|
if (actPoint.startY <= canvasDraw.canvas.height / 2) {
|
|
1706
1935
|
actPoint.startY = canvasDraw.canvas.height / 2 + ((canvasDraw.canvas.height / 2) - actPoint.endY);
|
|
1707
1936
|
actPoint.endY = actPoint.startY + actPoint.height;
|
|
1708
|
-
this.updateActiveObject(actPoint,
|
|
1937
|
+
this.updateActiveObject(actPoint, actObj);
|
|
1938
|
+
parent.activeObj = actObj;
|
|
1709
1939
|
}
|
|
1710
1940
|
else if (actPoint.startY >= canvasDraw.canvas.height / 2) {
|
|
1711
1941
|
actPoint.startY = canvasDraw.canvas.height - actPoint.endY;
|
|
1712
1942
|
actPoint.endY = actPoint.startY + actPoint.height;
|
|
1713
|
-
this.updateActiveObject(actPoint,
|
|
1943
|
+
this.updateActiveObject(actPoint, actObj);
|
|
1944
|
+
parent.activeObj = actObj;
|
|
1714
1945
|
}
|
|
1715
1946
|
}
|
|
1716
1947
|
return actPoint;
|
|
@@ -1720,11 +1951,11 @@ var Draw = /** @class */ (function () {
|
|
|
1720
1951
|
var degree;
|
|
1721
1952
|
var actObj = parent.activeObj;
|
|
1722
1953
|
var tempActiveObj = extend({}, parent.activeObj, null, true);
|
|
1723
|
-
if (
|
|
1954
|
+
if (actObj.shapeDegree === 0) {
|
|
1724
1955
|
degree = parent.transform.degree;
|
|
1725
1956
|
}
|
|
1726
1957
|
else {
|
|
1727
|
-
degree = parent.transform.degree -
|
|
1958
|
+
degree = parent.transform.degree - actObj.shapeDegree;
|
|
1728
1959
|
}
|
|
1729
1960
|
if (degree === -450) {
|
|
1730
1961
|
degree = -90;
|
|
@@ -1733,11 +1964,11 @@ var Draw = /** @class */ (function () {
|
|
|
1733
1964
|
degree = 360 + degree;
|
|
1734
1965
|
}
|
|
1735
1966
|
var imgPoint = { startX: 0, startY: 0, width: 0, height: 0 };
|
|
1736
|
-
imgPoint.width = degree % 90 === 0 && degree % 180 !== 0 ?
|
|
1737
|
-
imgPoint.height = degree % 90 === 0 && degree % 180 !== 0 ?
|
|
1738
|
-
|
|
1739
|
-
imgPoint.startX =
|
|
1740
|
-
imgPoint.startY =
|
|
1967
|
+
imgPoint.width = degree % 90 === 0 && degree % 180 !== 0 ? actObj.activePoint.height : actObj.activePoint.width;
|
|
1968
|
+
imgPoint.height = degree % 90 === 0 && degree % 180 !== 0 ? actObj.activePoint.width :
|
|
1969
|
+
actObj.activePoint.height;
|
|
1970
|
+
imgPoint.startX = actObj.activePoint.startX;
|
|
1971
|
+
imgPoint.startY = actObj.activePoint.startY;
|
|
1741
1972
|
var startX = imgPoint.startX;
|
|
1742
1973
|
var startY = imgPoint.startY;
|
|
1743
1974
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
@@ -1767,7 +1998,7 @@ var Draw = /** @class */ (function () {
|
|
|
1767
1998
|
canvasDraw.translate(canvasDraw.canvas.width / 2, canvasDraw.canvas.height / 2);
|
|
1768
1999
|
canvasDraw.rotate(Math.PI / 180 * coll);
|
|
1769
2000
|
canvasDraw.translate(-canvasDraw.canvas.height / 2, -canvasDraw.canvas.width / 2);
|
|
1770
|
-
if (tempDegree % 90 === 0 && tempDegree % 270 !== 0) {
|
|
2001
|
+
if ((tempDegree % 90 === 0 && tempDegree % 270 !== 0) || tempDegree === 0) {
|
|
1771
2002
|
startY = canvasDraw.canvas.width - (actObj.activePoint.startX + actObj.activePoint.width);
|
|
1772
2003
|
startY += ((actObj.activePoint.width - imgPoint.height) / 2);
|
|
1773
2004
|
startX = imgPoint.startY;
|
|
@@ -1825,11 +2056,12 @@ var Draw = /** @class */ (function () {
|
|
|
1825
2056
|
var degree;
|
|
1826
2057
|
var actObj = parent.activeObj;
|
|
1827
2058
|
var tempActiveObj = extend({}, parent.activeObj, null, true);
|
|
1828
|
-
|
|
2059
|
+
var actPoint = parent.activeObj.activePoint;
|
|
2060
|
+
if (actObj.shapeDegree === 0) {
|
|
1829
2061
|
degree = parent.transform.degree;
|
|
1830
2062
|
}
|
|
1831
2063
|
else {
|
|
1832
|
-
degree = parent.transform.degree -
|
|
2064
|
+
degree = parent.transform.degree - actObj.shapeDegree;
|
|
1833
2065
|
}
|
|
1834
2066
|
if (degree === -450) {
|
|
1835
2067
|
degree = -90;
|
|
@@ -1838,11 +2070,10 @@ var Draw = /** @class */ (function () {
|
|
|
1838
2070
|
degree = 360 + degree;
|
|
1839
2071
|
}
|
|
1840
2072
|
var imgPoint = { startX: 0, startY: 0, width: 0, height: 0 };
|
|
1841
|
-
imgPoint.width = degree % 90 === 0 && degree % 180 !== 0 ?
|
|
1842
|
-
imgPoint.height = degree % 90 === 0 && degree % 180 !== 0 ?
|
|
1843
|
-
|
|
1844
|
-
imgPoint.
|
|
1845
|
-
imgPoint.startY = actObj.activePoint.startY;
|
|
2073
|
+
imgPoint.width = degree % 90 === 0 && degree % 180 !== 0 ? actPoint.height : actPoint.width;
|
|
2074
|
+
imgPoint.height = degree % 90 === 0 && degree % 180 !== 0 ? actPoint.width : actPoint.height;
|
|
2075
|
+
imgPoint.startX = actPoint.startX;
|
|
2076
|
+
imgPoint.startY = actPoint.startY;
|
|
1846
2077
|
var startX = imgPoint.startX;
|
|
1847
2078
|
var startY = imgPoint.startY;
|
|
1848
2079
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
@@ -1866,26 +2097,25 @@ var Draw = /** @class */ (function () {
|
|
|
1866
2097
|
if (tempDegree < 0) {
|
|
1867
2098
|
tempDegree = 360 + tempDegree;
|
|
1868
2099
|
}
|
|
1869
|
-
imgPoint.width = tempDegree % 90 === 0 && tempDegree % 180 !== 0 ?
|
|
1870
|
-
imgPoint.height = tempDegree % 90 === 0 && tempDegree % 180 !== 0 ?
|
|
1871
|
-
actObj.activePoint.height;
|
|
2100
|
+
imgPoint.width = tempDegree % 90 === 0 && tempDegree % 180 !== 0 ? actPoint.height : actPoint.width;
|
|
2101
|
+
imgPoint.height = tempDegree % 90 === 0 && tempDegree % 180 !== 0 ? actPoint.width : actPoint.height;
|
|
1872
2102
|
canvasDraw.translate(canvasDraw.canvas.width / 2, canvasDraw.canvas.height / 2);
|
|
1873
2103
|
canvasDraw.rotate(Math.PI / 180 * coll);
|
|
1874
2104
|
canvasDraw.translate(-canvasDraw.canvas.height / 2, -canvasDraw.canvas.width / 2);
|
|
1875
|
-
if (tempDegree % 90 === 0 && tempDegree % 270 !== 0) {
|
|
1876
|
-
startY = (
|
|
1877
|
-
startX =
|
|
2105
|
+
if ((tempDegree % 90 === 0 && tempDegree % 270 !== 0) || tempDegree === 0) {
|
|
2106
|
+
startY = (canvasDraw.canvas.width - actPoint.endX);
|
|
2107
|
+
startX = actPoint.startY;
|
|
1878
2108
|
}
|
|
1879
2109
|
else if (tempDegree % 270 === 0) {
|
|
1880
|
-
startX =
|
|
1881
|
-
startY =
|
|
2110
|
+
startX = canvasDraw.canvas.height - actPoint.endY;
|
|
2111
|
+
startY = actPoint.startX;
|
|
1882
2112
|
}
|
|
1883
2113
|
imgPoint.startX = startX;
|
|
1884
2114
|
imgPoint.startY = startY;
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
2115
|
+
actPoint.startX = startX;
|
|
2116
|
+
actPoint.startY = startY;
|
|
2117
|
+
actPoint.endX = actPoint.startX + imgPoint.width;
|
|
2118
|
+
actPoint.endY = actPoint.startY + imgPoint.height;
|
|
1889
2119
|
actObj = this.updateWidthHeight(actObj);
|
|
1890
2120
|
}
|
|
1891
2121
|
else {
|
|
@@ -1898,18 +2128,17 @@ var Draw = /** @class */ (function () {
|
|
|
1898
2128
|
if (coll === 'horizontal') {
|
|
1899
2129
|
canvasDraw.translate(canvasDraw.canvas.width, 0);
|
|
1900
2130
|
canvasDraw.scale(-1, 1);
|
|
1901
|
-
actObj.activePoint = this.updateActPoint('horizontal', canvasDraw);
|
|
1902
2131
|
}
|
|
1903
2132
|
else if (coll === 'vertical') {
|
|
1904
2133
|
canvasDraw.translate(0, canvasDraw.canvas.height);
|
|
1905
2134
|
canvasDraw.scale(1, -1);
|
|
1906
|
-
actObj.activePoint = this.updateActPoint('vertical', canvasDraw);
|
|
1907
2135
|
}
|
|
1908
|
-
|
|
1909
|
-
imgPoint.
|
|
2136
|
+
actObj.activePoint = actPoint = this.updateActPoint(coll, canvasDraw);
|
|
2137
|
+
imgPoint.startX = actPoint.startX;
|
|
2138
|
+
imgPoint.startY = actPoint.startY;
|
|
1910
2139
|
}
|
|
1911
|
-
imgPoint.startX =
|
|
1912
|
-
imgPoint.startY =
|
|
2140
|
+
imgPoint.startX = actPoint.startX;
|
|
2141
|
+
imgPoint.startY = actPoint.startY;
|
|
1913
2142
|
startX = imgPoint.startX;
|
|
1914
2143
|
startY = imgPoint.startY;
|
|
1915
2144
|
}
|
|
@@ -1926,36 +2155,32 @@ var Draw = /** @class */ (function () {
|
|
|
1926
2155
|
};
|
|
1927
2156
|
Draw.prototype.textFlipDegree = function (canvasDraw, startX, startY) {
|
|
1928
2157
|
var parent = this.parent;
|
|
1929
|
-
var
|
|
1930
|
-
var
|
|
1931
|
-
var
|
|
1932
|
-
var
|
|
1933
|
-
|
|
2158
|
+
var actObj = parent.activeObj;
|
|
2159
|
+
var rows = actObj.keyHistory.split('\n');
|
|
2160
|
+
var fontSize = actObj.textSettings.fontSize;
|
|
2161
|
+
var lineHeight = ((fontSize * rows.length) - (fontSize * rows.length)) / rows.length;
|
|
2162
|
+
var yPoint = (fontSize * 0.85) + lineHeight;
|
|
2163
|
+
for (var i = 0, len = rows.length; i < len; i++) {
|
|
1934
2164
|
var text = rows[i];
|
|
1935
2165
|
if (i > 0) {
|
|
1936
2166
|
if (i === 1) {
|
|
1937
|
-
yPoint -= (
|
|
2167
|
+
yPoint -= (fontSize * 0.85);
|
|
1938
2168
|
}
|
|
1939
|
-
yPoint +=
|
|
2169
|
+
yPoint += fontSize + fontSize * 0.15;
|
|
1940
2170
|
}
|
|
1941
|
-
canvasDraw.fillText(text, startX +
|
|
1942
|
-
yPoint + (i > 0 ?
|
|
2171
|
+
canvasDraw.fillText(text, startX + fontSize * 0.15, startY +
|
|
2172
|
+
yPoint + (i > 0 ? fontSize * 0.25 : -fontSize * 0.35));
|
|
1943
2173
|
}
|
|
1944
2174
|
};
|
|
1945
2175
|
Draw.prototype.clearOuterCanvas = function (context) {
|
|
1946
2176
|
var parent = this.parent;
|
|
1947
|
-
var
|
|
1948
|
-
var
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
if (parent.img.destHeight < parent.lowerCanvas.height) {
|
|
1955
|
-
var top_1 = parent.img.destTop > 0 ? parent.img.destTop : 0;
|
|
1956
|
-
context.clearRect(0, 0, parent.lowerCanvas.width, top_1);
|
|
1957
|
-
context.clearRect(0, parent.img.destTop + parent.img.destHeight, parent.lowerCanvas.width, top_1);
|
|
1958
|
-
}
|
|
2177
|
+
var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
|
|
2178
|
+
var left = destLeft > 0 ? destLeft : 0;
|
|
2179
|
+
var top = destTop > 0 ? destTop : 0;
|
|
2180
|
+
context.clearRect(0, 0, left, parent.lowerCanvas.height);
|
|
2181
|
+
context.clearRect(destLeft + destWidth, 0, parent.lowerCanvas.width - (destLeft + destWidth), parent.lowerCanvas.height);
|
|
2182
|
+
context.clearRect(0, 0, parent.lowerCanvas.width, top);
|
|
2183
|
+
context.clearRect(0, destTop + destHeight, parent.lowerCanvas.width, parent.lowerCanvas.height - (destTop + destHeight));
|
|
1959
2184
|
if (parent.transform.currFlipState !== '') {
|
|
1960
2185
|
parent.img.destLeft = destLeft;
|
|
1961
2186
|
parent.img.destTop = destTop;
|
|
@@ -1964,19 +2189,20 @@ var Draw = /** @class */ (function () {
|
|
|
1964
2189
|
Draw.prototype.setDestPoints = function () {
|
|
1965
2190
|
var maxDimension;
|
|
1966
2191
|
var parent = this.parent;
|
|
1967
|
-
|
|
2192
|
+
var _a = parent.transform, degree = _a.degree, zoomFactor = _a.zoomFactor;
|
|
2193
|
+
if (degree % 90 === 0 && degree % 180 !== 0) {
|
|
1968
2194
|
var obj = { width: 0, height: 0 };
|
|
1969
2195
|
parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
|
|
1970
2196
|
value: { width: parent.img.srcHeight, height: parent.img.srcWidth, obj: obj, isImgShape: null } });
|
|
1971
2197
|
maxDimension = obj;
|
|
1972
2198
|
if (this.isRotateZoom) {
|
|
1973
|
-
maxDimension.width += (maxDimension.width *
|
|
1974
|
-
maxDimension.height += (maxDimension.height *
|
|
2199
|
+
maxDimension.width += (maxDimension.width * zoomFactor);
|
|
2200
|
+
maxDimension.height += (maxDimension.height * zoomFactor);
|
|
1975
2201
|
parent.img.destWidth = maxDimension.height;
|
|
1976
2202
|
parent.img.destHeight = maxDimension.width;
|
|
1977
2203
|
}
|
|
1978
2204
|
parent.img.destLeft = (parent.lowerCanvas.clientWidth - maxDimension.height) / 2;
|
|
1979
|
-
parent.img.destTop = (parent.lowerCanvas.clientHeight - maxDimension.width) / 2;
|
|
2205
|
+
parent.img.destTop = (parent.lowerCanvas.clientHeight - maxDimension.width + 1) / 2;
|
|
1980
2206
|
parent.img.destWidth = maxDimension.height;
|
|
1981
2207
|
parent.img.destHeight = maxDimension.width;
|
|
1982
2208
|
}
|
|
@@ -1986,18 +2212,18 @@ var Draw = /** @class */ (function () {
|
|
|
1986
2212
|
value: { width: parent.img.srcWidth, height: parent.img.srcHeight, obj: obj, isImgShape: null } });
|
|
1987
2213
|
maxDimension = obj;
|
|
1988
2214
|
if (this.isRotateZoom) {
|
|
1989
|
-
maxDimension.width += (maxDimension.width *
|
|
1990
|
-
maxDimension.height += (maxDimension.height *
|
|
2215
|
+
maxDimension.width += (maxDimension.width * zoomFactor);
|
|
2216
|
+
maxDimension.height += (maxDimension.height * zoomFactor);
|
|
1991
2217
|
parent.img.destWidth = maxDimension.width;
|
|
1992
2218
|
parent.img.destHeight = maxDimension.height;
|
|
1993
2219
|
}
|
|
1994
2220
|
parent.img.destLeft = (parent.lowerCanvas.clientWidth - maxDimension.width) / 2;
|
|
1995
|
-
parent.img.destTop = (parent.lowerCanvas.clientHeight - maxDimension.height) / 2;
|
|
2221
|
+
parent.img.destTop = (parent.lowerCanvas.clientHeight - maxDimension.height + 1) / 2;
|
|
1996
2222
|
parent.img.destWidth = maxDimension.width;
|
|
1997
2223
|
parent.img.destHeight = maxDimension.height;
|
|
1998
2224
|
}
|
|
1999
2225
|
};
|
|
2000
|
-
Draw.prototype.updateCurrTransState = function (type, isPreventDestination, isRotatePan) {
|
|
2226
|
+
Draw.prototype.updateCurrTransState = function (type, isPreventDestination, isRotatePan, isStraighten) {
|
|
2001
2227
|
var parent = this.parent;
|
|
2002
2228
|
var destLeft = parent.img.destLeft;
|
|
2003
2229
|
var destTop = parent.img.destTop;
|
|
@@ -2009,7 +2235,8 @@ var Draw = /** @class */ (function () {
|
|
|
2009
2235
|
}
|
|
2010
2236
|
if (parent.isCircleCrop || (parent.currSelectionPoint && parent.currSelectionPoint.shape === 'crop-circle')) {
|
|
2011
2237
|
this.currTransState(type, true, null, isRotatePan);
|
|
2012
|
-
if (parent.transform.degree === 0 && parent.transform.currFlipState === ''
|
|
2238
|
+
if (parent.transform.degree === 0 && parent.transform.currFlipState === '' && parent.transform.straighten === 0 &&
|
|
2239
|
+
isNullOrUndefined(isStraighten)) {
|
|
2013
2240
|
parent.img.destLeft = destLeft;
|
|
2014
2241
|
parent.img.destTop = destTop;
|
|
2015
2242
|
}
|
|
@@ -2028,7 +2255,8 @@ var Draw = /** @class */ (function () {
|
|
|
2028
2255
|
}
|
|
2029
2256
|
else {
|
|
2030
2257
|
this.currTransState(type, null, null, isRotatePan);
|
|
2031
|
-
if (parent.transform.degree === 0 && parent.transform.currFlipState === ''
|
|
2258
|
+
if (parent.transform.degree === 0 && parent.transform.currFlipState === '' && parent.transform.straighten === 0 &&
|
|
2259
|
+
isNullOrUndefined(isStraighten)) {
|
|
2032
2260
|
parent.img.destLeft = destLeft;
|
|
2033
2261
|
parent.img.destTop = destTop;
|
|
2034
2262
|
}
|
|
@@ -2127,7 +2355,7 @@ var Draw = /** @class */ (function () {
|
|
|
2127
2355
|
}
|
|
2128
2356
|
this.lowerContext.filter = temp;
|
|
2129
2357
|
};
|
|
2130
|
-
Draw.prototype.renderImage = function (isMouseWheel, isPreventClearRect, isFrame) {
|
|
2358
|
+
Draw.prototype.renderImage = function (isMouseWheel, isPreventClearRect, isFrame, isStraighten) {
|
|
2131
2359
|
var parent = this.parent;
|
|
2132
2360
|
var temp = this.lowerContext.filter;
|
|
2133
2361
|
parent.notify('shape', { prop: 'applyActObj', onPropertyChange: false, value: { isMouseDown: null } });
|
|
@@ -2142,7 +2370,7 @@ var Draw = /** @class */ (function () {
|
|
|
2142
2370
|
if (parent.transform.zoomFactor !== 0) {
|
|
2143
2371
|
this.isRotateZoom = true;
|
|
2144
2372
|
}
|
|
2145
|
-
this.updateCurrTransState('initial');
|
|
2373
|
+
this.updateCurrTransState('initial', null, null, isStraighten);
|
|
2146
2374
|
}
|
|
2147
2375
|
parent.notify('transform', { prop: 'setDestPointsForFlipState', onPropertyChange: false });
|
|
2148
2376
|
this.drawImage();
|
|
@@ -2151,10 +2379,9 @@ var Draw = /** @class */ (function () {
|
|
|
2151
2379
|
this.setTransformColl(this.lowerContext, 'reverse');
|
|
2152
2380
|
}
|
|
2153
2381
|
else {
|
|
2154
|
-
this.updateCurrTransState('reverse');
|
|
2382
|
+
this.updateCurrTransState('reverse', null, null, isStraighten);
|
|
2155
2383
|
this.isRotateZoom = false;
|
|
2156
2384
|
}
|
|
2157
|
-
this.lowerContext.filter = 'none';
|
|
2158
2385
|
if (isFrame) {
|
|
2159
2386
|
parent.notify('shape', { prop: 'zoomObjColl', onPropertyChange: false, value: { isPreventApply: null } });
|
|
2160
2387
|
parent.notify('freehand-draw', { prop: 'zoomFHDColl', onPropertyChange: false, value: { isPreventApply: null } });
|
|
@@ -2164,7 +2391,6 @@ var Draw = /** @class */ (function () {
|
|
|
2164
2391
|
parent.notify('freehand-draw', { prop: 'freehandRedraw', onPropertyChange: false,
|
|
2165
2392
|
value: { context: this.lowerContext, points: null } });
|
|
2166
2393
|
}
|
|
2167
|
-
this.lowerContext.filter = temp;
|
|
2168
2394
|
this.clearOuterCanvas(this.lowerContext);
|
|
2169
2395
|
if (parent.isCircleCrop || (parent.currSelectionPoint && parent.currSelectionPoint.shape === 'crop-circle')) {
|
|
2170
2396
|
parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
|
|
@@ -2193,7 +2419,8 @@ var Draw = /** @class */ (function () {
|
|
|
2193
2419
|
if (Browser.isDevice) {
|
|
2194
2420
|
parent.notify('toolbar', { prop: 'destroy-top-toolbar', onPropertyChange: false });
|
|
2195
2421
|
parent.notify('toolbar', { prop: 'destroy-bottom-toolbar', onPropertyChange: false });
|
|
2196
|
-
var eventargs = { isApplyBtn: false, isDevice: Browser.isDevice, isOkBtn: null
|
|
2422
|
+
var eventargs = { isApplyBtn: false, isDevice: Browser.isDevice, isOkBtn: null,
|
|
2423
|
+
isResize: null, isFrame: null, isMainToolbar: true };
|
|
2197
2424
|
parent.notify('toolbar', { prop: 'init-main-toolbar', onPropertyChange: false, value: eventargs });
|
|
2198
2425
|
parent.notify('toolbar', { prop: 'create-bottom-toolbar', onPropertyChange: false });
|
|
2199
2426
|
}
|
|
@@ -2208,14 +2435,12 @@ var Draw = /** @class */ (function () {
|
|
|
2208
2435
|
if (Browser.isDevice) {
|
|
2209
2436
|
parent.element.querySelector('.e-bottom-toolbar-area').style.display = 'block';
|
|
2210
2437
|
parent.element.querySelector('.e-canvas-wrapper').style.height = (parent.element.offsetHeight
|
|
2211
|
-
- parent.toolbarHeight * 2) -
|
|
2438
|
+
- parent.toolbarHeight * 2) - 1 + 'px';
|
|
2212
2439
|
}
|
|
2213
2440
|
}
|
|
2214
2441
|
};
|
|
2215
2442
|
parent.baseImg.onerror = function () {
|
|
2216
2443
|
hideSpinner(parent.element);
|
|
2217
|
-
// proxy.reset();
|
|
2218
|
-
// proxy.parent.baseImg.src = proxy.baseImgSrc;
|
|
2219
2444
|
proxy.isErrorImage = true;
|
|
2220
2445
|
proxy.errorLoading();
|
|
2221
2446
|
};
|
|
@@ -2246,7 +2471,7 @@ var Draw = /** @class */ (function () {
|
|
|
2246
2471
|
value: { width: parent.img.srcWidth, height: parent.img.srcHeight, obj: obj, isImgShape: null } });
|
|
2247
2472
|
var maxDimension = obj;
|
|
2248
2473
|
parent.img.destLeft = (parent.lowerCanvas.clientWidth - maxDimension.width) / 2;
|
|
2249
|
-
parent.img.destTop = (parent.lowerCanvas.clientHeight - maxDimension.height) / 2;
|
|
2474
|
+
parent.img.destTop = (parent.lowerCanvas.clientHeight - maxDimension.height + 1) / 2;
|
|
2250
2475
|
this.drawImgToCanvas(maxDimension);
|
|
2251
2476
|
this.origDim.width = parent.img.destWidth;
|
|
2252
2477
|
this.origDim.height = parent.img.destHeight;
|
|
@@ -2290,7 +2515,7 @@ var Draw = /** @class */ (function () {
|
|
|
2290
2515
|
}
|
|
2291
2516
|
this.isImageEdited = false;
|
|
2292
2517
|
};
|
|
2293
|
-
Draw.prototype.resetFrameZoom = function () {
|
|
2518
|
+
Draw.prototype.resetFrameZoom = function (isOk) {
|
|
2294
2519
|
var parent = this.parent;
|
|
2295
2520
|
if (!isNullOrUndefined(parent.tempFrameZoomLevel)) {
|
|
2296
2521
|
var temp = parent.tempFrameZoomLevel;
|
|
@@ -2298,10 +2523,19 @@ var Draw = /** @class */ (function () {
|
|
|
2298
2523
|
parent.notify('transform', { prop: 'resetZoom', onPropertyChange: false });
|
|
2299
2524
|
parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
2300
2525
|
value: { zoomFactor: temp, zoomPoint: null, isResize: true } });
|
|
2526
|
+
var obj = parent.cancelCropSelection;
|
|
2527
|
+
if (isOk && obj) {
|
|
2528
|
+
obj.previousObj.frameObj = extend({}, parent.frameObj, null, true);
|
|
2529
|
+
obj.currentObj.frameObj = extend({}, parent.frameObj, null, true);
|
|
2530
|
+
obj.previousObj.frame = obj.currentObj.frame = parent.frameObj.type;
|
|
2531
|
+
}
|
|
2532
|
+
this.updateCropSelObj();
|
|
2533
|
+
parent.cancelCropSelection = null;
|
|
2301
2534
|
}
|
|
2302
2535
|
};
|
|
2303
2536
|
Draw.prototype.performCancel = function (isContextualToolbar) {
|
|
2304
2537
|
var parent = this.parent;
|
|
2538
|
+
var straightenObj = { bool: parent.isStraightening };
|
|
2305
2539
|
isContextualToolbar = isContextualToolbar ? isContextualToolbar : false;
|
|
2306
2540
|
var obj = { bool: false };
|
|
2307
2541
|
parent.allowDownScale = true;
|
|
@@ -2310,7 +2544,7 @@ var Draw = /** @class */ (function () {
|
|
|
2310
2544
|
extend(parent.frameObj, parent.tempFrameObj);
|
|
2311
2545
|
this.renderImage(null, null, true);
|
|
2312
2546
|
}
|
|
2313
|
-
this.resetFrameZoom();
|
|
2547
|
+
this.resetFrameZoom(false);
|
|
2314
2548
|
if (obj['bool']) {
|
|
2315
2549
|
parent.notify('freehand-draw', { prop: 'cancelFhd', onPropertyChange: false });
|
|
2316
2550
|
if (!isBlazor()) {
|
|
@@ -2321,7 +2555,7 @@ var Draw = /** @class */ (function () {
|
|
|
2321
2555
|
}
|
|
2322
2556
|
parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'cancel' } });
|
|
2323
2557
|
}
|
|
2324
|
-
else if (parent.textArea.style.display === 'block') {
|
|
2558
|
+
else if (parent.textArea.style.display === 'block' || parent.textArea.style.display === 'inline-block') {
|
|
2325
2559
|
parent.textArea.style.display = 'none';
|
|
2326
2560
|
parent.textArea.value = '';
|
|
2327
2561
|
parent.textArea.style.transform = '';
|
|
@@ -2344,8 +2578,11 @@ var Draw = /** @class */ (function () {
|
|
|
2344
2578
|
else {
|
|
2345
2579
|
parent.updateToolbar(parent.element, 'imageLoaded');
|
|
2346
2580
|
}
|
|
2581
|
+
parent.notify('selection', { prop: 'setTempActObj', onPropertyChange: false, value: { obj: parent.activeObj } });
|
|
2347
2582
|
}
|
|
2348
|
-
else if ((!isBlazor() &&
|
|
2583
|
+
else if ((!isBlazor() && (!Browser.isDevice || (Browser.isDevice && !straightenObj['bool'])) &&
|
|
2584
|
+
document.querySelector('#' + parent.element.id + '_sliderWrapper')) ||
|
|
2585
|
+
(isBlazor() && !parent.element.querySelector('.e-ie-contextual-slider').classList.contains('e-hidden')) ||
|
|
2349
2586
|
parent.currObjType.isFiltered) {
|
|
2350
2587
|
this.lowerContext.filter = this.tempAdjValue;
|
|
2351
2588
|
parent.canvasFilter = this.tempAdjValue;
|
|
@@ -2356,6 +2593,7 @@ var Draw = /** @class */ (function () {
|
|
|
2356
2593
|
parent.notify('filter', { prop: 'setBrightnessAdjusted', onPropertyChange: false, value: { isBrightnessAdjusted: false } });
|
|
2357
2594
|
}
|
|
2358
2595
|
parent.currentFilter = this.tempFilter;
|
|
2596
|
+
parent.notify('filter', { prop: 'setBevelFilter', onPropertyChange: false, value: { bevelFilter: this.lowerContext.filter } });
|
|
2359
2597
|
this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
|
|
2360
2598
|
this.redrawImgWithObj();
|
|
2361
2599
|
parent.currObjType.isFiltered = false;
|
|
@@ -2383,7 +2621,7 @@ var Draw = /** @class */ (function () {
|
|
|
2383
2621
|
parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'cancel' } });
|
|
2384
2622
|
}
|
|
2385
2623
|
else {
|
|
2386
|
-
if (isContextualToolbar) {
|
|
2624
|
+
if (isContextualToolbar && (!Browser.isDevice || (Browser.isDevice && !straightenObj['bool']))) {
|
|
2387
2625
|
var eventargs = { type: 'main', isApplyBtn: null, isCropping: null, isZooming: null };
|
|
2388
2626
|
if (!isBlazor()) {
|
|
2389
2627
|
parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: eventargs });
|
|
@@ -2414,8 +2652,9 @@ var Draw = /** @class */ (function () {
|
|
|
2414
2652
|
Draw.prototype.cancelItems = function () {
|
|
2415
2653
|
var parent = this.parent;
|
|
2416
2654
|
var isCropSelection = false;
|
|
2417
|
-
var
|
|
2418
|
-
var
|
|
2655
|
+
var id = parent.element.id;
|
|
2656
|
+
var ascpectIcon = parent.element.querySelector('#' + id + '_aspectratio');
|
|
2657
|
+
var nonAspectIcon = parent.element.querySelector('#' + id + '_nonaspectratio');
|
|
2419
2658
|
var splitWords;
|
|
2420
2659
|
var shapes = ['rectangle', 'ellipse', 'line', 'arrow', 'path', 'image'];
|
|
2421
2660
|
if (parent.activeObj.shape !== undefined) {
|
|
@@ -2432,14 +2671,15 @@ var Draw = /** @class */ (function () {
|
|
|
2432
2671
|
parent.transform.zoomFactor = parent.transform.defaultZoomFactor;
|
|
2433
2672
|
}
|
|
2434
2673
|
if (parent.isResize) {
|
|
2435
|
-
|
|
2674
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
2675
|
+
if (ascpectIcon || nonAspectIcon || parent.currentToolbar === 'resize-toolbar') {
|
|
2436
2676
|
var obj = { width: null, height: null };
|
|
2437
2677
|
parent.notify('selection', { prop: 'getNumTextValue', onPropertyChange: false, value: { obj: obj } });
|
|
2438
2678
|
var point = { x: obj['width'], y: obj['height'] };
|
|
2439
|
-
var aspectRatioElement =
|
|
2440
|
-
var blrAspRatElem =
|
|
2441
|
-
if (point && point.x && point.y && !isNullOrUndefined(
|
|
2442
|
-
if (aspectRatioElement || (blrAspRatElem && !blrAspRatElem.classList.contains(
|
|
2679
|
+
var aspectRatioElement = parent.element.querySelector('#' + parent.element.id + '_aspectratio');
|
|
2680
|
+
var blrAspRatElem = parent.element.querySelector('.e-ie-toolbar-aspect-ratio-btn');
|
|
2681
|
+
if (point && point.x && point.y && !isNullOrUndefined(parent.aspectWidth)) {
|
|
2682
|
+
if (aspectRatioElement || (blrAspRatElem && !blrAspRatElem.classList.contains('e-hidden'))) {
|
|
2443
2683
|
parent.notify('transform', { prop: 'resizeImage', value: { width: parent.aspectWidth, height: parent.aspectHeight } });
|
|
2444
2684
|
}
|
|
2445
2685
|
else {
|
|
@@ -2451,8 +2691,8 @@ var Draw = /** @class */ (function () {
|
|
|
2451
2691
|
}
|
|
2452
2692
|
var obj1 = { prevCropObj: parent.prevCropObj };
|
|
2453
2693
|
var obj2 = { prevObj: parent.prevObj };
|
|
2454
|
-
|
|
2455
|
-
|
|
2694
|
+
parent.notify('toolbar', { prop: 'getPrevCropObj', onPropertyChange: false, value: { obj: obj1 } });
|
|
2695
|
+
parent.notify('toolbar', { prop: 'getPrevObj', onPropertyChange: false, value: { obj: obj2 } });
|
|
2456
2696
|
if (obj1['prevCropObj'] && obj2['prevObj']) {
|
|
2457
2697
|
parent.objColl = [];
|
|
2458
2698
|
parent.pointColl = [];
|
|
@@ -2462,13 +2702,14 @@ var Draw = /** @class */ (function () {
|
|
|
2462
2702
|
parent.objColl = obj2['prevObj']['objColl'];
|
|
2463
2703
|
parent.pointColl = obj2['prevObj']['pointColl'];
|
|
2464
2704
|
parent.freehandCounter = parent.pointColl.length;
|
|
2705
|
+
parent.transform.straighten = 0;
|
|
2465
2706
|
parent.notify('shape', { prop: 'zoomObjColl', onPropertyChange: false, value: { isPreventApply: null } });
|
|
2466
2707
|
parent.notify('freehand-draw', { prop: 'zoomFHDColl', onPropertyChange: false, value: { isPreventApply: null } });
|
|
2467
2708
|
var currObj = parent.currSelectionPoint ?
|
|
2468
2709
|
extend({}, parent.currSelectionPoint, {}, true) : null;
|
|
2469
|
-
|
|
2470
|
-
value: { zoomFactor: -
|
|
2471
|
-
|
|
2710
|
+
parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
2711
|
+
value: { zoomFactor: -parent.transform.zoomFactor, zoomPoint: null, isResize: true } });
|
|
2712
|
+
parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
2472
2713
|
value: { zoomFactor: obj2['prevObj']['defaultZoom'], zoomPoint: null, isResize: true } });
|
|
2473
2714
|
parent.currSelectionPoint = currObj;
|
|
2474
2715
|
if (obj2['prevObj'].zoomFactor) {
|
|
@@ -2479,24 +2720,30 @@ var Draw = /** @class */ (function () {
|
|
|
2479
2720
|
}
|
|
2480
2721
|
parent.isResize = false;
|
|
2481
2722
|
parent.notify('transform', { prop: 'setResizedImgAngle', onPropertyChange: false, value: { angle: null } });
|
|
2723
|
+
var temp = parent.isCropTab;
|
|
2724
|
+
parent.isCropTab = false;
|
|
2725
|
+
this.updateCropSelObj();
|
|
2726
|
+
parent.isCropTab = temp;
|
|
2482
2727
|
}
|
|
2483
2728
|
}
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2729
|
+
switch (true) {
|
|
2730
|
+
case parent.togglePen:
|
|
2731
|
+
this.cancelPen();
|
|
2732
|
+
break;
|
|
2733
|
+
case parent.activeObj.shape === 'text':
|
|
2734
|
+
this.cancelText(isCropSelection);
|
|
2735
|
+
break;
|
|
2736
|
+
case shapes.indexOf(parent.activeObj.shape) !== -1:
|
|
2737
|
+
this.cancelShape();
|
|
2738
|
+
break;
|
|
2739
|
+
case isCropSelection:
|
|
2740
|
+
this.cancelSelection();
|
|
2741
|
+
break;
|
|
2742
|
+
default:
|
|
2743
|
+
parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
|
|
2744
|
+
this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
|
|
2745
|
+
parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'cancel' } });
|
|
2746
|
+
break;
|
|
2500
2747
|
}
|
|
2501
2748
|
parent.notify('selection', { prop: 'setCurrentDrawingShape', onPropertyChange: false, value: { value: '' } });
|
|
2502
2749
|
parent.upperCanvas.style.cursor = parent.cursor = 'default';
|
|
@@ -2543,9 +2790,9 @@ var Draw = /** @class */ (function () {
|
|
|
2543
2790
|
var object = { appliedUndoRedoColl: [] };
|
|
2544
2791
|
parent.notify('undo-redo', { prop: 'getAppliedUndoRedoColl', value: { obj: object } });
|
|
2545
2792
|
var len = object['appliedUndoRedoColl'].length;
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2793
|
+
var appliedColl = object['appliedUndoRedoColl'][len - 1];
|
|
2794
|
+
if (this.prevActObj && appliedColl && appliedColl.currentObjColl.length &&
|
|
2795
|
+
appliedColl.currentObjColl[appliedColl.currentObjColl.length - 1].currIndex === this.prevActObj.currIndex) {
|
|
2549
2796
|
parent.activeObj = this.prevActObj;
|
|
2550
2797
|
this.prevActObj = null;
|
|
2551
2798
|
}
|
|
@@ -2575,7 +2822,7 @@ var Draw = /** @class */ (function () {
|
|
|
2575
2822
|
else {
|
|
2576
2823
|
parent.updateToolbar(parent.element, 'destroyQuickAccessToolbar');
|
|
2577
2824
|
}
|
|
2578
|
-
this.tempTextSettings = { text: 'Enter Text', fontFamily:
|
|
2825
|
+
this.tempTextSettings = { text: 'Enter Text', fontFamily: parent.fontFamily.default, fontSize: null, fontRatio: null, bold: false,
|
|
2579
2826
|
italic: false, underline: false };
|
|
2580
2827
|
};
|
|
2581
2828
|
Draw.prototype.cancelShape = function () {
|
|
@@ -2595,11 +2842,12 @@ var Draw = /** @class */ (function () {
|
|
|
2595
2842
|
var object = { appliedUndoRedoColl: [] };
|
|
2596
2843
|
parent.notify('undo-redo', { prop: 'getAppliedUndoRedoColl', value: { obj: object } });
|
|
2597
2844
|
var obj = void 0;
|
|
2598
|
-
for (var i = 0
|
|
2599
|
-
|
|
2845
|
+
for (var i = 0, iLen = object['appliedUndoRedoColl'].length; i < iLen; i++) {
|
|
2846
|
+
var currObjColl = object['appliedUndoRedoColl'][i].currentObjColl;
|
|
2847
|
+
for (var j = 0, jLen = currObjColl.length; j < jLen; j++) {
|
|
2600
2848
|
if (this.prevActObj && this.prevActObj.currIndex &&
|
|
2601
|
-
|
|
2602
|
-
obj =
|
|
2849
|
+
currObjColl[j].currIndex === this.prevActObj.currIndex) {
|
|
2850
|
+
obj = currObjColl[0];
|
|
2603
2851
|
break;
|
|
2604
2852
|
}
|
|
2605
2853
|
}
|
|
@@ -2625,6 +2873,22 @@ var Draw = /** @class */ (function () {
|
|
|
2625
2873
|
}
|
|
2626
2874
|
};
|
|
2627
2875
|
Draw.prototype.cancelSelection = function () {
|
|
2876
|
+
var parent = this.parent;
|
|
2877
|
+
if (parent.cancelCropSelection) {
|
|
2878
|
+
var obj = { value: parent.tempStraighten };
|
|
2879
|
+
parent.transform.straighten = obj['value'];
|
|
2880
|
+
parent.straightenBaseImageCanvas();
|
|
2881
|
+
parent.notify('freehand-draw', { prop: 'resetStraightenPoint' });
|
|
2882
|
+
parent.notify('draw', { prop: 'render-image', value: { isMouseWheel: false } });
|
|
2883
|
+
parent.notify('draw', { prop: 'setStraightenActObj', value: { activeObj: parent.activeObj } });
|
|
2884
|
+
parent.notify('crop', { prop: 'resizeWrapper' });
|
|
2885
|
+
this.updateCropSelObj();
|
|
2886
|
+
if (this.tempStraightenDestPoints && JSON.stringify(this.tempStraightenDestPoints) !== JSON.stringify(this.straightenDestPoints)) {
|
|
2887
|
+
this.straightenDestPoints = extend({}, this.tempStraightenDestPoints, {}, true);
|
|
2888
|
+
}
|
|
2889
|
+
}
|
|
2890
|
+
};
|
|
2891
|
+
Draw.prototype.updateCropSelObj = function () {
|
|
2628
2892
|
var parent = this.parent;
|
|
2629
2893
|
if (parent.cancelCropSelection) {
|
|
2630
2894
|
parent.cropObj = extend({}, parent.cancelCropSelection.previousCropObj, {}, true);
|
|
@@ -2641,6 +2905,26 @@ var Draw = /** @class */ (function () {
|
|
|
2641
2905
|
}
|
|
2642
2906
|
}
|
|
2643
2907
|
};
|
|
2908
|
+
Draw.prototype.updateCropSelection = function () {
|
|
2909
|
+
var parent = this.parent;
|
|
2910
|
+
var object = { currObj: {} };
|
|
2911
|
+
parent.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
|
|
2912
|
+
var currentObj = object['currObj'];
|
|
2913
|
+
currentObj.objColl = extend([], parent.objColl, [], true);
|
|
2914
|
+
currentObj.pointColl = extend([], parent.pointColl, [], true);
|
|
2915
|
+
currentObj.afterCropActions = extend([], parent.afterCropActions, [], true);
|
|
2916
|
+
var selPointCollObj = { selPointColl: null };
|
|
2917
|
+
parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
|
|
2918
|
+
value: { obj: selPointCollObj } });
|
|
2919
|
+
currentObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
|
|
2920
|
+
parent.cancelCropSelection = { operation: 'cropTransform', previousObj: currentObj, currentObj: currentObj,
|
|
2921
|
+
previousObjColl: currentObj.objColl, currentObjColl: currentObj.objColl,
|
|
2922
|
+
previousPointColl: currentObj.pointColl, currentPointColl: currentObj.pointColl,
|
|
2923
|
+
previousSelPointColl: currentObj.selPointColl, currentSelPointColl: currentObj.selPointColl,
|
|
2924
|
+
previousCropObj: extend({}, parent.cropObj, {}, true),
|
|
2925
|
+
currentCropObj: extend({}, parent.cropObj, {}, true),
|
|
2926
|
+
previousText: null, currentText: null, filter: null, isCircleCrop: parent.isCircleCrop };
|
|
2927
|
+
};
|
|
2644
2928
|
Draw.prototype.updateFlipPan = function (tempSelectionObj) {
|
|
2645
2929
|
var parent = this.parent;
|
|
2646
2930
|
if (parent.transform.currFlipState !== '') {
|
|
@@ -2659,6 +2943,7 @@ var Draw = /** @class */ (function () {
|
|
|
2659
2943
|
};
|
|
2660
2944
|
Draw.prototype.select = function (type, startX, startY, width, height) {
|
|
2661
2945
|
var parent = this.parent;
|
|
2946
|
+
type = type.toLowerCase();
|
|
2662
2947
|
if (!parent.disabled && parent.isImageLoaded) {
|
|
2663
2948
|
parent.allowDownScale = false;
|
|
2664
2949
|
var object = { currObj: {} };
|
|
@@ -2718,11 +3003,20 @@ var Draw = /** @class */ (function () {
|
|
|
2718
3003
|
}
|
|
2719
3004
|
parent.transform.zoomFactor = parent.transform.cropZoomFactor;
|
|
2720
3005
|
if (isNullOrUndefined(parent.cropObj.activeObj.shape)) {
|
|
2721
|
-
parent.currObjType.shape = 'crop-' + type
|
|
3006
|
+
parent.currObjType.shape = 'crop-' + type;
|
|
2722
3007
|
this.drawNewSelection(type, startX, startY, width, height);
|
|
2723
3008
|
}
|
|
2724
3009
|
}
|
|
2725
3010
|
else {
|
|
3011
|
+
if (!this.isCropSelect) {
|
|
3012
|
+
parent.notify('crop', { prop: 'adjustStraightenForShapes', onPropertyChange: false,
|
|
3013
|
+
value: { type: 'reverse', isInitialRotated: true } });
|
|
3014
|
+
parent.notify('freehand-draw', { prop: 'updateFHDColl', onPropertyChange: false });
|
|
3015
|
+
this.renderImage();
|
|
3016
|
+
}
|
|
3017
|
+
else {
|
|
3018
|
+
this.isCropSelect = false;
|
|
3019
|
+
}
|
|
2726
3020
|
if (type === 'custom') {
|
|
2727
3021
|
parent.currObjType.shape = '';
|
|
2728
3022
|
}
|
|
@@ -2733,19 +3027,25 @@ var Draw = /** @class */ (function () {
|
|
|
2733
3027
|
Draw.prototype.drawNewSelection = function (type, startX, startY, width, height) {
|
|
2734
3028
|
var parent = this.parent;
|
|
2735
3029
|
var points;
|
|
2736
|
-
var cropShape = 'crop-' + type;
|
|
2737
|
-
if (cropShape
|
|
3030
|
+
var cropShape = 'crop-' + type.toLowerCase();
|
|
3031
|
+
if (cropShape === 'crop-custom') {
|
|
2738
3032
|
if (parent.currObjType.shape === '' || parent.currObjType.shape === 'crop-custom') {
|
|
2739
3033
|
this.drawCustomSelection('crop-custom', startX, startY, width, height);
|
|
3034
|
+
this.adjToStraighten();
|
|
3035
|
+
this.updateSelectionInsert();
|
|
3036
|
+
if (parent.isStraightening) {
|
|
3037
|
+
this.straightenActObj = extend({}, parent.activeObj, {}, true);
|
|
3038
|
+
this.straightenInitZoom = parent.transform.zoomFactor;
|
|
3039
|
+
}
|
|
2740
3040
|
}
|
|
2741
3041
|
}
|
|
2742
|
-
else if (cropShape
|
|
3042
|
+
else if (cropShape === 'crop-canvas') {
|
|
2743
3043
|
parent.upperCanvas.style.display = 'block';
|
|
2744
3044
|
parent.notify('selection', { prop: 'setDragCanvas', value: { bool: true } });
|
|
2745
3045
|
}
|
|
2746
3046
|
else {
|
|
2747
3047
|
parent.currObjType.isCustomCrop = false;
|
|
2748
|
-
parent.currObjType.shape = cropShape
|
|
3048
|
+
parent.currObjType.shape = cropShape;
|
|
2749
3049
|
if (width && height) {
|
|
2750
3050
|
points = { startX: startX, startY: startY, endX: startX + width, endY: startY + height,
|
|
2751
3051
|
width: width, height: height };
|
|
@@ -2754,7 +3054,7 @@ var Draw = /** @class */ (function () {
|
|
|
2754
3054
|
points = { startX: startX, startY: startY, endX: startX + width, endY: startY + width,
|
|
2755
3055
|
width: width, height: width };
|
|
2756
3056
|
}
|
|
2757
|
-
parent.activeObj.shape = cropShape
|
|
3057
|
+
parent.activeObj.shape = cropShape;
|
|
2758
3058
|
this.updateSelectionInsert(points);
|
|
2759
3059
|
}
|
|
2760
3060
|
};
|
|
@@ -2821,30 +3121,27 @@ var Draw = /** @class */ (function () {
|
|
|
2821
3121
|
}
|
|
2822
3122
|
else {
|
|
2823
3123
|
if (isNullOrUndefined(parent.transform.zoomFactor) || parent.transform.zoomFactor === 0) {
|
|
2824
|
-
var
|
|
2825
|
-
var imgTop_1 = parent.img.destTop;
|
|
2826
|
-
var imgWidth_1 = parent.img.destWidth;
|
|
2827
|
-
var imgHeight_1 = parent.img.destHeight;
|
|
3124
|
+
var _a = parent.img, destLeft_1 = _a.destLeft, destTop_1 = _a.destTop, destWidth_1 = _a.destWidth, destHeight_1 = _a.destHeight;
|
|
2828
3125
|
var lowerCanvasWidth_1 = parent.lowerCanvas.width;
|
|
2829
3126
|
var lowerCanvasHeight_1 = parent.lowerCanvas.height;
|
|
2830
3127
|
var activePoint_1 = actPoint;
|
|
2831
|
-
if (
|
|
2832
|
-
activePoint_1.startX =
|
|
2833
|
-
activePoint_1.startY =
|
|
2834
|
-
activePoint_1.endX =
|
|
2835
|
-
activePoint_1.endY =
|
|
2836
|
-
}
|
|
2837
|
-
else if (
|
|
2838
|
-
activePoint_1.startX =
|
|
3128
|
+
if (destLeft_1 >= 0 && destTop_1 >= 0) {
|
|
3129
|
+
activePoint_1.startX = destLeft_1;
|
|
3130
|
+
activePoint_1.startY = destTop_1;
|
|
3131
|
+
activePoint_1.endX = destLeft_1 + destWidth_1;
|
|
3132
|
+
activePoint_1.endY = destTop_1 + destHeight_1;
|
|
3133
|
+
}
|
|
3134
|
+
else if (destLeft_1 >= 0) {
|
|
3135
|
+
activePoint_1.startX = destLeft_1;
|
|
2839
3136
|
activePoint_1.startY = 7.5;
|
|
2840
|
-
activePoint_1.endX =
|
|
3137
|
+
activePoint_1.endX = destLeft_1 + destWidth_1;
|
|
2841
3138
|
activePoint_1.endY = lowerCanvasHeight_1 - 15;
|
|
2842
3139
|
}
|
|
2843
|
-
else if (
|
|
3140
|
+
else if (destTop_1 >= 0) {
|
|
2844
3141
|
activePoint_1.startX = 7.5;
|
|
2845
|
-
activePoint_1.startY =
|
|
3142
|
+
activePoint_1.startY = destTop_1;
|
|
2846
3143
|
activePoint_1.endX = lowerCanvasWidth_1 - 15;
|
|
2847
|
-
activePoint_1.endY =
|
|
3144
|
+
activePoint_1.endY = destTop_1 + destHeight_1;
|
|
2848
3145
|
}
|
|
2849
3146
|
else {
|
|
2850
3147
|
activePoint_1.startX = 7.5;
|
|
@@ -2854,42 +3151,110 @@ var Draw = /** @class */ (function () {
|
|
|
2854
3151
|
}
|
|
2855
3152
|
}
|
|
2856
3153
|
else {
|
|
2857
|
-
var
|
|
2858
|
-
var imgTop_2 = parent.img.destTop;
|
|
2859
|
-
var imgWidth_2 = parent.img.destWidth;
|
|
2860
|
-
var imgHeight_2 = parent.img.destHeight;
|
|
3154
|
+
var _b = parent.img, destLeft_2 = _b.destLeft, destTop_2 = _b.destTop, destWidth_2 = _b.destWidth, destHeight_2 = _b.destHeight;
|
|
2861
3155
|
var lowerCanvasWidth_2 = parent.lowerCanvas.width;
|
|
2862
3156
|
var lowerCanvasHeight_2 = parent.lowerCanvas.height;
|
|
2863
3157
|
var activePoint_2 = actPoint;
|
|
2864
|
-
activePoint_2.startX = Math.max(
|
|
2865
|
-
activePoint_2.startY = Math.max(
|
|
2866
|
-
activePoint_2.endX = Math.min(
|
|
2867
|
-
lowerCanvasWidth_2 - 15,
|
|
2868
|
-
activePoint_2.endY = Math.min(
|
|
2869
|
-
lowerCanvasHeight_2 - 15,
|
|
2870
|
-
}
|
|
2871
|
-
var
|
|
2872
|
-
var imgTop = parent.img.destTop;
|
|
2873
|
-
var imgWidth = parent.img.destWidth;
|
|
2874
|
-
var imgHeight = parent.img.destHeight;
|
|
3158
|
+
activePoint_2.startX = Math.max(destLeft_2 > 0 ? destLeft_2 : 7.5, destLeft_2);
|
|
3159
|
+
activePoint_2.startY = Math.max(destTop_2 > 0 ? destTop_2 : 7.5, destTop_2);
|
|
3160
|
+
activePoint_2.endX = Math.min(destLeft_2 + destWidth_2 + 15 < lowerCanvasWidth_2 ? destLeft_2 + destWidth_2 - 15 :
|
|
3161
|
+
lowerCanvasWidth_2 - 15, destLeft_2 + destWidth_2);
|
|
3162
|
+
activePoint_2.endY = Math.min(destTop_2 + destHeight_2 + 15 < lowerCanvasHeight_2 ? destTop_2 + destHeight_2 - 15 :
|
|
3163
|
+
lowerCanvasHeight_2 - 15, destTop_2 + destHeight_2);
|
|
3164
|
+
}
|
|
3165
|
+
var _c = parent.img, destLeft = _c.destLeft, destTop = _c.destTop, destWidth = _c.destWidth, destHeight = _c.destHeight;
|
|
2875
3166
|
var lowerCanvasWidth = parent.lowerCanvas.clientWidth;
|
|
2876
3167
|
var lowerCanvasHeight = parent.lowerCanvas.clientHeight;
|
|
2877
3168
|
var activePoint = actPoint;
|
|
2878
|
-
activePoint.startX = Math.max(activePoint.startX,
|
|
2879
|
-
activePoint.startY = Math.max(activePoint.startY,
|
|
2880
|
-
activePoint.endX = Math.min(activePoint.endX,
|
|
2881
|
-
activePoint.endY = Math.min(activePoint.endY,
|
|
2882
|
-
if (
|
|
3169
|
+
activePoint.startX = Math.max(activePoint.startX, destLeft);
|
|
3170
|
+
activePoint.startY = Math.max(activePoint.startY, destTop);
|
|
3171
|
+
activePoint.endX = Math.min(activePoint.endX, destLeft + destWidth);
|
|
3172
|
+
activePoint.endY = Math.min(activePoint.endY, destTop + destHeight);
|
|
3173
|
+
if (parent.transform.straighten > 0) {
|
|
3174
|
+
if (this.imgCanvasPoints[0].x > activePoint.startX) {
|
|
3175
|
+
activePoint.startX = this.imgCanvasPoints[0].x;
|
|
3176
|
+
}
|
|
3177
|
+
if (this.imgCanvasPoints[0].y > activePoint.startY) {
|
|
3178
|
+
activePoint.startY = this.imgCanvasPoints[0].y;
|
|
3179
|
+
}
|
|
3180
|
+
if (this.imgCanvasPoints[2].x < activePoint.endX) {
|
|
3181
|
+
activePoint.endX = this.imgCanvasPoints[2].x;
|
|
3182
|
+
}
|
|
3183
|
+
if (this.imgCanvasPoints[2].y < activePoint.endY) {
|
|
3184
|
+
activePoint.endY = this.imgCanvasPoints[2].x;
|
|
3185
|
+
}
|
|
3186
|
+
}
|
|
3187
|
+
else if (parent.transform.straighten < 0) {
|
|
3188
|
+
if (this.imgCanvasPoints[3].x > activePoint.startX) {
|
|
3189
|
+
activePoint.startX = this.imgCanvasPoints[3].x;
|
|
3190
|
+
}
|
|
3191
|
+
if (this.imgCanvasPoints[3].y < activePoint.startY) {
|
|
3192
|
+
activePoint.startY = this.imgCanvasPoints[3].y;
|
|
3193
|
+
}
|
|
3194
|
+
if (this.imgCanvasPoints[1].x < activePoint.endX) {
|
|
3195
|
+
activePoint.endX = this.imgCanvasPoints[1].x;
|
|
3196
|
+
}
|
|
3197
|
+
if (this.imgCanvasPoints[1].y > activePoint.endY) {
|
|
3198
|
+
activePoint.endY = this.imgCanvasPoints[1].x;
|
|
3199
|
+
}
|
|
3200
|
+
}
|
|
3201
|
+
if (activePoint.startX === destLeft && destLeft + destWidth > lowerCanvasWidth) {
|
|
2883
3202
|
activePoint.endX = lowerCanvasWidth - 15;
|
|
2884
3203
|
}
|
|
2885
|
-
if (activePoint.startY ===
|
|
3204
|
+
if (activePoint.startY === destTop && destTop + destHeight > lowerCanvasHeight) {
|
|
2886
3205
|
activePoint.endY = lowerCanvasHeight - 15;
|
|
2887
3206
|
}
|
|
3207
|
+
if (parent.activeObj.activePoint.startX > parent.activeObj.activePoint.endX) {
|
|
3208
|
+
var temp = parent.activeObj.activePoint.startX;
|
|
3209
|
+
parent.activeObj.activePoint.startX = parent.activeObj.activePoint.endX;
|
|
3210
|
+
parent.activeObj.activePoint.endX = temp;
|
|
3211
|
+
}
|
|
3212
|
+
if (parent.activeObj.activePoint.startY > parent.activeObj.activePoint.endY) {
|
|
3213
|
+
var temp = parent.activeObj.activePoint.startY;
|
|
3214
|
+
parent.activeObj.activePoint.startY = parent.activeObj.activePoint.endY;
|
|
3215
|
+
parent.activeObj.activePoint.endY = temp;
|
|
3216
|
+
}
|
|
2888
3217
|
parent.activeObj = this.updateWidthHeight(parent.activeObj);
|
|
2889
3218
|
this.updateActiveObject(actPoint, parent.activeObj);
|
|
3219
|
+
this.adjActObj();
|
|
2890
3220
|
}
|
|
2891
3221
|
this.updateSelectionInsert();
|
|
2892
3222
|
};
|
|
3223
|
+
Draw.prototype.adjToStraighten = function () {
|
|
3224
|
+
var parent = this.parent;
|
|
3225
|
+
if (parent.transform.straighten !== 0 && parent.isStraightening) {
|
|
3226
|
+
var actPoint = parent.activeObj.activePoint;
|
|
3227
|
+
actPoint.startX += 7.5;
|
|
3228
|
+
actPoint.startY += 7.5;
|
|
3229
|
+
actPoint.endX -= 7.5;
|
|
3230
|
+
actPoint.endY -= 7.5;
|
|
3231
|
+
parent.activeObj = this.updateWidthHeight(parent.activeObj);
|
|
3232
|
+
}
|
|
3233
|
+
};
|
|
3234
|
+
Draw.prototype.adjActObj = function () {
|
|
3235
|
+
var parent = this.parent;
|
|
3236
|
+
if (parent.transform.straighten === 0) {
|
|
3237
|
+
return;
|
|
3238
|
+
}
|
|
3239
|
+
var actPoint = parent.activeObj.activePoint;
|
|
3240
|
+
var tempActPoint = extend({}, actPoint, {}, true);
|
|
3241
|
+
var count = 0;
|
|
3242
|
+
while (true) {
|
|
3243
|
+
count++;
|
|
3244
|
+
var object = { isIntersect: null, arr: null };
|
|
3245
|
+
parent.notify('draw', { prop: 'updateImgCanvasPoints', onPropertyChange: false });
|
|
3246
|
+
parent.notify('draw', { prop: 'isLinesIntersect', onPropertyChange: false, value: { obj: object } });
|
|
3247
|
+
if (object['arr'][0] || object['arr'][1] || object['arr'][2] || object['arr'][3] || count === 100) {
|
|
3248
|
+
actPoint = extend({}, tempActPoint, {}, true);
|
|
3249
|
+
break;
|
|
3250
|
+
}
|
|
3251
|
+
tempActPoint = extend({}, actPoint, {}, true);
|
|
3252
|
+
actPoint.startX -= 5;
|
|
3253
|
+
actPoint.endX += 5;
|
|
3254
|
+
actPoint.width = actPoint.endX - actPoint.startX;
|
|
3255
|
+
this.updateActiveObject(actPoint, parent.activeObj);
|
|
3256
|
+
}
|
|
3257
|
+
};
|
|
2893
3258
|
Draw.prototype.callUpdateCurrTransState = function () {
|
|
2894
3259
|
var parent = this.parent;
|
|
2895
3260
|
var tempObjColl = extend([], parent.objColl, [], true);
|
|
@@ -2975,7 +3340,7 @@ var Draw = /** @class */ (function () {
|
|
|
2975
3340
|
value: { context: this.lowerContext, isSave: null, isFlip: null } });
|
|
2976
3341
|
}
|
|
2977
3342
|
};
|
|
2978
|
-
Draw.prototype.setCurrentObj = function (obj) {
|
|
3343
|
+
Draw.prototype.setCurrentObj = function (obj, isUndoRedo) {
|
|
2979
3344
|
var parent = this.parent;
|
|
2980
3345
|
var isObj = obj ? true : false;
|
|
2981
3346
|
if (!isObj) {
|
|
@@ -2986,6 +3351,7 @@ var Draw = /** @class */ (function () {
|
|
|
2986
3351
|
obj = obj ? obj : parent.cropObj;
|
|
2987
3352
|
parent.transform.cropZoomFactor = obj.cropZoom;
|
|
2988
3353
|
parent.transform.defaultZoomFactor = obj.defaultZoom;
|
|
3354
|
+
this.straightenInitZoom = obj.straightenZoom;
|
|
2989
3355
|
if (!isObj) {
|
|
2990
3356
|
parent.transform.zoomFactor = obj.cropZoom;
|
|
2991
3357
|
}
|
|
@@ -3008,14 +3374,17 @@ var Draw = /** @class */ (function () {
|
|
|
3008
3374
|
parent.transform.degree = obj.degree;
|
|
3009
3375
|
parent.frameObj.type = obj.frame;
|
|
3010
3376
|
parent.transform.currFlipState = obj.currFlipState;
|
|
3011
|
-
parent.
|
|
3012
|
-
parent.
|
|
3013
|
-
parent.
|
|
3014
|
-
parent.
|
|
3015
|
-
parent.
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3377
|
+
parent.notify('filter', { prop: 'setAdjustmentLevel', onPropertyChange: false, value: { adjustmentLevel: obj.adjustmentLevel } });
|
|
3378
|
+
parent.notify('filter', { prop: 'setTempAdjVal' });
|
|
3379
|
+
parent.currentFilter = obj.currentFilter;
|
|
3380
|
+
parent.notify('filter', { prop: 'setTempFilVal' });
|
|
3381
|
+
if (parent.transform.straighten !== obj.straighten || isUndoRedo) {
|
|
3382
|
+
parent.transform.straighten = obj.straighten;
|
|
3383
|
+
parent.straightenBaseImageCanvas();
|
|
3384
|
+
}
|
|
3385
|
+
parent.img = { destLeft: obj.destPoints.startX, destTop: obj.destPoints.startY, destWidth: obj.destPoints.width,
|
|
3386
|
+
destHeight: obj.destPoints.height, srcLeft: obj.srcPoints.startX, srcTop: obj.srcPoints.startY,
|
|
3387
|
+
srcWidth: obj.srcPoints.width, srcHeight: obj.srcPoints.height };
|
|
3019
3388
|
parent.aspectWidth = obj.aspectWidth;
|
|
3020
3389
|
parent.aspectHeight = obj.aspectHeight;
|
|
3021
3390
|
if (obj.afterCropActions) {
|
|
@@ -3063,7 +3432,7 @@ var Draw = /** @class */ (function () {
|
|
|
3063
3432
|
var afterCropActions = extend([], parent.afterCropActions, [], true);
|
|
3064
3433
|
if (!isObj && afterCropActions.length > 0) {
|
|
3065
3434
|
isAfterCropAction = true;
|
|
3066
|
-
for (var i = 0
|
|
3435
|
+
for (var i = 0, len = afterCropActions.length; i < len; i++) {
|
|
3067
3436
|
if (afterCropActions[i] === 'horizontalflip' || afterCropActions[i] === 'verticalflip') {
|
|
3068
3437
|
parent.activeObj = extend({}, currSelectionPoint, {}, true);
|
|
3069
3438
|
this.rotatedFlipCropSel = true;
|
|
@@ -3134,14 +3503,9 @@ var Draw = /** @class */ (function () {
|
|
|
3134
3503
|
parent.notify('freehand-draw', { prop: 'zoomFHDColl', onPropertyChange: false, value: { isPreventApply: null } });
|
|
3135
3504
|
}
|
|
3136
3505
|
else {
|
|
3137
|
-
parent.img
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
parent.img.destHeight = obj.destPoints.height;
|
|
3141
|
-
parent.img.srcLeft = obj.srcPoints.startX;
|
|
3142
|
-
parent.img.srcTop = obj.srcPoints.startY;
|
|
3143
|
-
parent.img.srcWidth = obj.srcPoints.width;
|
|
3144
|
-
parent.img.srcHeight = obj.srcPoints.height;
|
|
3506
|
+
parent.img = { destLeft: obj.destPoints.startX, destTop: obj.destPoints.startY, destWidth: obj.destPoints.width,
|
|
3507
|
+
destHeight: obj.destPoints.height, srcLeft: obj.srcPoints.startX, srcTop: obj.srcPoints.startY,
|
|
3508
|
+
srcWidth: obj.srcPoints.width, srcHeight: obj.srcPoints.height };
|
|
3145
3509
|
if (obj.activeObj.activePoint.width !== 0 && obj.activeObj.activePoint.height !== 0) {
|
|
3146
3510
|
var destPoints = { startX: parent.img.destLeft, startY: parent.img.destTop, width: parent.img.destWidth,
|
|
3147
3511
|
height: parent.img.destHeight };
|
|
@@ -3160,22 +3524,22 @@ var Draw = /** @class */ (function () {
|
|
|
3160
3524
|
parent.activeObj = activeObj;
|
|
3161
3525
|
this.lowerContext.filter = temp;
|
|
3162
3526
|
};
|
|
3163
|
-
Draw.prototype.performPointZoom = function (x, y, type) {
|
|
3527
|
+
Draw.prototype.performPointZoom = function (x, y, type, isResize, value) {
|
|
3164
3528
|
var parent = this.parent;
|
|
3165
|
-
var
|
|
3166
|
-
var
|
|
3529
|
+
var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
|
|
3530
|
+
var ratioX = (x - destLeft) / destWidth;
|
|
3531
|
+
var ratioY = (y - destTop) / destHeight;
|
|
3167
3532
|
var isUndoRedo = parent.isUndoRedo;
|
|
3168
3533
|
parent.isUndoRedo = true;
|
|
3169
3534
|
parent.setProperties({ zoomSettings: { zoomPoint: { x: x, y: y } } }, true);
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
}
|
|
3174
|
-
else if (type === 'zoomOut') {
|
|
3175
|
-
parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
3176
|
-
value: { zoomFactor: -.1, zoomPoint: null }, isResize: null });
|
|
3177
|
-
}
|
|
3535
|
+
var zoomValue = value ? value : (type === 'zoomIn') ? .1 : -.1;
|
|
3536
|
+
parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
3537
|
+
value: { zoomFactor: zoomValue, zoomPoint: null, isResize: isResize } });
|
|
3178
3538
|
parent.isUndoRedo = isUndoRedo;
|
|
3539
|
+
this.panToPoint(x, y, ratioX, ratioY);
|
|
3540
|
+
};
|
|
3541
|
+
Draw.prototype.panToPoint = function (x, y, ratioX, ratioY) {
|
|
3542
|
+
var parent = this.parent;
|
|
3179
3543
|
if (parent.transform.zoomFactor > 0) {
|
|
3180
3544
|
var destLeft = parent.img.destLeft;
|
|
3181
3545
|
var destTop = parent.img.destTop;
|
|
@@ -3190,9 +3554,14 @@ var Draw = /** @class */ (function () {
|
|
|
3190
3554
|
parent.isCropTab = true;
|
|
3191
3555
|
var objColl = extend([], parent.objColl, [], true);
|
|
3192
3556
|
var pointColl = extend([], parent.pointColl, [], true);
|
|
3557
|
+
var straightenObj = { straightenPoint: null };
|
|
3558
|
+
parent.notify('freehand-draw', { prop: 'getStraightenPoint', onPropertyChange: false,
|
|
3559
|
+
value: { obj: straightenObj } });
|
|
3193
3560
|
parent.objColl = [];
|
|
3194
3561
|
parent.pointColl = [];
|
|
3195
3562
|
parent.freehandCounter = 0;
|
|
3563
|
+
parent.notify('freehand-draw', { prop: 'setStraightenPoint', onPropertyChange: false,
|
|
3564
|
+
value: { x: null, y: null, ratioX: null, ratioY: null } });
|
|
3196
3565
|
var object = { selPointColl: null };
|
|
3197
3566
|
parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
|
|
3198
3567
|
value: { obj: object } });
|
|
@@ -3207,6 +3576,11 @@ var Draw = /** @class */ (function () {
|
|
|
3207
3576
|
parent.objColl = objColl;
|
|
3208
3577
|
parent.pointColl = pointColl;
|
|
3209
3578
|
parent.freehandCounter = parent.pointColl.length;
|
|
3579
|
+
if (straightenObj['straightenPoint']['x'] && straightenObj['straightenPoint']['y']) {
|
|
3580
|
+
parent.notify('freehand-draw', { prop: 'setStraightenPoint', onPropertyChange: false,
|
|
3581
|
+
value: { x: straightenObj['straightenPoint']['x'], y: straightenObj['straightenPoint']['y'],
|
|
3582
|
+
ratioX: straightenObj['straightenPoint']['ratioX'], ratioY: straightenObj['straightenPoint']['ratioY'] } });
|
|
3583
|
+
}
|
|
3210
3584
|
parent.notify('freehand-draw', { prop: 'setSelPointColl', onPropertyChange: false,
|
|
3211
3585
|
value: { obj: { selPointColl: cropSelPointColl } } });
|
|
3212
3586
|
parent.notify('shape', { prop: 'panObjColl', onPropertyChange: false,
|
|
@@ -3223,21 +3597,21 @@ var Draw = /** @class */ (function () {
|
|
|
3223
3597
|
};
|
|
3224
3598
|
Draw.prototype.adjustPanning = function (activeObj) {
|
|
3225
3599
|
var parent = this.parent;
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
var
|
|
3600
|
+
var _a = activeObj.activePoint, startX = _a.startX, startY = _a.startY, width = _a.width, height = _a.height;
|
|
3601
|
+
if (width !== 0 && height !== 0) {
|
|
3602
|
+
var _b = parent.img, destLeft = _b.destLeft, destTop = _b.destTop, destWidth = _b.destWidth, destHeight = _b.destHeight;
|
|
3229
3603
|
var point = { x: 0, y: 0 };
|
|
3230
|
-
if (
|
|
3231
|
-
point.x =
|
|
3604
|
+
if (destLeft > startX) {
|
|
3605
|
+
point.x = destLeft - startX;
|
|
3232
3606
|
}
|
|
3233
|
-
else if (
|
|
3234
|
-
point.x = (
|
|
3607
|
+
else if (destLeft + destWidth < startX + width) {
|
|
3608
|
+
point.x = (destLeft + destWidth) - (startX + width);
|
|
3235
3609
|
}
|
|
3236
|
-
if (
|
|
3237
|
-
point.y =
|
|
3610
|
+
if (destTop > startY) {
|
|
3611
|
+
point.y = destTop - startY;
|
|
3238
3612
|
}
|
|
3239
|
-
else if (
|
|
3240
|
-
point.y = (
|
|
3613
|
+
else if (destTop + destHeight < startY + height) {
|
|
3614
|
+
point.y = (destTop + destHeight) - (startY + height);
|
|
3241
3615
|
}
|
|
3242
3616
|
if (parent.transform.degree === 0) {
|
|
3243
3617
|
parent.img.destLeft -= point.x;
|
|
@@ -3276,12 +3650,64 @@ var Draw = /** @class */ (function () {
|
|
|
3276
3650
|
}
|
|
3277
3651
|
}
|
|
3278
3652
|
};
|
|
3653
|
+
Draw.prototype.panToSel = function () {
|
|
3654
|
+
var parent = this.parent;
|
|
3655
|
+
var activeObj = extend({}, parent.activeObj, {}, true);
|
|
3656
|
+
var img = parent.img;
|
|
3657
|
+
var _a = activeObj.activePoint, startX = _a.startX, startY = _a.startY, width = _a.width, height = _a.height;
|
|
3658
|
+
var straightenObj = { straightenPoint: null };
|
|
3659
|
+
parent.notify('freehand-draw', { prop: 'getStraightenPoint', onPropertyChange: false,
|
|
3660
|
+
value: { obj: straightenObj } });
|
|
3661
|
+
if (straightenObj['straightenPoint']['x'] && straightenObj['straightenPoint']['y']) {
|
|
3662
|
+
var panX = (startX + (width / 2)) - straightenObj['straightenPoint']['x'];
|
|
3663
|
+
var panY = (startY + (height / 2)) - straightenObj['straightenPoint']['y'];
|
|
3664
|
+
if (parent.transform.degree === 0) {
|
|
3665
|
+
parent.img.destLeft += panX;
|
|
3666
|
+
parent.img.destTop += panY;
|
|
3667
|
+
parent.notify('transform', { prop: 'drawPannImage', value: { point: { x: panX, y: panY } } });
|
|
3668
|
+
}
|
|
3669
|
+
else {
|
|
3670
|
+
parent.panPoint.currentPannedPoint = { x: panX, y: panY };
|
|
3671
|
+
parent.notify('transform', { prop: 'drawPannedImage', value: { xDiff: panX, yDiff: panY } });
|
|
3672
|
+
parent.panPoint.currentPannedPoint = { x: 0, y: 0 };
|
|
3673
|
+
parent.notify('transform', { prop: 'setTempPanMove', value: { point: null } });
|
|
3674
|
+
}
|
|
3675
|
+
parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: activeObj } });
|
|
3676
|
+
var _b = parent.img, destLeft_3 = _b.destLeft, destTop_3 = _b.destTop, destWidth_3 = _b.destWidth, destHeight_3 = _b.destHeight;
|
|
3677
|
+
var points = this.imgCanvasPoints;
|
|
3678
|
+
points.forEach(function (point) {
|
|
3679
|
+
point.x = (point.ratioX * destWidth_3) + destLeft_3;
|
|
3680
|
+
point.y = (point.ratioY * destHeight_3) + destTop_3;
|
|
3681
|
+
});
|
|
3682
|
+
this.imgCanvasPoints = points;
|
|
3683
|
+
var count = 0;
|
|
3684
|
+
if ((!isBlazor() && parent.transform.straighten === 3 && !this.preventStraightening) ||
|
|
3685
|
+
(isBlazor() && parent.transform.straighten === 5 && !this.preventStraightening)) {
|
|
3686
|
+
this.preventStraightening = true;
|
|
3687
|
+
var temp = parent.prevStraightenedDegree;
|
|
3688
|
+
parent.prevStraightenedDegree = parent.transform.straighten;
|
|
3689
|
+
parent.setStraighten(0);
|
|
3690
|
+
if (isBlazor()) {
|
|
3691
|
+
parent.setStraighten(5);
|
|
3692
|
+
}
|
|
3693
|
+
else {
|
|
3694
|
+
parent.setStraighten(3);
|
|
3695
|
+
}
|
|
3696
|
+
;
|
|
3697
|
+
parent.prevStraightenedDegree = temp;
|
|
3698
|
+
this.preventStraightening = false;
|
|
3699
|
+
}
|
|
3700
|
+
while (this.isLinesIntersect() && parent.transform.straighten !== 0 && parent.transform.straighten !== 360 && count < 100) {
|
|
3701
|
+
count++;
|
|
3702
|
+
this.performPointZoom(parent.activeObj.activePoint.startX + (parent.activeObj.activePoint.width / 2), parent.activeObj.activePoint.startY + (parent.activeObj.activePoint.height / 2), 'zoomIn', false, 0.025);
|
|
3703
|
+
this.updateImgCanvasPoints();
|
|
3704
|
+
}
|
|
3705
|
+
}
|
|
3706
|
+
};
|
|
3279
3707
|
Draw.prototype.drawZoomPanImage = function (x, y) {
|
|
3280
3708
|
var parent = this.parent;
|
|
3281
|
-
parent.notify('shape', { prop: 'panObjColl', onPropertyChange: false,
|
|
3282
|
-
|
|
3283
|
-
parent.notify('freehand-draw', { prop: 'panFHDColl', onPropertyChange: false,
|
|
3284
|
-
value: { xDiff: x, yDiff: y, panRegion: '' } });
|
|
3709
|
+
parent.notify('shape', { prop: 'panObjColl', onPropertyChange: false, value: { xDiff: x, yDiff: y, panRegion: '' } });
|
|
3710
|
+
parent.notify('freehand-draw', { prop: 'panFHDColl', onPropertyChange: false, value: { xDiff: x, yDiff: y, panRegion: '' } });
|
|
3285
3711
|
this.renderImage(true);
|
|
3286
3712
|
var obj = { width: 0, height: 0 };
|
|
3287
3713
|
parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
|
|
@@ -3295,10 +3721,11 @@ var Draw = /** @class */ (function () {
|
|
|
3295
3721
|
};
|
|
3296
3722
|
Draw.prototype.openNewImage = function () {
|
|
3297
3723
|
var parent = this.parent;
|
|
3724
|
+
var id = parent.element.id;
|
|
3298
3725
|
var inMemoryContext = parent.inMemoryCanvas.getContext('2d');
|
|
3299
3726
|
showSpinner(parent.element);
|
|
3300
3727
|
parent.element.style.opacity = '0.5';
|
|
3301
|
-
var toolbar = document.querySelector('#' +
|
|
3728
|
+
var toolbar = document.querySelector('#' + id + '_currPos');
|
|
3302
3729
|
if (toolbar) {
|
|
3303
3730
|
toolbar.style.display = 'none';
|
|
3304
3731
|
}
|
|
@@ -3306,14 +3733,14 @@ var Draw = /** @class */ (function () {
|
|
|
3306
3733
|
if (!isBlazor()) {
|
|
3307
3734
|
parent.notify('toolbar', { prop: 'getDefToolbarItems', value: { obj: obj } });
|
|
3308
3735
|
if (obj['defToolbarItems'].length === 0 &&
|
|
3309
|
-
(isNullOrUndefined(document.getElementById(
|
|
3310
|
-
var height = parent.element.querySelector('#' +
|
|
3736
|
+
(isNullOrUndefined(document.getElementById(id + '_toolbar')))) {
|
|
3737
|
+
var height = parent.element.querySelector('#' + id + '_toolbarArea').clientHeight;
|
|
3311
3738
|
parent.notify('toolbar', { prop: 'setToolbarHeight', value: { height: height } });
|
|
3312
3739
|
}
|
|
3313
3740
|
}
|
|
3314
3741
|
else {
|
|
3315
|
-
if (parent.element.querySelector('#' +
|
|
3316
|
-
parent.toolbarHeight = parent.element.querySelector('#' +
|
|
3742
|
+
if (parent.element.querySelector('#' + id + '_toolbarArea')) {
|
|
3743
|
+
parent.toolbarHeight = parent.element.querySelector('#' + id + '_toolbarArea').clientHeight;
|
|
3317
3744
|
}
|
|
3318
3745
|
}
|
|
3319
3746
|
parent.reset();
|
|
@@ -3349,8 +3776,8 @@ var Draw = /** @class */ (function () {
|
|
|
3349
3776
|
else {
|
|
3350
3777
|
this.fileName = 'ImageEditor';
|
|
3351
3778
|
this.fileType = null;
|
|
3352
|
-
parent.lowerCanvas = document.querySelector('#' +
|
|
3353
|
-
parent.upperCanvas = document.querySelector('#' +
|
|
3779
|
+
parent.lowerCanvas = document.querySelector('#' + id + '_lowerCanvas');
|
|
3780
|
+
parent.upperCanvas = document.querySelector('#' + id + '_upperCanvas');
|
|
3354
3781
|
this.lowerContext = parent.lowerCanvas.getContext('2d');
|
|
3355
3782
|
this.upperContext = parent.upperCanvas.getContext('2d');
|
|
3356
3783
|
parent.clearContext(this.lowerContext);
|
|
@@ -3363,25 +3790,14 @@ var Draw = /** @class */ (function () {
|
|
|
3363
3790
|
}
|
|
3364
3791
|
};
|
|
3365
3792
|
Draw.prototype.dlgBtnClick = function () {
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
if (this.isFileChanged) {
|
|
3369
|
-
parent.isImageLoaded = this.isFileChanged = false;
|
|
3370
|
-
parent.reset();
|
|
3371
|
-
this.checkToolbarTemplate(this.inputElem, this.openURL);
|
|
3372
|
-
}
|
|
3373
|
-
else {
|
|
3374
|
-
this.reset();
|
|
3375
|
-
this.openNewImage();
|
|
3376
|
-
}
|
|
3377
|
-
if (!isBlazor()) {
|
|
3378
|
-
getComponent(document.getElementById(parent.element.id + '_dialog'), 'dialog').destroy();
|
|
3379
|
-
}
|
|
3380
|
-
this.isImageEdited = false;
|
|
3793
|
+
this.parent.export();
|
|
3794
|
+
this.applyDialogOption();
|
|
3381
3795
|
};
|
|
3382
3796
|
Draw.prototype.dlgCloseBtnClick = function () {
|
|
3797
|
+
this.applyDialogOption();
|
|
3798
|
+
};
|
|
3799
|
+
Draw.prototype.applyDialogOption = function () {
|
|
3383
3800
|
var parent = this.parent;
|
|
3384
|
-
this.baseImgSrc = parent.baseImg.src;
|
|
3385
3801
|
if (this.isFileChanged) {
|
|
3386
3802
|
parent.isImageLoaded = this.isFileChanged = false;
|
|
3387
3803
|
parent.reset();
|
|
@@ -3397,15 +3813,16 @@ var Draw = /** @class */ (function () {
|
|
|
3397
3813
|
this.isImageEdited = false;
|
|
3398
3814
|
};
|
|
3399
3815
|
Draw.prototype.showDialogPopup = function () {
|
|
3816
|
+
var parent = this.parent;
|
|
3400
3817
|
var headerObj = { key: 'ConfirmDialogHeader' };
|
|
3401
|
-
|
|
3818
|
+
parent.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: headerObj } });
|
|
3402
3819
|
var contentObj = { key: 'ConfirmDialogContent' };
|
|
3403
|
-
|
|
3820
|
+
parent.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: contentObj } });
|
|
3404
3821
|
var yesObj = { key: 'Yes' };
|
|
3405
|
-
|
|
3822
|
+
parent.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: yesObj } });
|
|
3406
3823
|
var noObj = { key: 'No' };
|
|
3407
|
-
|
|
3408
|
-
|
|
3824
|
+
parent.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: noObj } });
|
|
3825
|
+
parent.element.querySelector('#' + parent.element.id + '_dialog').style.display = 'block';
|
|
3409
3826
|
var dialog = new Dialog({
|
|
3410
3827
|
header: headerObj['value'],
|
|
3411
3828
|
closeOnEscape: true,
|
|
@@ -3423,21 +3840,10 @@ var Draw = /** @class */ (function () {
|
|
|
3423
3840
|
buttonModel: { content: yesObj['value'], isPrimary: true, iconCss: 'e-icons e-check' } }
|
|
3424
3841
|
]
|
|
3425
3842
|
});
|
|
3426
|
-
dialog.appendTo('#' +
|
|
3843
|
+
dialog.appendTo('#' + parent.element.id + '_dialog');
|
|
3427
3844
|
};
|
|
3428
3845
|
Draw.prototype.restoreOldImage = function () {
|
|
3429
3846
|
if (this.parent.isImageLoaded) {
|
|
3430
|
-
// if (this.isImageEdited || this.parent.pointColl.length > 0 || this.parent.objColl.length > 0) {
|
|
3431
|
-
// this.showDialogPopup();
|
|
3432
|
-
// } else {
|
|
3433
|
-
// this.reset();
|
|
3434
|
-
// this.openNewImage();
|
|
3435
|
-
// }
|
|
3436
|
-
// const data: ImageData = this.parent.getImageData();
|
|
3437
|
-
// const canvas: HTMLCanvasElement = document.createElement('canvas');
|
|
3438
|
-
// canvas.width = data.width; canvas.height = data.height;
|
|
3439
|
-
// canvas.getContext('2d').putImageData(data, 0, 0);
|
|
3440
|
-
// this.baseImgSrc = canvas.toDataURL();
|
|
3441
3847
|
this.reset();
|
|
3442
3848
|
this.openNewImage();
|
|
3443
3849
|
}
|
|
@@ -3507,7 +3913,7 @@ var Draw = /** @class */ (function () {
|
|
|
3507
3913
|
var URL_1 = window.URL;
|
|
3508
3914
|
var url = URL_1.createObjectURL(filesData);
|
|
3509
3915
|
this.openURL = url;
|
|
3510
|
-
if (parent.isImageLoaded && (this.isImageEdited || parent.pointColl.length > 0 || parent.objColl.length > 0)) {
|
|
3916
|
+
if (parent.isImageLoaded && !parent.isChangesSaved && (this.isImageEdited || parent.pointColl.length > 0 || parent.objColl.length > 0)) {
|
|
3511
3917
|
this.isFileChanged = true;
|
|
3512
3918
|
if (!isBlazor()) {
|
|
3513
3919
|
this.showDialogPopup();
|
|
@@ -3536,8 +3942,9 @@ var Draw = /** @class */ (function () {
|
|
|
3536
3942
|
var parent = this.parent;
|
|
3537
3943
|
if (parent.activeObj.shape) {
|
|
3538
3944
|
var isRotated = false;
|
|
3539
|
-
for (var i = 0
|
|
3540
|
-
|
|
3945
|
+
for (var i = 0, len = parent.rotateFlipColl.length; i < len; i++) {
|
|
3946
|
+
var degree = parent.rotateFlipColl[i];
|
|
3947
|
+
if (degree === 90 || degree === -90) {
|
|
3541
3948
|
isRotated = true;
|
|
3542
3949
|
break;
|
|
3543
3950
|
}
|
|
@@ -3549,13 +3956,14 @@ var Draw = /** @class */ (function () {
|
|
|
3549
3956
|
var zoomFactor = parent.transform.zoomFactor;
|
|
3550
3957
|
parent.objColl.push(parent.activeObj);
|
|
3551
3958
|
parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
|
|
3959
|
+
var currObj = parent.objColl[parent.objColl.length - 1];
|
|
3552
3960
|
if (type === 'rotateleft' || type === 'rotateright') {
|
|
3553
3961
|
if (parent.transform.degree % 90 === 0 && parent.transform.degree % 180 !== 0) {
|
|
3554
|
-
if (
|
|
3962
|
+
if (currObj.activePoint.width < activeObj.activePoint.height) {
|
|
3555
3963
|
for (var i = 2; i < parent.zoomSettings.maxZoomFactor; i++) {
|
|
3556
|
-
if (
|
|
3557
|
-
this.isSelectionBiggerThanCanvas(
|
|
3558
|
-
this.isSelectionOutsideCanvas(
|
|
3964
|
+
if (currObj.activePoint.width >= activeObj.activePoint.height ||
|
|
3965
|
+
this.isSelectionBiggerThanCanvas(currObj) ||
|
|
3966
|
+
this.isSelectionOutsideCanvas(currObj)) {
|
|
3559
3967
|
if (!isNullOrUndefined(zoomFactor)) {
|
|
3560
3968
|
parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
3561
3969
|
value: { zoomFactor: -0.1, zoomPoint: null }, isResize: null });
|
|
@@ -3569,9 +3977,9 @@ var Draw = /** @class */ (function () {
|
|
|
3569
3977
|
}
|
|
3570
3978
|
else {
|
|
3571
3979
|
for (var i = 2; i < parent.zoomSettings.maxZoomFactor; i++) {
|
|
3572
|
-
if (
|
|
3573
|
-
this.isSelectionBiggerThanCanvas(
|
|
3574
|
-
this.isSelectionOutsideCanvas(
|
|
3980
|
+
if (currObj.activePoint.width >= activeObj.activePoint.height ||
|
|
3981
|
+
this.isSelectionBiggerThanCanvas(currObj) ||
|
|
3982
|
+
this.isSelectionOutsideCanvas(currObj)) {
|
|
3575
3983
|
if (!isNullOrUndefined(zoomFactor)) {
|
|
3576
3984
|
parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
3577
3985
|
value: { zoomFactor: 0.1, zoomPoint: null, isResize: null } });
|
|
@@ -3585,11 +3993,11 @@ var Draw = /** @class */ (function () {
|
|
|
3585
3993
|
}
|
|
3586
3994
|
}
|
|
3587
3995
|
else {
|
|
3588
|
-
if (
|
|
3996
|
+
if (currObj.activePoint.height < activeObj.activePoint.width) {
|
|
3589
3997
|
for (var i = 2; i < parent.zoomSettings.maxZoomFactor; i++) {
|
|
3590
|
-
if (
|
|
3591
|
-
this.isSelectionBiggerThanCanvas(
|
|
3592
|
-
this.isSelectionOutsideCanvas(
|
|
3998
|
+
if (currObj.activePoint.height >= activeObj.activePoint.width ||
|
|
3999
|
+
this.isSelectionBiggerThanCanvas(currObj) ||
|
|
4000
|
+
this.isSelectionOutsideCanvas(currObj)) {
|
|
3593
4001
|
if (!isNullOrUndefined(zoomFactor)) {
|
|
3594
4002
|
parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
3595
4003
|
value: { zoomFactor: -0.1, zoomPoint: null }, isResize: null });
|
|
@@ -3603,9 +4011,9 @@ var Draw = /** @class */ (function () {
|
|
|
3603
4011
|
}
|
|
3604
4012
|
else {
|
|
3605
4013
|
for (var i = 2; i < parent.zoomSettings.maxZoomFactor; i++) {
|
|
3606
|
-
if (
|
|
3607
|
-
this.isSelectionBiggerThanCanvas(
|
|
3608
|
-
this.isSelectionOutsideCanvas(
|
|
4014
|
+
if (currObj.activePoint.height >= activeObj.activePoint.width ||
|
|
4015
|
+
this.isSelectionBiggerThanCanvas(currObj) ||
|
|
4016
|
+
this.isSelectionOutsideCanvas(currObj)) {
|
|
3609
4017
|
if (!isNullOrUndefined(zoomFactor)) {
|
|
3610
4018
|
parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
3611
4019
|
value: { zoomFactor: 0.1, zoomPoint: null }, isResize: null });
|
|
@@ -3619,10 +4027,13 @@ var Draw = /** @class */ (function () {
|
|
|
3619
4027
|
}
|
|
3620
4028
|
}
|
|
3621
4029
|
}
|
|
3622
|
-
var panX = (parent.lowerCanvas.clientWidth / 2) - (
|
|
3623
|
-
(
|
|
3624
|
-
var panY = (parent.lowerCanvas.clientHeight / 2) - (
|
|
3625
|
-
(
|
|
4030
|
+
var panX = (parent.lowerCanvas.clientWidth / 2) - Math.floor(currObj.activePoint.startX +
|
|
4031
|
+
(currObj.activePoint.width / 2));
|
|
4032
|
+
var panY = (parent.lowerCanvas.clientHeight / 2) - Math.floor(currObj.activePoint.startY +
|
|
4033
|
+
(currObj.activePoint.height / 2));
|
|
4034
|
+
if (isNullOrUndefined(parent.activeObj.shape)) {
|
|
4035
|
+
parent.activeObj = extend({}, activeObj, {}, true);
|
|
4036
|
+
}
|
|
3626
4037
|
if (parent.transform.degree === 0) {
|
|
3627
4038
|
parent.img.destLeft += panX;
|
|
3628
4039
|
parent.img.destTop += panY;
|
|
@@ -3643,18 +4054,19 @@ var Draw = /** @class */ (function () {
|
|
|
3643
4054
|
};
|
|
3644
4055
|
Draw.prototype.isSelectionBiggerThanCanvas = function (obj) {
|
|
3645
4056
|
var isBigger = false;
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
4057
|
+
var parent = this.parent;
|
|
4058
|
+
var _a = obj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
|
|
4059
|
+
var _b = parent.img, destLeft = _b.destLeft, destTop = _b.destTop, destWidth = _b.destWidth, destHeight = _b.destHeight;
|
|
4060
|
+
if (startX <= destLeft || startY <= destTop || endX >= destLeft + destWidth || endY >= destTop + destHeight) {
|
|
3650
4061
|
isBigger = true;
|
|
3651
4062
|
}
|
|
3652
4063
|
return isBigger;
|
|
3653
4064
|
};
|
|
3654
4065
|
Draw.prototype.isSelectionOutsideCanvas = function (obj) {
|
|
3655
4066
|
var isOutside = false;
|
|
3656
|
-
|
|
3657
|
-
|
|
4067
|
+
var parent = this.parent;
|
|
4068
|
+
if ((obj.activePoint.height < parent.lowerCanvas.height - parent.toolbarHeight) ||
|
|
4069
|
+
(obj.activePoint.width < parent.lowerCanvas.width)) {
|
|
3658
4070
|
isOutside = true;
|
|
3659
4071
|
}
|
|
3660
4072
|
return isOutside;
|
|
@@ -3679,15 +4091,17 @@ var Draw = /** @class */ (function () {
|
|
|
3679
4091
|
var tempCanvas = parent.createElement('canvas', {
|
|
3680
4092
|
id: parent.element.id + '_downScaleCanvas', attrs: { name: 'canvasImage' }
|
|
3681
4093
|
});
|
|
3682
|
-
tempCanvas.width = isImgAnnotation ? img.width :
|
|
3683
|
-
tempCanvas.height = isImgAnnotation ? img.height :
|
|
4094
|
+
tempCanvas.width = isImgAnnotation ? img.width : parent.img.srcWidth;
|
|
4095
|
+
tempCanvas.height = isImgAnnotation ? img.height : parent.img.srcHeight;
|
|
3684
4096
|
if (isImgAnnotation) {
|
|
3685
4097
|
tempCanvas.getContext('2d').drawImage(img, 0, 0, tempCanvas.width, tempCanvas.height);
|
|
3686
4098
|
}
|
|
3687
4099
|
else {
|
|
3688
4100
|
tempCanvas.getContext('2d').drawImage(canvas, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, 0, 0, tempCanvas.width, tempCanvas.height);
|
|
3689
4101
|
}
|
|
3690
|
-
|
|
4102
|
+
if (isImgAnnotation || this.isDownScale) {
|
|
4103
|
+
this.downScale(tempCanvas, width, height, isImgAnnotation);
|
|
4104
|
+
}
|
|
3691
4105
|
if (isImgAnnotation) {
|
|
3692
4106
|
ctx.canvas.width = tempCanvas.width;
|
|
3693
4107
|
ctx.canvas.height = tempCanvas.height;
|
|
@@ -3730,17 +4144,28 @@ var Draw = /** @class */ (function () {
|
|
|
3730
4144
|
ctx.drawImage(tempCanvas, 0, 0);
|
|
3731
4145
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
3732
4146
|
}
|
|
4147
|
+
else if (parent.isFinetuning) {
|
|
4148
|
+
ctx.save();
|
|
4149
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
4150
|
+
ctx.drawImage(parent.inMemoryCanvas, 0, 0);
|
|
4151
|
+
ctx.restore();
|
|
4152
|
+
}
|
|
3733
4153
|
else {
|
|
3734
4154
|
ctx.drawImage(tempCanvas, 0, 0, tempCanvas.width, tempCanvas.height, parent.img.destLeft, parent.img.destTop, tempCanvas.width, tempCanvas.height);
|
|
3735
4155
|
}
|
|
3736
4156
|
}
|
|
3737
4157
|
else {
|
|
3738
|
-
if (isNullOrUndefined(isImgAnnotation) || !isImgAnnotation)
|
|
3739
|
-
|
|
4158
|
+
if ((isNullOrUndefined(isImgAnnotation) || !isImgAnnotation) && parent.baseImgCanvas.width !== 0 &&
|
|
4159
|
+
parent.baseImgCanvas.height !== 0) {
|
|
4160
|
+
ctx.drawImage(parent.baseImgCanvas, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, parent.img.destLeft, parent.img.destTop, parent.img.destWidth, parent.img.destHeight);
|
|
3740
4161
|
}
|
|
3741
4162
|
}
|
|
3742
4163
|
};
|
|
3743
4164
|
Draw.prototype.downScale = function (canvas, width, height, isImgAnnotation) {
|
|
4165
|
+
var parent = this.parent;
|
|
4166
|
+
if (isImgAnnotation && parent.isStraightening) {
|
|
4167
|
+
return;
|
|
4168
|
+
}
|
|
3744
4169
|
var widthSource = canvas.width;
|
|
3745
4170
|
var heightSource = canvas.height;
|
|
3746
4171
|
width = Math.round(width);
|
|
@@ -3796,13 +4221,13 @@ var Draw = /** @class */ (function () {
|
|
|
3796
4221
|
data2[x2 + 3] = a / alphaWeights;
|
|
3797
4222
|
}
|
|
3798
4223
|
}
|
|
3799
|
-
canvas.width = isImgAnnotation ?
|
|
3800
|
-
canvas.height = isImgAnnotation ?
|
|
4224
|
+
canvas.width = isImgAnnotation ? parent.activeObj.activePoint.width : parent.lowerCanvas.width;
|
|
4225
|
+
canvas.height = isImgAnnotation ? parent.activeObj.activePoint.height : parent.lowerCanvas.height;
|
|
3801
4226
|
ctx.putImageData(img2, 0, 0);
|
|
3802
4227
|
};
|
|
3803
4228
|
Draw.prototype.drawImgToCtx = function (ctx, preventImg) {
|
|
3804
4229
|
var parent = this.parent;
|
|
3805
|
-
if (ctx.canvas.id !== parent.element.id + '_tempCanvas' && isNullOrUndefined(preventImg)) {
|
|
4230
|
+
if (ctx.canvas.id !== parent.element.id + '_tempCanvas' && ctx !== this.upperContext && isNullOrUndefined(preventImg)) {
|
|
3806
4231
|
this.downScaleImgCanvas(ctx, null, null, null);
|
|
3807
4232
|
}
|
|
3808
4233
|
};
|
|
@@ -3810,6 +4235,7 @@ var Draw = /** @class */ (function () {
|
|
|
3810
4235
|
var parent = this.parent;
|
|
3811
4236
|
var color = parent.frameObj.color;
|
|
3812
4237
|
if (frameObj.gradientColor) {
|
|
4238
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
3813
4239
|
var gradient = ctx.createLinearGradient(points.startX, points.startY, points.startX + points.width, points.startY + points.height);
|
|
3814
4240
|
gradient.addColorStop(0, frameObj.color);
|
|
3815
4241
|
gradient.addColorStop(1, frameObj.gradientColor);
|
|
@@ -3830,11 +4256,10 @@ var Draw = /** @class */ (function () {
|
|
|
3830
4256
|
var frameObj = { type: parent.frameObj.type, color: parent.frameObj.color, size: parent.frameObj.size,
|
|
3831
4257
|
inset: parent.frameObj.inset, offset: parent.frameObj.offset / 2, radius: parent.frameObj.radius,
|
|
3832
4258
|
amount: parent.frameObj.amount, border: parent.frameObj.border, gradientColor: parent.frameObj.gradientColor };
|
|
4259
|
+
var zoomFactor = parent.transform.zoomFactor;
|
|
3833
4260
|
if (ctx.canvas.id === parent.element.id + '_tempCanvas') {
|
|
3834
|
-
var newWidth =
|
|
3835
|
-
var newHeight =
|
|
3836
|
-
newWidth = ctx.canvas.width;
|
|
3837
|
-
newHeight = ctx.canvas.height;
|
|
4261
|
+
var newWidth = ctx.canvas.width;
|
|
4262
|
+
var newHeight = ctx.canvas.height;
|
|
3838
4263
|
var obj = { width: 0, height: 0 };
|
|
3839
4264
|
parent.notify('crop', { prop: 'calcRatio', onPropertyChange: false,
|
|
3840
4265
|
value: { obj: obj, dimension: { width: newWidth, height: newHeight } } });
|
|
@@ -3844,20 +4269,38 @@ var Draw = /** @class */ (function () {
|
|
|
3844
4269
|
frameObj.offset *= ((ratio.width + ratio.height) / 2);
|
|
3845
4270
|
frameObj.radius *= ((ratio.width + ratio.height) / 2);
|
|
3846
4271
|
points = { startX: 0, startY: 0, width: ctx.canvas.width, height: ctx.canvas.height };
|
|
4272
|
+
parent.notify('export', { prop: 'updateSaveContext', onPropertyChange: false, value: { context: ctx } });
|
|
4273
|
+
}
|
|
4274
|
+
else if (ctx === this.upperContext && parent.activeObj.shape) {
|
|
4275
|
+
points = { startX: parent.activeObj.activePoint.startX - ctx.lineWidth, startY: parent.activeObj.activePoint.startY
|
|
4276
|
+
- ctx.lineWidth, width: parent.activeObj.activePoint.width + (2 * ctx.lineWidth), height: parent.activeObj.activePoint.height + (2 * ctx.lineWidth) };
|
|
3847
4277
|
}
|
|
3848
4278
|
else if (isNullOrUndefined(preventImg)) {
|
|
3849
4279
|
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
|
|
3850
4280
|
}
|
|
3851
4281
|
var valueForty = (40 * ((ratio.width + ratio.height) / 2));
|
|
3852
4282
|
var valueFifty = (50 * ((ratio.width + ratio.height) / 2));
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
4283
|
+
if (ctx !== this.upperContext) {
|
|
4284
|
+
frameObj.size += (frameObj.size * zoomFactor);
|
|
4285
|
+
frameObj.inset += (frameObj.inset * zoomFactor);
|
|
4286
|
+
frameObj.offset += (frameObj.offset * zoomFactor);
|
|
4287
|
+
frameObj.radius += (frameObj.radius * zoomFactor);
|
|
4288
|
+
valueForty += (valueForty * zoomFactor);
|
|
4289
|
+
valueFifty += (valueFifty * zoomFactor);
|
|
4290
|
+
}
|
|
4291
|
+
if (ctx === this.upperContext && parent.activeObj.shape) {
|
|
4292
|
+
if ((frame === 'mat' && ((points.width - (2 * frameObj.size) < 0) || (points.height - (2 * frameObj.size) < 0))) ||
|
|
4293
|
+
(frame === 'bevel' && (points.width - (2 * frameObj.size) < 40 || points.height - (2 * frameObj.size) < 40)) ||
|
|
4294
|
+
((frame === 'inset') && (points.startX + points.width - frameObj.offset - (points.startX + frameObj.offset) < 0 ||
|
|
4295
|
+
points.startY + points.height - frameObj.offset - (points.startY + frameObj.offset) < 0)) ||
|
|
4296
|
+
(frame === 'hook' && (points.width - (2 * frameObj.size) < 50 || points.height - (2 * frameObj.size) < 50))) {
|
|
4297
|
+
return;
|
|
4298
|
+
}
|
|
4299
|
+
}
|
|
4300
|
+
var bevelObj = { bevelFilter: ctx.filter };
|
|
3859
4301
|
var filter = ctx.filter;
|
|
3860
|
-
if ((parent.currSelectionPoint && parent.currSelectionPoint.shape === 'crop-circle') || parent.isCircleCrop
|
|
4302
|
+
if ((parent.currSelectionPoint && parent.currSelectionPoint.shape === 'crop-circle') || parent.isCircleCrop ||
|
|
4303
|
+
(ctx === this.lowerContext && parent.isCropTab)) {
|
|
3861
4304
|
this.drawImgToCtx(ctx, preventImg);
|
|
3862
4305
|
}
|
|
3863
4306
|
else {
|
|
@@ -3867,6 +4310,10 @@ var Draw = /** @class */ (function () {
|
|
|
3867
4310
|
break;
|
|
3868
4311
|
case 'mat':
|
|
3869
4312
|
this.drawImgToCtx(ctx, preventImg);
|
|
4313
|
+
while (((points.width - (2 * frameObj.size) < 0) ||
|
|
4314
|
+
(points.height - (2 * frameObj.size) < 0)) && frameObj.size > 0) {
|
|
4315
|
+
frameObj.size -= 20;
|
|
4316
|
+
}
|
|
3870
4317
|
ctx.filter = 'none';
|
|
3871
4318
|
ctx.fillStyle = this.getFrameColor(frameObj, ctx, points);
|
|
3872
4319
|
ctx.beginPath();
|
|
@@ -3886,6 +4333,18 @@ var Draw = /** @class */ (function () {
|
|
|
3886
4333
|
points.startY += frameObj.size;
|
|
3887
4334
|
points.width -= (2 * frameObj.size);
|
|
3888
4335
|
points.height -= (2 * frameObj.size);
|
|
4336
|
+
while ((points.width - (2 * frameObj.size) < 40 ||
|
|
4337
|
+
points.height - (2 * frameObj.size) < 40) && frameObj.size > 0) {
|
|
4338
|
+
points.startX -= frameObj.size;
|
|
4339
|
+
points.startY -= frameObj.size;
|
|
4340
|
+
points.width += (2 * frameObj.size);
|
|
4341
|
+
points.height += (2 * frameObj.size);
|
|
4342
|
+
frameObj.size -= 20;
|
|
4343
|
+
points.startX += frameObj.size;
|
|
4344
|
+
points.startY += frameObj.size;
|
|
4345
|
+
points.width -= (2 * frameObj.size);
|
|
4346
|
+
points.height -= (2 * frameObj.size);
|
|
4347
|
+
}
|
|
3889
4348
|
ctx.fillStyle = this.getFrameColor(frameObj, ctx, points);
|
|
3890
4349
|
ctx.save();
|
|
3891
4350
|
ctx.beginPath();
|
|
@@ -3895,33 +4354,28 @@ var Draw = /** @class */ (function () {
|
|
|
3895
4354
|
ctx.lineTo(points.startX + points.width, points.startY + points.height - valueForty);
|
|
3896
4355
|
ctx.quadraticCurveTo(points.startX + points.width, points.startY + points.height, points.startX + points.width - valueForty, points.startY + points.height);
|
|
3897
4356
|
ctx.lineTo(points.startX + valueForty, points.startY + points.height);
|
|
3898
|
-
ctx.quadraticCurveTo(points.startX, points.startY + points.height, points.startX, points.startY + points.height
|
|
4357
|
+
ctx.quadraticCurveTo(points.startX, points.startY + points.height, points.startX, points.startY + points.height
|
|
4358
|
+
- valueForty);
|
|
3899
4359
|
ctx.lineTo(points.startX, points.startY + valueForty);
|
|
3900
4360
|
ctx.quadraticCurveTo(points.startX, points.startY, points.startX + valueForty, points.startY);
|
|
3901
4361
|
ctx.closePath();
|
|
3902
4362
|
ctx.clip();
|
|
3903
4363
|
ctx.filter = filter === 'none' ? parent.canvasFilter : filter;
|
|
3904
4364
|
if (ctx.canvas.id === parent.element.id + '_tempCanvas') {
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
ctx.filter = 'none';
|
|
3910
|
-
parent.notify('export', { prop: 'drawAnnotation', onPropertyChange: false,
|
|
3911
|
-
value: { context: ctx, ratio: ratio } });
|
|
3912
|
-
parent.frameObj.type = 'bevel';
|
|
3913
|
-
ctx.filter = filter === 'none' ? parent.canvasFilter : filter;
|
|
3914
|
-
}
|
|
3915
|
-
else {
|
|
3916
|
-
ctx.drawImage(parent.baseImg, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, 0, 0, ctx.canvas.width, ctx.canvas.height);
|
|
3917
|
-
}
|
|
4365
|
+
preventImg = null;
|
|
4366
|
+
ctx.filter = 'none';
|
|
4367
|
+
ctx.drawImage(parent.inMemoryCanvas, 0, 0);
|
|
4368
|
+
ctx.filter = filter === 'none' ? parent.canvasFilter : filter;
|
|
3918
4369
|
}
|
|
3919
4370
|
else {
|
|
4371
|
+
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
|
|
3920
4372
|
if (preventImg) {
|
|
3921
4373
|
preventImg = null;
|
|
3922
4374
|
if (parent.transform.zoomFactor !== 0) {
|
|
3923
4375
|
this.isRotateZoom = true;
|
|
3924
4376
|
}
|
|
4377
|
+
parent.notify('filter', { prop: 'getBevelFilter', onPropertyChange: false, value: { obj: bevelObj } });
|
|
4378
|
+
ctx.filter = bevelObj['bevelFilter'];
|
|
3925
4379
|
this.updateCurrTransState('initial');
|
|
3926
4380
|
this.drawImgToCtx(ctx, preventImg);
|
|
3927
4381
|
this.updateCurrTransState('reverse');
|
|
@@ -3935,6 +4389,8 @@ var Draw = /** @class */ (function () {
|
|
|
3935
4389
|
ctx.filter = filter === 'none' ? parent.canvasFilter : filter;
|
|
3936
4390
|
}
|
|
3937
4391
|
else {
|
|
4392
|
+
parent.notify('filter', { prop: 'getBevelFilter', onPropertyChange: false, value: { obj: bevelObj } });
|
|
4393
|
+
ctx.filter = bevelObj['bevelFilter'];
|
|
3938
4394
|
this.drawImgToCtx(ctx, preventImg);
|
|
3939
4395
|
}
|
|
3940
4396
|
}
|
|
@@ -4039,15 +4495,16 @@ var Draw = /** @class */ (function () {
|
|
|
4039
4495
|
Draw.prototype.triggerFrameChange = function (prevFrameSettings) {
|
|
4040
4496
|
var _this = this;
|
|
4041
4497
|
var parent = this.parent;
|
|
4042
|
-
var currFrameSettings = { type: parent.toPascalCase(parent.frameObj.type),
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
lineCount: parent.frameObj.amount };
|
|
4046
|
-
var frameChange = { cancel: false, previousFrameSetting: prevFrameSettings,
|
|
4498
|
+
var currFrameSettings = { type: parent.toPascalCase(parent.frameObj.type),
|
|
4499
|
+
color: parent.frameObj.color, gradientColor: parent.frameObj.gradientColor, size: parent.frameObj.size,
|
|
4500
|
+
inset: parent.frameObj.inset, offset: parent.frameObj.offset, borderRadius: parent.frameObj.radius,
|
|
4501
|
+
frameLineStyle: parent.toPascalCase(parent.frameObj.border), lineCount: parent.frameObj.amount };
|
|
4502
|
+
var frameChange = { cancel: false, previousFrameSetting: prevFrameSettings,
|
|
4503
|
+
currentFrameSetting: currFrameSettings };
|
|
4047
4504
|
if (isBlazor()) {
|
|
4048
4505
|
if (parent.events && parent.events.frameChanging.hasDelegate === true) {
|
|
4049
4506
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
4050
|
-
parent.dotNetRef.invokeMethodAsync('OnFrameChangingAsync', frameChange).then(function (args) {
|
|
4507
|
+
parent.dotNetRef.invokeMethodAsync('OnFrameChangingAsync', 'FrameChanging', frameChange, null).then(function (args) {
|
|
4051
4508
|
if (!args.cancel) {
|
|
4052
4509
|
_this.setFrameObj(args.currentFrameSetting);
|
|
4053
4510
|
var obj = { currObj: {} };
|
|
@@ -4060,6 +4517,7 @@ var Draw = /** @class */ (function () {
|
|
|
4060
4517
|
} });
|
|
4061
4518
|
var fillColorDiv = parent.element.querySelector('.e-ie-toolbar-e-frame-color');
|
|
4062
4519
|
if (fillColorDiv) {
|
|
4520
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
4063
4521
|
parent.element.querySelector('.e-ie-toolbar-e-frame-color' + parent.DDBPREVIEW).style.background = parent.frameObj.color;
|
|
4064
4522
|
}
|
|
4065
4523
|
var graColorDiv = parent.element.querySelector('.e-ie-toolbar-e-frame-gradient');
|
|
@@ -4068,15 +4526,20 @@ var Draw = /** @class */ (function () {
|
|
|
4068
4526
|
if (noColorDiv) {
|
|
4069
4527
|
noColorDiv.querySelector('.e-nocolor-item').classList.remove('e-selected');
|
|
4070
4528
|
}
|
|
4529
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
4071
4530
|
parent.element.querySelector('.e-ie-toolbar-e-frame-gradient' + parent.DDBPREVIEW).classList.remove('e-nocolor-item');
|
|
4072
|
-
if (parent.frameObj.gradientColor
|
|
4531
|
+
if (parent.frameObj.gradientColor === '') {
|
|
4532
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
4073
4533
|
parent.element.querySelector('.e-ie-toolbar-e-frame-gradient' + parent.DDBPREVIEW).classList.add('e-nocolor-item');
|
|
4074
4534
|
}
|
|
4075
4535
|
else {
|
|
4536
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
4076
4537
|
parent.element.querySelector('.e-ie-toolbar-e-frame-gradient' + parent.DDBPREVIEW).style.background = parent.frameObj.gradientColor;
|
|
4077
4538
|
}
|
|
4078
4539
|
}
|
|
4079
4540
|
parent.notify('draw', { prop: 'render-image', value: { isMouseWheel: null } });
|
|
4541
|
+
parent.curFrameObjEvent = { currentFrameSetting: args.currentFrameSetting };
|
|
4542
|
+
parent.isFrameBtnClick = true;
|
|
4080
4543
|
}
|
|
4081
4544
|
});
|
|
4082
4545
|
}
|
|
@@ -4106,6 +4569,344 @@ var Draw = /** @class */ (function () {
|
|
|
4106
4569
|
parent.frameObj.border = currFrameSettings.frameLineStyle.toLowerCase();
|
|
4107
4570
|
parent.frameObj.amount = currFrameSettings.lineCount;
|
|
4108
4571
|
};
|
|
4572
|
+
Draw.prototype.zoomToSel = function (activeObj, isToolbar) {
|
|
4573
|
+
var parent = this.parent;
|
|
4574
|
+
if (this.straightenActObj && JSON.stringify(this.straightenActObj.activePoint) === JSON.stringify(activeObj.activePoint)) {
|
|
4575
|
+
parent.activeObj = extend({}, this.straightenActObj, null, true);
|
|
4576
|
+
if (parent.transform.straighten === 0) {
|
|
4577
|
+
var destWidth = parent.img.destWidth;
|
|
4578
|
+
var destHeight = parent.img.destHeight;
|
|
4579
|
+
parent.transform.straighten = 360;
|
|
4580
|
+
while (true) {
|
|
4581
|
+
if (!isNullOrUndefined(this.straightenInitZoom) &&
|
|
4582
|
+
(Math.round(parent.transform.zoomFactor * Math.pow(10, 3)) / Math.pow(10, 3)) >
|
|
4583
|
+
(Math.round(this.straightenInitZoom * Math.pow(10, 3)) / Math.pow(10, 3))) {
|
|
4584
|
+
this.setZoomPan('out');
|
|
4585
|
+
if (destWidth === parent.img.destWidth && destHeight === parent.img.destHeight) {
|
|
4586
|
+
this.performDummyZoom();
|
|
4587
|
+
break;
|
|
4588
|
+
}
|
|
4589
|
+
if (parent.transform.degree === 0) {
|
|
4590
|
+
parent.transform.zoomFactor -= 0.025;
|
|
4591
|
+
parent.transform.cropZoomFactor -= 0.025;
|
|
4592
|
+
}
|
|
4593
|
+
}
|
|
4594
|
+
else {
|
|
4595
|
+
this.performDummyZoom();
|
|
4596
|
+
break;
|
|
4597
|
+
}
|
|
4598
|
+
}
|
|
4599
|
+
parent.transform.straighten = 0;
|
|
4600
|
+
parent.img = { destLeft: parent.img.destLeft, destTop: parent.img.destTop, destWidth: parent.img.destWidth,
|
|
4601
|
+
destHeight: parent.img.destHeight, srcLeft: parent.img.srcLeft, srcTop: parent.img.srcTop,
|
|
4602
|
+
srcWidth: parent.img.srcWidth, srcHeight: parent.img.srcHeight };
|
|
4603
|
+
}
|
|
4604
|
+
else {
|
|
4605
|
+
if (isNullOrUndefined(this.straightenInitZoom)) {
|
|
4606
|
+
this.straightenInitZoom = parent.transform.zoomFactor;
|
|
4607
|
+
}
|
|
4608
|
+
if (this.straightenInitZoom - parent.transform.zoomFactor > 0) {
|
|
4609
|
+
parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
4610
|
+
value: { zoomFactor: -(this.straightenInitZoom - parent.transform.zoomFactor), zoomPoint: null, isResize: true } });
|
|
4611
|
+
}
|
|
4612
|
+
else if (this.straightenInitZoom - parent.transform.zoomFactor < 0) {
|
|
4613
|
+
parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
4614
|
+
value: { zoomFactor: (this.straightenInitZoom - parent.transform.zoomFactor), zoomPoint: null, isResize: true } });
|
|
4615
|
+
}
|
|
4616
|
+
parent.activeObj = extend({}, activeObj, null, true);
|
|
4617
|
+
parent.transform.zoomFactor += 0.001;
|
|
4618
|
+
this.calcStraightenedPoints(isToolbar);
|
|
4619
|
+
}
|
|
4620
|
+
}
|
|
4621
|
+
else {
|
|
4622
|
+
this.straightenActObj = extend({}, activeObj, null, true);
|
|
4623
|
+
parent.activeObj = extend({}, this.straightenActObj, null, true);
|
|
4624
|
+
this.straightenInitZoom = parent.transform.zoomFactor;
|
|
4625
|
+
this.calcStraightenedPoints(isToolbar);
|
|
4626
|
+
}
|
|
4627
|
+
};
|
|
4628
|
+
Draw.prototype.isDestPointSmall = function () {
|
|
4629
|
+
var parent = this.parent;
|
|
4630
|
+
var img = parent.img;
|
|
4631
|
+
var destPoints = { startX: img.destLeft, startY: img.destTop,
|
|
4632
|
+
width: img.destWidth, height: img.destHeight };
|
|
4633
|
+
parent.notify('shape', { prop: 'straightenShapes', onPropertyChange: false });
|
|
4634
|
+
var isSmall = false;
|
|
4635
|
+
if (this.straightenDestPoints.destWidth && this.straightenDestPoints.destHeight &&
|
|
4636
|
+
(img.destWidth < this.straightenDestPoints.destWidth || img.destHeight < this.straightenDestPoints.destHeight)) {
|
|
4637
|
+
isSmall = true;
|
|
4638
|
+
}
|
|
4639
|
+
img.destLeft = destPoints.startX;
|
|
4640
|
+
img.destTop = destPoints.startY;
|
|
4641
|
+
img.destWidth = destPoints.width;
|
|
4642
|
+
img.destHeight = destPoints.height;
|
|
4643
|
+
parent.img = img;
|
|
4644
|
+
return isSmall;
|
|
4645
|
+
};
|
|
4646
|
+
Draw.prototype.calcStraightenedPoints = function (isToolbar) {
|
|
4647
|
+
var parent = this.parent;
|
|
4648
|
+
var destWidth = parent.img.destWidth;
|
|
4649
|
+
var destHeight = parent.img.destHeight;
|
|
4650
|
+
if (isNullOrUndefined(parent.transform.zoomFactor)) {
|
|
4651
|
+
parent.transform.zoomFactor += 0.025;
|
|
4652
|
+
}
|
|
4653
|
+
this.updateImgCanvasPoints();
|
|
4654
|
+
var _loop_1 = function () {
|
|
4655
|
+
if (this_1.isLinesIntersect() || this_1.isSelOutsideImg() || (isToolbar && this_1.isDestPointSmall())) {
|
|
4656
|
+
parent.activeObj = extend({}, this_1.straightenActObj, null, true);
|
|
4657
|
+
this_1.setZoomPan('in');
|
|
4658
|
+
if (destWidth === parent.img.destWidth && destHeight === parent.img.destHeight) {
|
|
4659
|
+
this_1.performDummyZoom();
|
|
4660
|
+
return "break";
|
|
4661
|
+
}
|
|
4662
|
+
if (parent.transform.degree === 0) {
|
|
4663
|
+
parent.transform.zoomFactor += 0.025;
|
|
4664
|
+
parent.transform.cropZoomFactor += 0.025;
|
|
4665
|
+
}
|
|
4666
|
+
var points = this_1.imgCanvasPoints;
|
|
4667
|
+
var left_1 = parent.img.destLeft;
|
|
4668
|
+
var top_1 = parent.img.destTop;
|
|
4669
|
+
var width_1 = parent.img.destWidth;
|
|
4670
|
+
var height_1 = parent.img.destHeight;
|
|
4671
|
+
points.forEach(function (point) {
|
|
4672
|
+
point.x = (point.ratioX * width_1) + left_1;
|
|
4673
|
+
point.y = (point.ratioY * height_1) + top_1;
|
|
4674
|
+
});
|
|
4675
|
+
this_1.imgCanvasPoints = points;
|
|
4676
|
+
}
|
|
4677
|
+
else {
|
|
4678
|
+
this_1.performDummyZoom();
|
|
4679
|
+
return "break";
|
|
4680
|
+
}
|
|
4681
|
+
};
|
|
4682
|
+
var this_1 = this;
|
|
4683
|
+
while (true) {
|
|
4684
|
+
var state_1 = _loop_1();
|
|
4685
|
+
if (state_1 === "break")
|
|
4686
|
+
break;
|
|
4687
|
+
}
|
|
4688
|
+
};
|
|
4689
|
+
Draw.prototype.performDummyZoom = function () {
|
|
4690
|
+
var parent = this.parent;
|
|
4691
|
+
parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
4692
|
+
value: { zoomFactor: 0.025, zoomPoint: null, isResize: true } });
|
|
4693
|
+
parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
4694
|
+
value: { zoomFactor: -0.025, zoomPoint: null, isResize: true } });
|
|
4695
|
+
var zoom = parent.transform.zoomFactor * 10;
|
|
4696
|
+
if (zoom < 1) {
|
|
4697
|
+
zoom = 1 + (zoom / 10);
|
|
4698
|
+
}
|
|
4699
|
+
parent.setProperties({ zoomSettings: { zoomFactor: zoom } }, true);
|
|
4700
|
+
parent.notify('transform', { prop: 'setPreviousZoomValue', onPropertyChange: false,
|
|
4701
|
+
value: { previousZoomValue: zoom } });
|
|
4702
|
+
this.panToSel();
|
|
4703
|
+
};
|
|
4704
|
+
Draw.prototype.setZoomPan = function (type) {
|
|
4705
|
+
var parent = this.parent;
|
|
4706
|
+
var obj = { maxDimension: null };
|
|
4707
|
+
if (parent.transform.degree === 0) {
|
|
4708
|
+
parent.notify('transform', { prop: 'cropZoom', onPropertyChange: false,
|
|
4709
|
+
value: { value: type === 'in' ? 0.025 : -0.025, selectionObj: parent.activeObj, obj: obj } });
|
|
4710
|
+
parent.img.destWidth = obj['maxDimension']['width'];
|
|
4711
|
+
parent.img.destHeight = obj['maxDimension']['height'];
|
|
4712
|
+
}
|
|
4713
|
+
else {
|
|
4714
|
+
parent.transform.zoomFactor += (type === 'in' ? 0.025 : -0.025);
|
|
4715
|
+
parent.transform.cropZoomFactor += (type === 'in' ? 0.025 : -0.025);
|
|
4716
|
+
this.updateCurrTransState('initial');
|
|
4717
|
+
this.isRotateZoom = true;
|
|
4718
|
+
this.setDestPoints();
|
|
4719
|
+
this.isRotateZoom = false;
|
|
4720
|
+
this.updateCurrTransState('reverse');
|
|
4721
|
+
}
|
|
4722
|
+
};
|
|
4723
|
+
Draw.prototype.updateImgCanvasPoints = function () {
|
|
4724
|
+
var parent = this.parent;
|
|
4725
|
+
var points = this.getImagePoints();
|
|
4726
|
+
var obj = { width: 0, height: 0 };
|
|
4727
|
+
var width = parent.baseImgCanvas.width;
|
|
4728
|
+
var height = parent.baseImgCanvas.height;
|
|
4729
|
+
parent.notify('crop', { prop: 'calcRatio', onPropertyChange: false,
|
|
4730
|
+
value: { obj: obj, dimension: { width: width, height: height } } });
|
|
4731
|
+
var ratio = obj;
|
|
4732
|
+
width = parent.transform.degree % 90 === 0 && parent.transform.degree % 180 !== 0 ?
|
|
4733
|
+
ratio.height : ratio.width;
|
|
4734
|
+
height = parent.transform.degree % 90 === 0 && parent.transform.degree % 180 !== 0 ?
|
|
4735
|
+
ratio.width : ratio.height;
|
|
4736
|
+
var p1;
|
|
4737
|
+
var p2;
|
|
4738
|
+
var p3;
|
|
4739
|
+
var p4;
|
|
4740
|
+
var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
|
|
4741
|
+
if (parent.transform.straighten > 0) {
|
|
4742
|
+
p1 = { x: destLeft + (points[0].x / width), y: destTop };
|
|
4743
|
+
p2 = { x: destLeft + destWidth, y: destTop + (points[1].y / height) };
|
|
4744
|
+
p3 = { x: destLeft + destWidth - (points[0].x / width), y: destTop + destHeight };
|
|
4745
|
+
p4 = { x: destLeft, y: destTop + destHeight - (points[1].y / height) };
|
|
4746
|
+
}
|
|
4747
|
+
else {
|
|
4748
|
+
p1 = { x: destLeft, y: destTop + (points[0].y / height) };
|
|
4749
|
+
p2 = { x: destLeft + (points[1].x / width), y: destTop };
|
|
4750
|
+
p3 = { x: destLeft + destWidth, y: destTop + destHeight - (points[0].y / height) };
|
|
4751
|
+
p4 = { x: destLeft + destWidth - (points[1].x / width), y: destTop + destHeight };
|
|
4752
|
+
}
|
|
4753
|
+
p1.ratioX = (p1.x - destLeft) / destWidth;
|
|
4754
|
+
p1.ratioY = (p1.y - destTop) / destHeight;
|
|
4755
|
+
p2.ratioX = (p2.x - destLeft) / destWidth;
|
|
4756
|
+
p2.ratioY = (p2.y - destTop) / destHeight;
|
|
4757
|
+
p3.ratioX = (p3.x - destLeft) / destWidth;
|
|
4758
|
+
p3.ratioY = (p3.y - destTop) / destHeight;
|
|
4759
|
+
p4.ratioX = (p4.x - destLeft) / destWidth;
|
|
4760
|
+
p4.ratioY = (p4.y - destTop) / destHeight;
|
|
4761
|
+
this.imgCanvasPoints = [p1, p2, p3, p4];
|
|
4762
|
+
};
|
|
4763
|
+
Draw.prototype.isLinesIntersect = function (obj) {
|
|
4764
|
+
var parent = this.parent;
|
|
4765
|
+
var point = parent.activeObj.activePoint;
|
|
4766
|
+
var imgPoints = this.imgCanvasPoints;
|
|
4767
|
+
var isTopIntersect = this.doIntersect({ x: point.startX, y: point.startY }, { x: point.endX, y: point.startY }, imgPoints[0], imgPoints[1]);
|
|
4768
|
+
var isRightIntersect = this.doIntersect({ x: point.endX, y: point.startY }, { x: point.endX, y: point.endY }, imgPoints[1], imgPoints[2]);
|
|
4769
|
+
var isBottomIntersect = this.doIntersect({ x: point.startX, y: point.endY }, { x: point.endX, y: point.endY }, imgPoints[2], imgPoints[3]);
|
|
4770
|
+
var isLeftIntersect = this.doIntersect({ x: point.startX, y: point.startY }, { x: point.startX, y: point.endY }, imgPoints[3], imgPoints[0]);
|
|
4771
|
+
var isTopLeftInsideRect = this.isInsideRect(imgPoints[0]);
|
|
4772
|
+
var isTopRightInsideRect = this.isInsideRect(imgPoints[1]);
|
|
4773
|
+
var isBottomRightInsideRect = this.isInsideRect(imgPoints[2]);
|
|
4774
|
+
var isBottomLeftInsideRect = this.isInsideRect(imgPoints[3]);
|
|
4775
|
+
if (obj) {
|
|
4776
|
+
obj['arr'] = [isTopIntersect, isRightIntersect, isBottomIntersect, isLeftIntersect];
|
|
4777
|
+
}
|
|
4778
|
+
return isTopIntersect || isRightIntersect || isBottomIntersect || isLeftIntersect ||
|
|
4779
|
+
isTopLeftInsideRect || isTopRightInsideRect || isBottomRightInsideRect || isBottomLeftInsideRect ||
|
|
4780
|
+
(imgPoints[0].x > point.startX && imgPoints[1].x < point.endX &&
|
|
4781
|
+
imgPoints[2].x < point.endX && imgPoints[3].x > point.startX &&
|
|
4782
|
+
imgPoints[0].y < point.startY && imgPoints[1].y < point.startY &&
|
|
4783
|
+
imgPoints[2].y > point.endY && imgPoints[3].y > point.endY) ||
|
|
4784
|
+
(imgPoints[0].x < point.startX && imgPoints[1].x > point.endX &&
|
|
4785
|
+
imgPoints[2].x > point.endX && imgPoints[3].x < point.startX &&
|
|
4786
|
+
imgPoints[0].y > point.startY && imgPoints[1].y > point.startY &&
|
|
4787
|
+
imgPoints[2].y < point.endY && imgPoints[3].y < point.endY);
|
|
4788
|
+
};
|
|
4789
|
+
Draw.prototype.isSelOutsideImg = function () {
|
|
4790
|
+
var parent = this.parent;
|
|
4791
|
+
var points = this.imgCanvasPoints;
|
|
4792
|
+
var actPoint = parent.activeObj.activePoint;
|
|
4793
|
+
return (this.checkPointPosition(actPoint.startX, actPoint.startY, points[0].x, points[0].y, points[1].x, points[1].y, points[2].x, points[2].y, points[3].x, points[3].y) !== 'inside' ||
|
|
4794
|
+
this.checkPointPosition(actPoint.endX, actPoint.startY, points[0].x, points[0].y, points[1].x, points[1].y, points[2].x, points[2].y, points[3].x, points[3].y) !== 'inside' ||
|
|
4795
|
+
this.checkPointPosition(actPoint.startX, actPoint.endY, points[0].x, points[0].y, points[1].x, points[1].y, points[2].x, points[2].y, points[3].x, points[3].y) !== 'inside' ||
|
|
4796
|
+
this.checkPointPosition(actPoint.endX, actPoint.endY, points[0].x, points[0].y, points[1].x, points[1].y, points[2].x, points[2].y, points[3].x, points[3].y) !== 'inside');
|
|
4797
|
+
};
|
|
4798
|
+
Draw.prototype.calcTriangleArea = function (x1, y1, x2, y2, x3, y3) {
|
|
4799
|
+
return Math.abs((x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)) / 2);
|
|
4800
|
+
};
|
|
4801
|
+
Draw.prototype.checkPointPosition = function (x, y, x1, y1, x2, y2, x3, y3, x4, y4) {
|
|
4802
|
+
var area1 = this.calcTriangleArea(x, y, x1, y1, x4, y4);
|
|
4803
|
+
var area2 = this.calcTriangleArea(x, y, x4, y4, x3, y3);
|
|
4804
|
+
var area3 = this.calcTriangleArea(x, y, x3, y3, x2, y2);
|
|
4805
|
+
var area4 = this.calcTriangleArea(x, y, x2, y2, x1, y1);
|
|
4806
|
+
var areaRectangle = this.calcTriangleArea(x1, y1, x2, y2, x3, y3) + this.calcTriangleArea(x3, y3, x4, y4, x1, y1);
|
|
4807
|
+
if (area1 + area2 + area3 + area4 > areaRectangle) {
|
|
4808
|
+
return 'outside';
|
|
4809
|
+
}
|
|
4810
|
+
else if (area1 + area2 + area3 + area4 === areaRectangle && (area1 === 0 || area2 === 0 || area3 === 0 || area4 === 0)) {
|
|
4811
|
+
return 'on';
|
|
4812
|
+
}
|
|
4813
|
+
else {
|
|
4814
|
+
return 'inside';
|
|
4815
|
+
}
|
|
4816
|
+
};
|
|
4817
|
+
Draw.prototype.getImagePoints = function () {
|
|
4818
|
+
var point = [];
|
|
4819
|
+
var parent = this.parent;
|
|
4820
|
+
var degree = parent.transform.degree;
|
|
4821
|
+
var width = parent.baseImg.width;
|
|
4822
|
+
var height = parent.baseImg.height;
|
|
4823
|
+
var obj = { dim: null, width: height, height: width, angle: parent.transform.straighten };
|
|
4824
|
+
obj['dim'] = parent.getRotatedCanvasDim(obj['width'], obj['height'], obj['angle']);
|
|
4825
|
+
var baseImgCanvasWidth = degree % 90 === 0 && degree % 180 !== 0 ? obj['dim']['width'] : parent.baseImgCanvas.width;
|
|
4826
|
+
var baseImgCanvasHeight = degree % 90 === 0 && degree % 180 !== 0 ? obj['dim']['height'] : parent.baseImgCanvas.height;
|
|
4827
|
+
var baseImgWidth = degree % 90 === 0 && degree % 180 !== 0 ? height : width;
|
|
4828
|
+
var baseImgHeight = degree % 90 === 0 && degree % 180 !== 0 ? width : height;
|
|
4829
|
+
var centerX = baseImgCanvasWidth / 2;
|
|
4830
|
+
var centerY = baseImgCanvasHeight / 2;
|
|
4831
|
+
var startX = centerX - (baseImgWidth / 2);
|
|
4832
|
+
var startY = centerY - (baseImgHeight / 2);
|
|
4833
|
+
var endX = centerX + (baseImgWidth / 2);
|
|
4834
|
+
var endY = centerY + (baseImgHeight / 2);
|
|
4835
|
+
var center = { x: centerX, y: centerY };
|
|
4836
|
+
var radians = parent.transform.straighten * (Math.PI / 180);
|
|
4837
|
+
var p1 = { x: Math.cos(radians) * (startX - center.x) - Math.sin(radians) * (startY - center.y) + center.x,
|
|
4838
|
+
y: Math.sin(radians) * (startX - center.x) + Math.cos(radians) * (startY - center.y) + center.y };
|
|
4839
|
+
var p2 = { x: Math.cos(radians) * (endX - center.x) - Math.sin(radians) * (startY - center.y) + center.x,
|
|
4840
|
+
y: Math.sin(radians) * (endX - center.x) + Math.cos(radians) * (startY - center.y) + center.y };
|
|
4841
|
+
var p3 = { x: Math.cos(radians) * (endX - center.x) - Math.sin(radians) * (endY - center.y) + center.x,
|
|
4842
|
+
y: Math.sin(radians) * (endX - center.x) + Math.cos(radians) * (endY - center.y) + center.y };
|
|
4843
|
+
var p4 = { x: Math.cos(radians) * (startX - center.x) - Math.sin(radians) * (endY - center.y) + center.x,
|
|
4844
|
+
y: Math.sin(radians) * (startX - center.x) + Math.cos(radians) * (endY - center.y) + center.y };
|
|
4845
|
+
point.push(p1);
|
|
4846
|
+
point.push(p2);
|
|
4847
|
+
point.push(p3);
|
|
4848
|
+
point.push(p4);
|
|
4849
|
+
return point;
|
|
4850
|
+
};
|
|
4851
|
+
Draw.prototype.doIntersect = function (a, b, c, d) {
|
|
4852
|
+
var point1 = this.initiation(a, b, c);
|
|
4853
|
+
var point2 = this.initiation(a, b, d);
|
|
4854
|
+
var point3 = this.initiation(c, d, a);
|
|
4855
|
+
var point4 = this.initiation(c, d, b);
|
|
4856
|
+
if (point1 !== point2 && point3 !== point4) {
|
|
4857
|
+
return true;
|
|
4858
|
+
}
|
|
4859
|
+
if (point1 === 0 && this.onSegment(a, c, b)) {
|
|
4860
|
+
return true;
|
|
4861
|
+
}
|
|
4862
|
+
if (point2 === 0 && this.onSegment(a, d, b)) {
|
|
4863
|
+
return true;
|
|
4864
|
+
}
|
|
4865
|
+
if (point3 === 0 && this.onSegment(c, a, d)) {
|
|
4866
|
+
return true;
|
|
4867
|
+
}
|
|
4868
|
+
if (point4 === 0 && this.onSegment(c, b, d)) {
|
|
4869
|
+
return true;
|
|
4870
|
+
}
|
|
4871
|
+
return false;
|
|
4872
|
+
};
|
|
4873
|
+
Draw.prototype.initiation = function (a, b, c) {
|
|
4874
|
+
var value = (b.y - a.y) * (c.x - b.x) - (b.x - a.x) * (c.y - b.y);
|
|
4875
|
+
if (value === 0) {
|
|
4876
|
+
return 0;
|
|
4877
|
+
}
|
|
4878
|
+
return (value > 0) ? 1 : 2;
|
|
4879
|
+
};
|
|
4880
|
+
Draw.prototype.onSegment = function (a, b, c) {
|
|
4881
|
+
if (b.x <= Math.max(a.x, c.x) && b.x >= Math.min(a.x, c.x) &&
|
|
4882
|
+
b.y <= Math.max(a.y, c.y) && b.y >= Math.min(a.y, c.y)) {
|
|
4883
|
+
return true;
|
|
4884
|
+
}
|
|
4885
|
+
return false;
|
|
4886
|
+
};
|
|
4887
|
+
Draw.prototype.isInsideRect = function (point) {
|
|
4888
|
+
var parent = this.parent;
|
|
4889
|
+
var actPoint = parent.activeObj.activePoint;
|
|
4890
|
+
var isInside = false;
|
|
4891
|
+
if (point.x >= actPoint.startX && point.x <= actPoint.endX &&
|
|
4892
|
+
point.y >= actPoint.startY && point.y <= actPoint.endY) {
|
|
4893
|
+
isInside = true;
|
|
4894
|
+
}
|
|
4895
|
+
return isInside;
|
|
4896
|
+
};
|
|
4897
|
+
Draw.prototype.setDestForStraighten = function () {
|
|
4898
|
+
var parent = this.parent;
|
|
4899
|
+
if (isNullOrUndefined(this.straightenDestPoints)) {
|
|
4900
|
+
var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
|
|
4901
|
+
// If straightening performed, then destination points are set in non-straightened state
|
|
4902
|
+
parent.notify('shape', { prop: 'straightenShapes', onPropertyChange: false });
|
|
4903
|
+
this.straightenDestPoints = extend({}, parent.img, {}, true);
|
|
4904
|
+
parent.img.destLeft = destLeft;
|
|
4905
|
+
parent.img.destTop = destTop;
|
|
4906
|
+
parent.img.destWidth = destWidth;
|
|
4907
|
+
parent.img.destHeight = destHeight;
|
|
4908
|
+
}
|
|
4909
|
+
};
|
|
4109
4910
|
return Draw;
|
|
4110
4911
|
}());
|
|
4111
4912
|
export { Draw };
|