@syncfusion/ej2-image-editor 26.2.14 → 27.1.50
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/README.md +1 -1
- 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 +3267 -731
- package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
- package/dist/es6/ej2-image-editor.es5.js +3345 -795
- 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 +13 -13
- package/src/image-editor/action/crop.d.ts +0 -1
- package/src/image-editor/action/crop.js +8 -19
- package/src/image-editor/action/draw.d.ts +4 -0
- package/src/image-editor/action/draw.js +401 -47
- package/src/image-editor/action/export.js +21 -13
- package/src/image-editor/action/filter.d.ts +13 -0
- package/src/image-editor/action/filter.js +272 -1
- package/src/image-editor/action/freehand-draw.d.ts +1 -0
- package/src/image-editor/action/freehand-draw.js +44 -23
- package/src/image-editor/action/selection.d.ts +9 -0
- package/src/image-editor/action/selection.js +420 -98
- package/src/image-editor/action/shape.d.ts +5 -0
- package/src/image-editor/action/shape.js +291 -141
- package/src/image-editor/action/transform.js +56 -82
- package/src/image-editor/action/undo-redo.d.ts +2 -0
- package/src/image-editor/action/undo-redo.js +100 -1
- package/src/image-editor/base/enum.d.ts +11 -0
- package/src/image-editor/base/enum.js +12 -0
- package/src/image-editor/base/image-editor-model.d.ts +13 -1
- package/src/image-editor/base/image-editor.d.ts +142 -20
- package/src/image-editor/base/image-editor.js +814 -150
- package/src/image-editor/base/interface.d.ts +140 -1
- package/src/image-editor/renderer/toolbar.d.ts +8 -0
- package/src/image-editor/renderer/toolbar.js +876 -193
- package/styles/bootstrap-dark-lite.css +746 -0
- package/styles/bootstrap-dark-lite.scss +13 -0
- package/styles/bootstrap-dark.css +150 -105
- package/styles/bootstrap-dark.scss +1 -0
- package/styles/bootstrap-lite.css +747 -0
- package/styles/bootstrap-lite.scss +13 -0
- package/styles/bootstrap.css +151 -106
- package/styles/bootstrap.scss +1 -0
- package/styles/bootstrap4-lite.css +747 -0
- package/styles/bootstrap4-lite.scss +13 -0
- package/styles/bootstrap4.css +150 -105
- package/styles/bootstrap4.scss +1 -0
- package/styles/bootstrap5-dark-lite.css +757 -0
- package/styles/bootstrap5-dark-lite.scss +13 -0
- package/styles/bootstrap5-dark.css +152 -113
- package/styles/bootstrap5-dark.scss +1 -0
- package/styles/bootstrap5-lite.css +757 -0
- package/styles/bootstrap5-lite.scss +13 -0
- package/styles/bootstrap5.3-lite.css +760 -0
- package/styles/bootstrap5.3-lite.scss +13 -0
- package/styles/bootstrap5.3.css +867 -0
- package/styles/bootstrap5.3.scss +14 -0
- package/styles/bootstrap5.css +152 -113
- package/styles/bootstrap5.scss +1 -0
- package/styles/fabric-dark-lite.css +749 -0
- package/styles/fabric-dark-lite.scss +13 -0
- package/styles/fabric-dark.css +150 -105
- package/styles/fabric-dark.scss +1 -0
- package/styles/fabric-lite.css +751 -0
- package/styles/fabric-lite.scss +13 -0
- package/styles/fabric.css +151 -106
- package/styles/fabric.scss +1 -0
- package/styles/fluent-dark-lite.css +758 -0
- package/styles/fluent-dark-lite.scss +13 -0
- package/styles/fluent-dark.css +150 -111
- package/styles/fluent-dark.scss +1 -0
- package/styles/fluent-lite.css +758 -0
- package/styles/fluent-lite.scss +13 -0
- package/styles/fluent.css +150 -111
- package/styles/fluent.scss +1 -0
- package/styles/fluent2-lite.css +791 -0
- package/styles/fluent2-lite.scss +13 -0
- package/styles/fluent2.css +173 -117
- package/styles/fluent2.scss +1 -0
- package/styles/highcontrast-light-lite.css +748 -0
- package/styles/highcontrast-light-lite.scss +13 -0
- package/styles/highcontrast-light.css +149 -104
- package/styles/highcontrast-light.scss +1 -0
- package/styles/highcontrast-lite.css +753 -0
- package/styles/highcontrast-lite.scss +13 -0
- package/styles/highcontrast.css +150 -104
- package/styles/highcontrast.scss +1 -0
- package/styles/image-editor/_bds-definition.scss +3 -1
- package/styles/image-editor/_bigger.scss +216 -0
- package/styles/image-editor/_bootstrap-dark-definition.scss +3 -1
- package/styles/image-editor/_bootstrap-definition.scss +3 -1
- package/styles/image-editor/_bootstrap4-definition.scss +3 -1
- package/styles/image-editor/_bootstrap5-definition.scss +3 -1
- package/styles/image-editor/_bootstrap5.3-definition.scss +3 -1
- package/styles/image-editor/_fabric-dark-definition.scss +3 -1
- package/styles/image-editor/_fabric-definition.scss +3 -1
- package/styles/image-editor/_fluent-definition.scss +3 -1
- package/styles/image-editor/_fluent2-definition.scss +4 -2
- package/styles/image-editor/_fusionnew-definition.scss +3 -1
- package/styles/image-editor/_highcontrast-definition.scss +3 -1
- package/styles/image-editor/_highcontrast-light-definition.scss +3 -1
- package/styles/image-editor/_layout.scss +75 -212
- package/styles/image-editor/_material-dark-definition.scss +3 -1
- package/styles/image-editor/_material-definition.scss +3 -1
- package/styles/image-editor/_material3-definition.scss +5 -3
- package/styles/image-editor/_tailwind-definition.scss +5 -3
- package/styles/image-editor/_theme.scss +48 -11
- package/styles/image-editor/bootstrap-dark.css +150 -105
- package/styles/image-editor/bootstrap-dark.scss +1 -0
- package/styles/image-editor/bootstrap.css +151 -106
- package/styles/image-editor/bootstrap.scss +1 -0
- package/styles/image-editor/bootstrap4.css +150 -105
- package/styles/image-editor/bootstrap4.scss +1 -0
- package/styles/image-editor/bootstrap5-dark.css +152 -113
- package/styles/image-editor/bootstrap5-dark.scss +1 -0
- package/styles/image-editor/bootstrap5.3.css +867 -0
- package/styles/image-editor/bootstrap5.3.scss +14 -0
- package/styles/image-editor/bootstrap5.css +152 -113
- package/styles/image-editor/bootstrap5.scss +1 -0
- package/styles/image-editor/fabric-dark.css +150 -105
- package/styles/image-editor/fabric-dark.scss +1 -0
- package/styles/image-editor/fabric.css +151 -106
- package/styles/image-editor/fabric.scss +1 -0
- package/styles/image-editor/fluent-dark.css +150 -111
- package/styles/image-editor/fluent-dark.scss +1 -0
- package/styles/image-editor/fluent.css +150 -111
- package/styles/image-editor/fluent.scss +1 -0
- package/styles/image-editor/fluent2.css +173 -117
- package/styles/image-editor/fluent2.scss +1 -0
- package/styles/image-editor/highcontrast-light.css +149 -104
- package/styles/image-editor/highcontrast-light.scss +1 -0
- package/styles/image-editor/highcontrast.css +150 -104
- package/styles/image-editor/highcontrast.scss +1 -0
- package/styles/image-editor/icons/_bds.scss +10 -1
- package/styles/image-editor/icons/_bootstrap-dark.scss +10 -1
- package/styles/image-editor/icons/_bootstrap.scss +10 -1
- package/styles/image-editor/icons/_bootstrap4.scss +10 -1
- package/styles/image-editor/icons/_bootstrap5.3.scss +10 -1
- package/styles/image-editor/icons/_bootstrap5.scss +10 -1
- package/styles/image-editor/icons/_fabric-dark.scss +10 -1
- package/styles/image-editor/icons/_fabric.scss +10 -1
- package/styles/image-editor/icons/_fluent.scss +10 -1
- package/styles/image-editor/icons/_fluent2.scss +10 -1
- package/styles/image-editor/icons/_fusionnew.scss +10 -1
- package/styles/image-editor/icons/_highcontrast-light.scss +10 -1
- package/styles/image-editor/icons/_highcontrast.scss +10 -1
- package/styles/image-editor/icons/_material-dark.scss +10 -1
- package/styles/image-editor/icons/_material.scss +10 -1
- package/styles/image-editor/icons/_material3.scss +10 -1
- package/styles/image-editor/icons/_tailwind.scss +10 -1
- package/styles/image-editor/material-dark.css +153 -108
- package/styles/image-editor/material-dark.scss +1 -0
- package/styles/image-editor/material.css +159 -114
- package/styles/image-editor/material.scss +1 -0
- package/styles/image-editor/material3-dark.css +171 -123
- package/styles/image-editor/material3-dark.scss +1 -0
- package/styles/image-editor/material3.css +171 -123
- package/styles/image-editor/material3.scss +1 -0
- package/styles/image-editor/tailwind-dark.css +154 -116
- package/styles/image-editor/tailwind-dark.scss +1 -0
- package/styles/image-editor/tailwind.css +154 -116
- package/styles/image-editor/tailwind.scss +1 -0
- package/styles/material-dark-lite.css +767 -0
- package/styles/material-dark-lite.scss +13 -0
- package/styles/material-dark.css +153 -108
- package/styles/material-dark.scss +1 -0
- package/styles/material-lite.css +769 -0
- package/styles/material-lite.scss +13 -0
- package/styles/material.css +159 -114
- package/styles/material.scss +1 -0
- package/styles/material3-dark-lite.css +799 -0
- package/styles/material3-dark-lite.scss +13 -0
- package/styles/material3-dark.css +171 -123
- package/styles/material3-dark.scss +1 -0
- package/styles/material3-lite.css +801 -0
- package/styles/material3-lite.scss +13 -0
- package/styles/material3.css +171 -123
- package/styles/material3.scss +1 -0
- package/styles/tailwind-dark-lite.css +751 -0
- package/styles/tailwind-dark-lite.scss +13 -0
- package/styles/tailwind-dark.css +154 -116
- package/styles/tailwind-dark.scss +1 -0
- package/styles/tailwind-lite.css +751 -0
- package/styles/tailwind-lite.scss +13 -0
- package/styles/tailwind.css +154 -116
- package/styles/tailwind.scss +1 -0
|
@@ -44,7 +44,7 @@ var Draw = /** @class */ (function () {
|
|
|
44
44
|
this.isErrorImage = false;
|
|
45
45
|
this.isShapeTextInserted = false;
|
|
46
46
|
this.isRotateZoom = false; // To restore zoomed image on selection crop selection
|
|
47
|
-
this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null }; // restore stroke settings on cancel
|
|
47
|
+
this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null, outlineColor: '', radius: null, outlineWidth: null }; // restore stroke settings on cancel
|
|
48
48
|
this.tempTextSettings = { text: 'Enter Text', fontFamily: '', fontSize: null, fontRatio: null, bold: false, italic: false, underline: false }; // restore text settings on cancel
|
|
49
49
|
this.tempAdjValue = ''; // for temp internal slider value
|
|
50
50
|
this.tempFilter = ''; // restore filter style on cancel
|
|
@@ -71,6 +71,8 @@ var Draw = /** @class */ (function () {
|
|
|
71
71
|
this.tempObjColl = [];
|
|
72
72
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
73
73
|
this.tempPointColl = {};
|
|
74
|
+
this.imageBackgroundColor = '';
|
|
75
|
+
this.allowRedactStraighten = true;
|
|
74
76
|
this.parent = parent;
|
|
75
77
|
this.addEventListener();
|
|
76
78
|
}
|
|
@@ -143,7 +145,7 @@ var Draw = /** @class */ (function () {
|
|
|
143
145
|
this.redrawImgWithObj();
|
|
144
146
|
break;
|
|
145
147
|
case 'setCurrentObj':
|
|
146
|
-
this.setCurrentObj(args.value['obj'], args.value['isUndoRedo']);
|
|
148
|
+
this.setCurrentObj(args.value['obj'], args.value['isUndoRedo'], args.value['isCircleCrop']);
|
|
147
149
|
break;
|
|
148
150
|
case 'performPointZoom':
|
|
149
151
|
this.performPointZoom(args.value['x'], args.value['y'], args.value['type'], args.value['isResize']);
|
|
@@ -336,6 +338,18 @@ var Draw = /** @class */ (function () {
|
|
|
336
338
|
case 'resetTempPointColl':
|
|
337
339
|
this.tempPointColl = {};
|
|
338
340
|
break;
|
|
341
|
+
case 'showDialogPopup':
|
|
342
|
+
this.showDialogPopup();
|
|
343
|
+
break;
|
|
344
|
+
case 'imageBackgroundColor':
|
|
345
|
+
this.imageBackgroundColor = args.value['color'];
|
|
346
|
+
break;
|
|
347
|
+
case 'getImageBackgroundColor':
|
|
348
|
+
args.value['obj']['color'] = this.imageBackgroundColor;
|
|
349
|
+
break;
|
|
350
|
+
case 'setTempStrokeWidth':
|
|
351
|
+
this.tempStrokeWidth = args.value['strokeWidth'];
|
|
352
|
+
break;
|
|
339
353
|
}
|
|
340
354
|
};
|
|
341
355
|
Draw.prototype.getModuleName = function () {
|
|
@@ -366,7 +380,7 @@ var Draw = /** @class */ (function () {
|
|
|
366
380
|
this.currSelPoint = null;
|
|
367
381
|
this.isRotateZoom = false;
|
|
368
382
|
this.tempAdjValue = '';
|
|
369
|
-
this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null };
|
|
383
|
+
this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null, radius: null, outlineColor: '', outlineWidth: null };
|
|
370
384
|
this.tempTextSettings =
|
|
371
385
|
{ text: 'Enter Text', fontFamily: this.parent.fontFamily.default, fontSize: null, fontRatio: null, bold: false, italic: false, underline: false };
|
|
372
386
|
this.tempUndoRedoStep = this.tempFreehandCounter = this.tempCurrFhdIndex = 0;
|
|
@@ -381,8 +395,11 @@ var Draw = /** @class */ (function () {
|
|
|
381
395
|
this.straightenActObj = null;
|
|
382
396
|
this.imgCanvasPoints = [];
|
|
383
397
|
this.straightenInitZoom = null;
|
|
398
|
+
this.allowRedactStraighten = true;
|
|
384
399
|
this.tempObjColl = [];
|
|
385
400
|
this.tempPointColl = {};
|
|
401
|
+
this.imageBackgroundColor = '';
|
|
402
|
+
this.tempStrokeWidth = null;
|
|
386
403
|
this.straightenDestPoints = null;
|
|
387
404
|
this.isCropSelect = this.isDownScale = this.preventStraightening = false;
|
|
388
405
|
};
|
|
@@ -553,7 +570,7 @@ var Draw = /** @class */ (function () {
|
|
|
553
570
|
var parent = this.parent;
|
|
554
571
|
var actPoint = parent.activeObj.activePoint;
|
|
555
572
|
var _a = parent.activeObj, shape = _a.shape, rotatedAngle = _a.rotatedAngle;
|
|
556
|
-
if (actPoint && shape !== 'image' && shape !== 'line' && rotatedAngle === 0) {
|
|
573
|
+
if (actPoint && shape !== 'image' && shape !== 'line' && rotatedAngle === 0 && parent.activeObj.preventShapeDragOut) {
|
|
557
574
|
var _b = parent.img, destLeft = _b.destLeft, destTop = _b.destTop, destWidth = _b.destWidth, destHeight = _b.destHeight;
|
|
558
575
|
if (actPoint.startX < destLeft) {
|
|
559
576
|
actPoint.startX = destLeft;
|
|
@@ -580,8 +597,6 @@ var Draw = /** @class */ (function () {
|
|
|
580
597
|
var y;
|
|
581
598
|
var width;
|
|
582
599
|
var height;
|
|
583
|
-
var canvasWidth = parent.lowerCanvas.clientWidth;
|
|
584
|
-
var canvasHeight = parent.lowerCanvas.clientHeight + 1;
|
|
585
600
|
var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
|
|
586
601
|
if (parent.transform.zoomFactor > 0 && this.currSelPoint) {
|
|
587
602
|
var activeObj = extend({}, parent.activeObj, {}, true);
|
|
@@ -594,18 +609,8 @@ var Draw = /** @class */ (function () {
|
|
|
594
609
|
height = width;
|
|
595
610
|
}
|
|
596
611
|
else {
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
}
|
|
600
|
-
else {
|
|
601
|
-
width = parent.transform.straighten === 0 ? canvasWidth - destLeft : actPoint.width;
|
|
602
|
-
}
|
|
603
|
-
if (destTop + destTop + destHeight <= canvasHeight) {
|
|
604
|
-
height = actPoint.height;
|
|
605
|
-
}
|
|
606
|
-
else {
|
|
607
|
-
height = parent.transform.straighten === 0 ? canvasHeight - destTop : actPoint.height;
|
|
608
|
-
}
|
|
612
|
+
width = actPoint.width;
|
|
613
|
+
height = actPoint.height;
|
|
609
614
|
}
|
|
610
615
|
parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
|
|
611
616
|
parent.activeObj = activeObj;
|
|
@@ -950,7 +955,9 @@ var Draw = /** @class */ (function () {
|
|
|
950
955
|
canvasDraw.lineWidth /= 2;
|
|
951
956
|
}
|
|
952
957
|
else {
|
|
953
|
-
|
|
958
|
+
if (parent.activeObj.shape !== 'redact') {
|
|
959
|
+
this.drawCenterCircles(canvasDraw);
|
|
960
|
+
}
|
|
954
961
|
}
|
|
955
962
|
canvasDraw.strokeStyle = strokeColor;
|
|
956
963
|
canvasDraw.fillStyle = fillColor;
|
|
@@ -1006,7 +1013,7 @@ var Draw = /** @class */ (function () {
|
|
|
1006
1013
|
canvasDraw = saveContext;
|
|
1007
1014
|
}
|
|
1008
1015
|
var shapeType = parent.currObjType.shape.toLowerCase();
|
|
1009
|
-
var shapeColl = ['rectangle', 'ellipse', 'line', 'arrow', 'path', 'image'];
|
|
1016
|
+
var shapeColl = ['rectangle', 'ellipse', 'line', 'arrow', 'path', 'image', 'redact'];
|
|
1010
1017
|
if (shapeColl.indexOf(shapeType) !== -1) {
|
|
1011
1018
|
actObj.shape = parent.currObjType.shape;
|
|
1012
1019
|
}
|
|
@@ -1032,6 +1039,13 @@ var Draw = /** @class */ (function () {
|
|
|
1032
1039
|
this.drawOuterSelection(canvasDraw);
|
|
1033
1040
|
}
|
|
1034
1041
|
break;
|
|
1042
|
+
case 'redact':
|
|
1043
|
+
this.drawRedact(canvasDraw, actObj);
|
|
1044
|
+
if (isNullOrUndefined(isPreventSelection) && canvasDraw === this.upperContext) {
|
|
1045
|
+
this.drawOuterSelection(canvasDraw);
|
|
1046
|
+
}
|
|
1047
|
+
parent.currObjType.isRedact = true;
|
|
1048
|
+
break;
|
|
1035
1049
|
case 'ellipse':
|
|
1036
1050
|
selectionWidth = Math.abs(selectionWidth);
|
|
1037
1051
|
selectionHeight = Math.abs(selectionHeight);
|
|
@@ -1050,9 +1064,6 @@ var Draw = /** @class */ (function () {
|
|
|
1050
1064
|
}
|
|
1051
1065
|
break;
|
|
1052
1066
|
case 'crop-circle':
|
|
1053
|
-
if (canvasDraw === this.lowerContext) {
|
|
1054
|
-
canvasDraw = this.upperContext;
|
|
1055
|
-
}
|
|
1056
1067
|
this.shapeCircle(canvasDraw, selectionWidth, selectionHeight);
|
|
1057
1068
|
break;
|
|
1058
1069
|
case 'line':
|
|
@@ -1096,7 +1107,7 @@ var Draw = /** @class */ (function () {
|
|
|
1096
1107
|
if (activeObj.pointColl.length > 1) {
|
|
1097
1108
|
var obj = { shape: null };
|
|
1098
1109
|
parent.notify('selection', { prop: 'getCurrentDrawingShape', value: { obj: obj } });
|
|
1099
|
-
if (obj['shape'] === 'path') {
|
|
1110
|
+
if (obj['shape'] === 'path' && parent.isShapeDrawing) {
|
|
1100
1111
|
var nextPoint = { x: 0, y: 0 };
|
|
1101
1112
|
for (var i = 0, len = activeObj.pointColl.length; i < len; i++) {
|
|
1102
1113
|
if (isNullOrUndefined(activeObj.pointColl[i + 1])) {
|
|
@@ -1113,6 +1124,10 @@ var Draw = /** @class */ (function () {
|
|
|
1113
1124
|
actPoint.endY = nextPoint.y;
|
|
1114
1125
|
parent.activeObj = this.updateWidthHeight(parent.activeObj);
|
|
1115
1126
|
this.shapeLine(canvasDraw, actPoint.startX, actPoint.startY, actPoint.endX, actPoint.endY);
|
|
1127
|
+
if (Browser.isDevice) {
|
|
1128
|
+
activeObj.activePoint.endX = nextPoint.x;
|
|
1129
|
+
activeObj.activePoint.endY = nextPoint.y;
|
|
1130
|
+
}
|
|
1116
1131
|
}
|
|
1117
1132
|
}
|
|
1118
1133
|
else {
|
|
@@ -1350,7 +1365,7 @@ var Draw = /** @class */ (function () {
|
|
|
1350
1365
|
var parent = this.parent;
|
|
1351
1366
|
var actObj = parent.activeObj;
|
|
1352
1367
|
var _a = actObj.activePoint, startX = _a.startX, startY = _a.startY, width = _a.width, height = _a.height;
|
|
1353
|
-
var _b = actObj.strokeSettings, fillColor = _b.fillColor, strokeColor = _b.strokeColor, strokeWidth = _b.strokeWidth;
|
|
1368
|
+
var _b = actObj.strokeSettings, fillColor = _b.fillColor, strokeColor = _b.strokeColor, strokeWidth = _b.strokeWidth, radius = _b.radius;
|
|
1354
1369
|
if (actObj.shape) {
|
|
1355
1370
|
splitWords = actObj.shape.split('-');
|
|
1356
1371
|
}
|
|
@@ -1361,12 +1376,33 @@ var Draw = /** @class */ (function () {
|
|
|
1361
1376
|
canvasDraw.strokeStyle = strokeColor;
|
|
1362
1377
|
}
|
|
1363
1378
|
canvasDraw.beginPath();
|
|
1364
|
-
|
|
1379
|
+
var obj = { width: 0, height: 0 };
|
|
1380
|
+
var ratio = { width: 1, height: 1 };
|
|
1381
|
+
parent.notify('crop', { prop: 'calcRatio', onPropertyChange: false,
|
|
1382
|
+
value: { obj: obj, dimension: { width: canvasDraw.canvas.width, height: canvasDraw.canvas.height } } });
|
|
1383
|
+
ratio = obj;
|
|
1384
|
+
var isTempCanvas = canvasDraw.canvas.id === parent.element.id + '_tempCanvas';
|
|
1385
|
+
var zoomFactor = parent.transform.zoomFactor;
|
|
1386
|
+
var baseRadius = isTempCanvas ? radius * 10 * ((ratio.width + ratio.height) / 2) : radius * 10;
|
|
1387
|
+
var adjustedRadius = baseRadius + (baseRadius * zoomFactor);
|
|
1388
|
+
if (radius !== null) {
|
|
1389
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1390
|
+
canvasDraw.roundRect(startX, startY, width, height, adjustedRadius);
|
|
1391
|
+
}
|
|
1392
|
+
else {
|
|
1393
|
+
canvasDraw.rect(startX, startY, width, height);
|
|
1394
|
+
}
|
|
1365
1395
|
if (fillColor !== '') {
|
|
1366
1396
|
canvasDraw.fillStyle = fillColor;
|
|
1367
1397
|
canvasDraw.fill();
|
|
1368
1398
|
}
|
|
1369
|
-
|
|
1399
|
+
if (radius !== null) {
|
|
1400
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1401
|
+
canvasDraw.roundRect(startX + strokeWidth, startY + strokeWidth, width - (2 * strokeWidth), height - (2 * strokeWidth), adjustedRadius);
|
|
1402
|
+
}
|
|
1403
|
+
else {
|
|
1404
|
+
canvasDraw.rect(startX + strokeWidth, startY + strokeWidth, width - (2 * strokeWidth), height - (2 * strokeWidth));
|
|
1405
|
+
}
|
|
1370
1406
|
canvasDraw.fillStyle = strokeColor;
|
|
1371
1407
|
canvasDraw.fill('evenodd');
|
|
1372
1408
|
canvasDraw.closePath();
|
|
@@ -1662,6 +1698,9 @@ var Draw = /** @class */ (function () {
|
|
|
1662
1698
|
else if (actObj.start === 'square' && actObj.end === 'square') {
|
|
1663
1699
|
this.shapeLine(canvasDraw, this.squareEndIntersectX1, this.squareEndIntersectY1, this.squareStartIntersectX1, this.squareStartIntersectY1);
|
|
1664
1700
|
}
|
|
1701
|
+
else if (actObj.end === 'squareSolid' && actObj.start === 'none') {
|
|
1702
|
+
this.shapeLine(canvasDraw, startX, startY, endX, endY);
|
|
1703
|
+
}
|
|
1665
1704
|
}
|
|
1666
1705
|
};
|
|
1667
1706
|
Draw.prototype.arrowCircle = function (canvasDraw, start) {
|
|
@@ -1923,6 +1962,13 @@ var Draw = /** @class */ (function () {
|
|
|
1923
1962
|
var lHeight = fontSize + fontSize * 0.25;
|
|
1924
1963
|
var lineHeight = ((lHeight * rows.length) - (fontSize * rows.length)) / rows.length;
|
|
1925
1964
|
canvasDraw.filter = 'none';
|
|
1965
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1966
|
+
var tempFill = canvasDraw.fillStyle;
|
|
1967
|
+
if (actObj.strokeSettings.fillColor !== '') {
|
|
1968
|
+
canvasDraw.fillStyle = actObj.strokeSettings.fillColor;
|
|
1969
|
+
canvasDraw.fillRect(actObj.activePoint.startX, actObj.activePoint.startY, actObj.activePoint.width, actObj.activePoint.height);
|
|
1970
|
+
}
|
|
1971
|
+
canvasDraw.fillStyle = tempFill;
|
|
1926
1972
|
for (var i = 0; i < rows.length; i++) {
|
|
1927
1973
|
var text = rows[i];
|
|
1928
1974
|
var yPoint = ((i + 1) * fontSize * 0.85) + (i * lineHeight);
|
|
@@ -1939,8 +1985,29 @@ var Draw = /** @class */ (function () {
|
|
|
1939
1985
|
fontSize = actObj.textSettings.fontSize = width - (width * 0.1);
|
|
1940
1986
|
}
|
|
1941
1987
|
}
|
|
1942
|
-
canvasDraw.strokeStyle = actObj.strokeSettings.
|
|
1988
|
+
canvasDraw.strokeStyle = actObj.strokeSettings.outlineColor;
|
|
1943
1989
|
canvasDraw.fillStyle = actObj.strokeSettings.strokeColor;
|
|
1990
|
+
var tempWidth = canvasDraw.lineWidth;
|
|
1991
|
+
var obj = { width: 0, height: 0 };
|
|
1992
|
+
var ratio = { width: 1, height: 1 };
|
|
1993
|
+
parent.notify('crop', { prop: 'calcRatio', onPropertyChange: false,
|
|
1994
|
+
value: { obj: obj, dimension: { width: canvasDraw.canvas.width, height: canvasDraw.canvas.height } } });
|
|
1995
|
+
ratio = obj;
|
|
1996
|
+
var isTempCanvas = canvasDraw.canvas.id === parent.element.id + '_tempCanvas';
|
|
1997
|
+
var baseWidth = Math.max(1, actObj.strokeSettings.outlineWidth / 2);
|
|
1998
|
+
if (/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$|^[a-zA-Z]+$/.test(actObj.strokeSettings.outlineColor)) {
|
|
1999
|
+
canvasDraw.lineWidth = baseWidth * ((isTempCanvas ? Math.floor((fontSize - 1) / 60) :
|
|
2000
|
+
Math.floor((fontSize - 1) / 16)) * 0.5 + 0.5);
|
|
2001
|
+
if (isTempCanvas) {
|
|
2002
|
+
canvasDraw.lineWidth *= ((ratio.width + ratio.height) / 2);
|
|
2003
|
+
if (parent.transform.degree !== 0) {
|
|
2004
|
+
canvasDraw.lineWidth /= 1.8;
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
else {
|
|
2009
|
+
canvasDraw.lineWidth = 0;
|
|
2010
|
+
}
|
|
1944
2011
|
var textStyle = '';
|
|
1945
2012
|
if (bold) {
|
|
1946
2013
|
textStyle = 'bold ';
|
|
@@ -1960,11 +2027,16 @@ var Draw = /** @class */ (function () {
|
|
|
1960
2027
|
this.rotateText(canvasDraw);
|
|
1961
2028
|
}
|
|
1962
2029
|
else {
|
|
2030
|
+
canvasDraw.strokeText(text, startX + fontSize * 0.1, startY + yPoint);
|
|
1963
2031
|
canvasDraw.fillText(text, startX + fontSize * 0.1, startY + yPoint);
|
|
1964
2032
|
}
|
|
2033
|
+
canvasDraw.lineWidth = tempWidth;
|
|
1965
2034
|
}
|
|
1966
2035
|
canvasDraw.filter = filter;
|
|
1967
2036
|
parent.currObjType.isText = false;
|
|
2037
|
+
if (this.upperContext === canvasDraw) {
|
|
2038
|
+
this.drawOuterSelection(canvasDraw);
|
|
2039
|
+
}
|
|
1968
2040
|
};
|
|
1969
2041
|
Draw.prototype.updateActPoint = function (degree, canvasDraw) {
|
|
1970
2042
|
var parent = this.parent;
|
|
@@ -2222,6 +2294,8 @@ var Draw = /** @class */ (function () {
|
|
|
2222
2294
|
}
|
|
2223
2295
|
yPoint += fontSize + fontSize * 0.15;
|
|
2224
2296
|
}
|
|
2297
|
+
canvasDraw.strokeText(text, startX + fontSize * 0.15, startY +
|
|
2298
|
+
yPoint + (i > 0 ? fontSize * 0.25 : -fontSize * 0.35));
|
|
2225
2299
|
canvasDraw.fillText(text, startX + fontSize * 0.15, startY +
|
|
2226
2300
|
yPoint + (i > 0 ? fontSize * 0.25 : -fontSize * 0.35));
|
|
2227
2301
|
}
|
|
@@ -2462,13 +2536,23 @@ var Draw = /** @class */ (function () {
|
|
|
2462
2536
|
parent.baseImg.src = src;
|
|
2463
2537
|
parent.baseImg.onload = function () {
|
|
2464
2538
|
parent.imgSrc = src;
|
|
2465
|
-
parent.
|
|
2539
|
+
if (!parent.isUndoRedo) {
|
|
2540
|
+
parent.notify('filter', { prop: 'update-finetunes', onPropertyChange: false });
|
|
2541
|
+
}
|
|
2466
2542
|
proxy.lowerContext.drawImage(parent.baseImg, 0, 0, proxy.parent.lowerCanvas.width, proxy.parent.lowerCanvas.height);
|
|
2543
|
+
var isCropped = false;
|
|
2544
|
+
var isSameDimension = false;
|
|
2545
|
+
if (parent.isImageUpdated) {
|
|
2546
|
+
var _a = parent.img, srcWidth = _a.srcWidth, srcHeight = _a.srcHeight;
|
|
2547
|
+
var _b = parent.baseImgCanvas, width = _b.width, height = _b.height;
|
|
2548
|
+
isCropped = srcWidth !== width || srcHeight !== height;
|
|
2549
|
+
isSameDimension = parent.baseImg.width === width && parent.baseImg.height === height;
|
|
2550
|
+
}
|
|
2467
2551
|
hideSpinner(parent.element);
|
|
2468
2552
|
parent.element.style.opacity = '1';
|
|
2469
2553
|
proxy.updateBaseImgCanvas();
|
|
2470
2554
|
var fileOpened = { fileName: _this.fileName, fileType: _this.fileType, isValidImage: true };
|
|
2471
|
-
proxy.updateCanvas();
|
|
2555
|
+
proxy.updateCanvas(isCropped, isSameDimension);
|
|
2472
2556
|
if (parent.currObjType.isUndoZoom) {
|
|
2473
2557
|
parent.currObjType.isUndoZoom = false;
|
|
2474
2558
|
proxy.parent.lowerCanvas.style.display = 'block';
|
|
@@ -2489,6 +2573,8 @@ var Draw = /** @class */ (function () {
|
|
|
2489
2573
|
}
|
|
2490
2574
|
if (parent.isImageLoaded && parent.element.style.opacity !== '0.5') {
|
|
2491
2575
|
parent.trigger('fileOpened', fileOpened);
|
|
2576
|
+
var action = { action: 'file-open', actionEventArgs: fileOpened };
|
|
2577
|
+
parent.triggerEditCompleteEvent(action);
|
|
2492
2578
|
}
|
|
2493
2579
|
};
|
|
2494
2580
|
parent.baseImg.onerror = function () {
|
|
@@ -2508,10 +2594,26 @@ var Draw = /** @class */ (function () {
|
|
|
2508
2594
|
parent.baseImgCanvas.height = parent.baseImg.height;
|
|
2509
2595
|
parent.baseImgCanvas.getContext('2d').drawImage(parent.baseImg, 0, 0);
|
|
2510
2596
|
};
|
|
2511
|
-
Draw.prototype.updateCanvas = function () {
|
|
2597
|
+
Draw.prototype.updateCanvas = function (isCropped, isSameDimension) {
|
|
2512
2598
|
var parent = this.parent;
|
|
2513
|
-
parent.
|
|
2514
|
-
|
|
2599
|
+
if (!parent.isImageUpdated || !isCropped) {
|
|
2600
|
+
parent.img.srcWidth = parent.baseImgCanvas.width;
|
|
2601
|
+
parent.img.srcHeight = parent.baseImgCanvas.height;
|
|
2602
|
+
}
|
|
2603
|
+
else if (!isSameDimension && isCropped) {
|
|
2604
|
+
parent.img.srcLeft = 0;
|
|
2605
|
+
parent.img.srcTop = 0;
|
|
2606
|
+
parent.img.srcWidth = parent.baseImgCanvas.width;
|
|
2607
|
+
parent.img.srcHeight = parent.baseImgCanvas.height;
|
|
2608
|
+
parent.currSelectionPoint = null;
|
|
2609
|
+
parent.cropObj = { cropZoom: 0, defaultZoom: 0, totalPannedPoint: { x: 0, y: 0 }, totalPannedClientPoint: { x: 0, y: 0 },
|
|
2610
|
+
totalPannedInternalPoint: { x: 0, y: 0 }, tempFlipPanPoint: { x: 0, y: 0 }, activeObj: {}, rotateFlipColl: [],
|
|
2611
|
+
degree: 0, currFlipState: '', straighten: 0, destPoints: { startX: 0, startY: 0, width: 0, height: 0 },
|
|
2612
|
+
srcPoints: { startX: 0, startY: 0, width: 0, height: 0 }, filter: '', isBrightAdjust: false,
|
|
2613
|
+
zoomFactor: 0, previousZoomValue: 0, aspectWidth: null, aspectHeight: null, frame: 'none', straightenZoom: 0,
|
|
2614
|
+
adjustmentLevel: { brightness: 0, contrast: 0, hue: 0, opacity: 100, saturation: 0, blur: 0,
|
|
2615
|
+
exposure: 0, transparency: 100, sharpen: false, bw: false }, currentFilter: '' };
|
|
2616
|
+
}
|
|
2515
2617
|
var obj = { width: 0, height: 0 };
|
|
2516
2618
|
parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
|
|
2517
2619
|
value: { width: parent.img.srcWidth, height: parent.img.srcHeight, obj: obj, isImgShape: null } });
|
|
@@ -2586,12 +2688,15 @@ var Draw = /** @class */ (function () {
|
|
|
2586
2688
|
this.renderImage(null, null, true);
|
|
2587
2689
|
}
|
|
2588
2690
|
this.resetFrameZoom(false);
|
|
2691
|
+
var editCompleteArgs = { action: '' };
|
|
2589
2692
|
if (obj['bool']) {
|
|
2693
|
+
editCompleteArgs['action'] = 'freehand-draw';
|
|
2590
2694
|
parent.notify('freehand-draw', { prop: 'cancelFhd', onPropertyChange: false });
|
|
2591
2695
|
parent.notify('toolbar', { prop: 'destroy-qa-toolbar', onPropertyChange: false });
|
|
2592
2696
|
parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
|
|
2593
2697
|
}
|
|
2594
2698
|
else if (parent.textArea.style.display === 'block' || parent.textArea.style.display === 'inline-block') {
|
|
2699
|
+
editCompleteArgs['action'] = 'text-editing';
|
|
2595
2700
|
parent.textArea.style.display = 'none';
|
|
2596
2701
|
parent.textArea.value = '';
|
|
2597
2702
|
parent.textArea.style.transform = '';
|
|
@@ -2614,8 +2719,9 @@ var Draw = /** @class */ (function () {
|
|
|
2614
2719
|
parent.enableShapeDrawing(parent.toPascalCase(parent.drawingShape), true);
|
|
2615
2720
|
}
|
|
2616
2721
|
}
|
|
2617
|
-
else if (((!Browser.isDevice || (Browser.isDevice && !straightenObj['bool'])) &&
|
|
2618
|
-
document.querySelector('#' + parent.element.id + '_sliderWrapper')) || parent.currObjType.isFiltered) {
|
|
2722
|
+
else if ((!parent.activeObj.shape || parent.activeObj.shape !== 'redact') && (((!Browser.isDevice || (Browser.isDevice && !straightenObj['bool'])) &&
|
|
2723
|
+
document.querySelector('#' + parent.element.id + '_sliderWrapper')) || parent.currObjType.isFiltered)) {
|
|
2724
|
+
editCompleteArgs['action'] = parent.isFinetuneBtnClick ? 'fine-tune' : 'filter';
|
|
2619
2725
|
this.lowerContext.filter = this.tempAdjValue;
|
|
2620
2726
|
parent.canvasFilter = this.tempAdjValue;
|
|
2621
2727
|
parent.notify('filter', { prop: 'setAdjustmentValue', onPropertyChange: false, value: { adjustmentValue: this.tempAdjValue } });
|
|
@@ -2636,7 +2742,7 @@ var Draw = /** @class */ (function () {
|
|
|
2636
2742
|
parent.notify('undo-redo', { prop: 'setUndoRedoStep', onPropertyChange: false, value: { step: this.tempUndoRedoStep } });
|
|
2637
2743
|
parent.upperCanvas.style.cursor = parent.cursor = 'default';
|
|
2638
2744
|
parent.currObjType.isCustomCrop = false;
|
|
2639
|
-
this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null };
|
|
2745
|
+
this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null, radius: null, outlineColor: '', outlineWidth: null };
|
|
2640
2746
|
this.clearOuterCanvas(this.lowerContext);
|
|
2641
2747
|
if ((parent.currSelectionPoint && parent.currSelectionPoint.shape === 'crop-circle') || parent.isCircleCrop) {
|
|
2642
2748
|
parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
|
|
@@ -2651,14 +2757,18 @@ var Draw = /** @class */ (function () {
|
|
|
2651
2757
|
parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'cancel' } });
|
|
2652
2758
|
parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
|
|
2653
2759
|
this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
|
|
2760
|
+
if (parent.drawingShape) {
|
|
2761
|
+
parent.drawingShape = null;
|
|
2762
|
+
parent.notify('selection', { prop: 'setCurrentDrawingShape', onPropertyChange: false, value: { value: '' } });
|
|
2763
|
+
}
|
|
2654
2764
|
}
|
|
2655
2765
|
else {
|
|
2656
|
-
if (isContextualToolbar && (!Browser.isDevice || (Browser.isDevice && !straightenObj['bool']))) {
|
|
2766
|
+
if ((!parent.activeObj.shape || parent.activeObj.shape !== 'redact') && isContextualToolbar && (!Browser.isDevice || (Browser.isDevice && !straightenObj['bool']))) {
|
|
2657
2767
|
var eventargs = { type: 'main', isApplyBtn: null, isCropping: null, isZooming: null };
|
|
2658
2768
|
parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: eventargs });
|
|
2659
2769
|
}
|
|
2660
2770
|
else {
|
|
2661
|
-
this.cancelItems();
|
|
2771
|
+
this.cancelItems(editCompleteArgs);
|
|
2662
2772
|
if (parent.transform.zoomFactor > 0) {
|
|
2663
2773
|
parent.togglePan = true;
|
|
2664
2774
|
parent.notify('selection', { prop: 'setDragCanvas', value: { bool: true } });
|
|
@@ -2679,15 +2789,18 @@ var Draw = /** @class */ (function () {
|
|
|
2679
2789
|
parent.drawingShape = null;
|
|
2680
2790
|
parent.notify('draw', { prop: 'resetTempObjColl' });
|
|
2681
2791
|
parent.notify('draw', { prop: 'resetTempPointColl' });
|
|
2792
|
+
parent.isMaskImage = parent.isFinetuneBtnClick = false;
|
|
2793
|
+
var actionArgs = { action: 'cancel', actionEventArgs: editCompleteArgs };
|
|
2794
|
+
parent.triggerEditCompleteEvent(actionArgs);
|
|
2682
2795
|
};
|
|
2683
|
-
Draw.prototype.cancelItems = function () {
|
|
2796
|
+
Draw.prototype.cancelItems = function (editCompleteArgs) {
|
|
2684
2797
|
var parent = this.parent;
|
|
2685
2798
|
var isCropSelection = false;
|
|
2686
2799
|
var id = parent.element.id;
|
|
2687
2800
|
var ascpectIcon = parent.element.querySelector('#' + id + '_aspectratio');
|
|
2688
2801
|
var nonAspectIcon = parent.element.querySelector('#' + id + '_nonaspectratio');
|
|
2689
2802
|
var splitWords;
|
|
2690
|
-
var shapes = ['rectangle', 'ellipse', 'line', 'arrow', 'path', 'image'];
|
|
2803
|
+
var shapes = ['rectangle', 'ellipse', 'line', 'arrow', 'path', 'image', 'redact'];
|
|
2691
2804
|
if (parent.activeObj.shape !== undefined) {
|
|
2692
2805
|
splitWords = parent.activeObj.shape.split('-');
|
|
2693
2806
|
}
|
|
@@ -2704,6 +2817,7 @@ var Draw = /** @class */ (function () {
|
|
|
2704
2817
|
if (parent.isResize) {
|
|
2705
2818
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
2706
2819
|
if (ascpectIcon || nonAspectIcon || parent.currentToolbar === 'resize-toolbar') {
|
|
2820
|
+
editCompleteArgs['action'] = 'resize';
|
|
2707
2821
|
var obj = { width: null, height: null };
|
|
2708
2822
|
parent.notify('selection', { prop: 'getNumTextValue', onPropertyChange: false, value: { obj: obj } });
|
|
2709
2823
|
var point = { x: obj['width'], y: obj['height'] };
|
|
@@ -2760,15 +2874,20 @@ var Draw = /** @class */ (function () {
|
|
|
2760
2874
|
}
|
|
2761
2875
|
switch (true) {
|
|
2762
2876
|
case parent.togglePen:
|
|
2877
|
+
editCompleteArgs['action'] = 'freehand-draw';
|
|
2763
2878
|
this.cancelPen();
|
|
2764
2879
|
break;
|
|
2765
2880
|
case parent.activeObj.shape === 'text':
|
|
2881
|
+
editCompleteArgs['action'] = 'text';
|
|
2766
2882
|
this.cancelText();
|
|
2767
2883
|
break;
|
|
2768
2884
|
case shapes.indexOf(parent.activeObj.shape) !== -1:
|
|
2885
|
+
editCompleteArgs['action'] = parent.activeObj.shape;
|
|
2769
2886
|
this.cancelShape();
|
|
2887
|
+
parent.currObjType.isRedact = false;
|
|
2770
2888
|
break;
|
|
2771
2889
|
case isCropSelection:
|
|
2890
|
+
editCompleteArgs['action'] = 'crop-selection';
|
|
2772
2891
|
this.cancelSelection();
|
|
2773
2892
|
break;
|
|
2774
2893
|
default:
|
|
@@ -2780,7 +2899,7 @@ var Draw = /** @class */ (function () {
|
|
|
2780
2899
|
parent.notify('selection', { prop: 'setCurrentDrawingShape', onPropertyChange: false, value: { value: '' } });
|
|
2781
2900
|
parent.upperCanvas.style.cursor = parent.cursor = 'default';
|
|
2782
2901
|
parent.currObjType.isCustomCrop = false;
|
|
2783
|
-
this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null };
|
|
2902
|
+
this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null, radius: null, outlineColor: '', outlineWidth: null };
|
|
2784
2903
|
var eventargs = { type: 'main', isApplyBtn: null, isCropping: false, isZooming: null };
|
|
2785
2904
|
parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: eventargs });
|
|
2786
2905
|
};
|
|
@@ -2798,8 +2917,9 @@ var Draw = /** @class */ (function () {
|
|
|
2798
2917
|
parent.freehandCounter = this.tempFreehandCounter;
|
|
2799
2918
|
parent.notify('freehand-draw', { prop: 'setCurrentFreehandDrawIndex', value: { value: this.tempCurrFhdIndex } });
|
|
2800
2919
|
parent.activeObj.strokeSettings = this.tempStrokeSettings;
|
|
2801
|
-
parent.notify('shape', { prop: 'setStrokeSettings',
|
|
2802
|
-
|
|
2920
|
+
parent.notify('shape', { prop: 'setStrokeSettings', value: { strokeSettings: parent.activeObj.strokeSettings, strokeColor: null,
|
|
2921
|
+
fillColor: null, strokeWidth: null, radius: null } });
|
|
2922
|
+
parent.notify('freehand-draw', { prop: 'setPenStrokeWidth', onPropertyChange: false, value: { value: this.tempStrokeWidth } });
|
|
2803
2923
|
parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'cancel' } });
|
|
2804
2924
|
parent.notify('selection', { prop: 'setFreehandDrawCustomized', value: { isFreehandDrawCustomized: false } });
|
|
2805
2925
|
parent.objColl = extend([], this.tempObjColl, [], true);
|
|
@@ -2814,7 +2934,7 @@ var Draw = /** @class */ (function () {
|
|
|
2814
2934
|
parent.notify('shape', { prop: 'setTextSettings', onPropertyChange: false,
|
|
2815
2935
|
value: { textSettings: this.tempTextSettings, fontFamily: null, fontSize: null } });
|
|
2816
2936
|
parent.notify('shape', { prop: 'setStrokeSettings',
|
|
2817
|
-
value: { strokeSettings: this.tempStrokeSettings, strokeColor: null, fillColor: null, strokeWidth: null } });
|
|
2937
|
+
value: { strokeSettings: this.tempStrokeSettings, strokeColor: null, fillColor: null, strokeWidth: null, radius: null } });
|
|
2818
2938
|
if (isNullOrUndefined(parent.activeObj.currIndex)) {
|
|
2819
2939
|
parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
|
|
2820
2940
|
this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
|
|
@@ -2846,7 +2966,7 @@ var Draw = /** @class */ (function () {
|
|
|
2846
2966
|
Draw.prototype.cancelShape = function () {
|
|
2847
2967
|
var parent = this.parent;
|
|
2848
2968
|
parent.notify('shape', { prop: 'setStrokeSettings',
|
|
2849
|
-
value: { strokeSettings: this.tempStrokeSettings, strokeColor: null, fillColor: null, strokeWidth: null } });
|
|
2969
|
+
value: { strokeSettings: this.tempStrokeSettings, strokeColor: null, fillColor: null, strokeWidth: null, radius: null } });
|
|
2850
2970
|
if (isNullOrUndefined(parent.activeObj.currIndex)) {
|
|
2851
2971
|
parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
|
|
2852
2972
|
this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
|
|
@@ -3097,6 +3217,7 @@ var Draw = /** @class */ (function () {
|
|
|
3097
3217
|
var selectionChangingArgs = { action: 'insert', previousSelectionSettings: selectionSettings,
|
|
3098
3218
|
currentSelectionSettings: selectionSettings };
|
|
3099
3219
|
parent.trigger('selectionChanging', selectionChangingArgs);
|
|
3220
|
+
parent.editCompleteArgs = selectionChangingArgs;
|
|
3100
3221
|
parent.notify('shape', { prop: 'updSelChangeEventArgs', onPropertyChange: false,
|
|
3101
3222
|
value: { selectionSettings: selectionChangingArgs.currentSelectionSettings } });
|
|
3102
3223
|
if (selectionChangingArgs.currentSelectionSettings.type === 'Custom') {
|
|
@@ -3299,8 +3420,11 @@ var Draw = /** @class */ (function () {
|
|
|
3299
3420
|
var tempTogglePen = parent.togglePen;
|
|
3300
3421
|
parent.togglePen = false;
|
|
3301
3422
|
this.lowerContext.filter = 'none';
|
|
3423
|
+
var widthObj = { penStrokeWidth: null };
|
|
3424
|
+
parent.notify('freehand-draw', { prop: 'getPenStrokeWidth', onPropertyChange: false, value: { obj: widthObj } });
|
|
3302
3425
|
parent.notify('shape', { prop: 'drawAnnotations', onPropertyChange: false,
|
|
3303
3426
|
value: { ctx: this.lowerContext, shape: 'iterate', pen: 'iterate', isPreventApply: null } });
|
|
3427
|
+
parent.notify('freehand-draw', { prop: 'setPenStrokeWidth', onPropertyChange: false, value: { value: widthObj['penStrokeWidth'] } });
|
|
3304
3428
|
parent.img.destLeft += parent.panPoint.totalPannedInternalPoint.x;
|
|
3305
3429
|
parent.img.destTop += parent.panPoint.totalPannedInternalPoint.y;
|
|
3306
3430
|
parent.img.destLeft -= parent.panPoint.totalPannedInternalPoint.x;
|
|
@@ -3353,7 +3477,7 @@ var Draw = /** @class */ (function () {
|
|
|
3353
3477
|
value: { context: this.lowerContext, isSave: null, isFlip: null } });
|
|
3354
3478
|
}
|
|
3355
3479
|
};
|
|
3356
|
-
Draw.prototype.setCurrentObj = function (obj, isUndoRedo) {
|
|
3480
|
+
Draw.prototype.setCurrentObj = function (obj, isUndoRedo, isCircleCropped) {
|
|
3357
3481
|
var parent = this.parent;
|
|
3358
3482
|
var isObj = obj ? true : false;
|
|
3359
3483
|
if (!isObj) {
|
|
@@ -3405,6 +3529,7 @@ var Draw = /** @class */ (function () {
|
|
|
3405
3529
|
}
|
|
3406
3530
|
this.lowerContext.filter = obj.filter;
|
|
3407
3531
|
parent.notify('filter', { prop: 'setBrightnessAdjusted', onPropertyChange: false, value: { isBrightnessAdjusted: obj.isBrightAdjust } });
|
|
3532
|
+
parent.notify('draw', { prop: 'imageBackgroundColor', onPropertyChange: false, value: { color: obj.bgColor } });
|
|
3408
3533
|
var isCircleCrop = parent.isCircleCrop;
|
|
3409
3534
|
var currSelectionPoint;
|
|
3410
3535
|
if (isNullOrUndefined(parent.currSelectionPoint)) {
|
|
@@ -3415,6 +3540,9 @@ var Draw = /** @class */ (function () {
|
|
|
3415
3540
|
parent.currSelectionPoint = null;
|
|
3416
3541
|
}
|
|
3417
3542
|
parent.isCircleCrop = false;
|
|
3543
|
+
if (isCircleCropped) {
|
|
3544
|
+
parent.frameObj.type = 'none';
|
|
3545
|
+
}
|
|
3418
3546
|
this.drawCropSelectionImage(obj, false);
|
|
3419
3547
|
if (parent.transform.degree !== 0) {
|
|
3420
3548
|
if (parent.transform.currFlipState === '') {
|
|
@@ -3535,6 +3663,16 @@ var Draw = /** @class */ (function () {
|
|
|
3535
3663
|
Draw.prototype.performPointZoom = function (x, y, type, isResize, value) {
|
|
3536
3664
|
var parent = this.parent;
|
|
3537
3665
|
var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
|
|
3666
|
+
var isCropSelection = false;
|
|
3667
|
+
if (parent.activeObj.shape && parent.activeObj.shape.indexOf('crop-') > -1) {
|
|
3668
|
+
isCropSelection = true;
|
|
3669
|
+
}
|
|
3670
|
+
if (parent.element.querySelector('.e-contextual-toolbar-wrapper') && !isCropSelection) {
|
|
3671
|
+
if (!parent.element.querySelector('.e-contextual-toolbar-wrapper').classList.contains('e-hide')) {
|
|
3672
|
+
parent.okBtn();
|
|
3673
|
+
parent.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
|
|
3674
|
+
}
|
|
3675
|
+
}
|
|
3538
3676
|
var ratioX = (x - destLeft) / destWidth;
|
|
3539
3677
|
var ratioY = (y - destTop) / destHeight;
|
|
3540
3678
|
var isUndoRedo = parent.isUndoRedo;
|
|
@@ -3669,6 +3807,7 @@ var Draw = /** @class */ (function () {
|
|
|
3669
3807
|
var parent = this.parent;
|
|
3670
3808
|
var activeObj = extend({}, parent.activeObj, {}, true);
|
|
3671
3809
|
var _a = activeObj.activePoint, startX = _a.startX, startY = _a.startY, width = _a.width, height = _a.height;
|
|
3810
|
+
this.allowRedactStraighten = true;
|
|
3672
3811
|
var straightenObj = { straightenPoint: null };
|
|
3673
3812
|
parent.notify('freehand-draw', { prop: 'getStraightenPoint', onPropertyChange: false,
|
|
3674
3813
|
value: { obj: straightenObj } });
|
|
@@ -3815,6 +3954,8 @@ var Draw = /** @class */ (function () {
|
|
|
3815
3954
|
return [3 /*break*/, 3];
|
|
3816
3955
|
case 2:
|
|
3817
3956
|
ex_1 = _a.sent();
|
|
3957
|
+
// eslint-disable-next-line no-console
|
|
3958
|
+
console.log(ex_1.message);
|
|
3818
3959
|
return [3 /*break*/, 3];
|
|
3819
3960
|
case 3: return [2 /*return*/];
|
|
3820
3961
|
}
|
|
@@ -4132,6 +4273,10 @@ var Draw = /** @class */ (function () {
|
|
|
4132
4273
|
tempCanvas.getContext('2d').drawImage(img, 0, 0, tempCanvas.width, tempCanvas.height);
|
|
4133
4274
|
}
|
|
4134
4275
|
else {
|
|
4276
|
+
if (this.imageBackgroundColor !== '') {
|
|
4277
|
+
ctx.fillStyle = this.imageBackgroundColor;
|
|
4278
|
+
ctx.fillRect(parent.img.destLeft, parent.img.destTop, parent.img.destWidth, parent.img.destHeight);
|
|
4279
|
+
}
|
|
4135
4280
|
tempCanvas.getContext('2d').drawImage(canvas, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, 0, 0, tempCanvas.width, tempCanvas.height);
|
|
4136
4281
|
}
|
|
4137
4282
|
if (isImgAnnotation || this.isDownScale) {
|
|
@@ -4192,9 +4337,16 @@ var Draw = /** @class */ (function () {
|
|
|
4192
4337
|
else {
|
|
4193
4338
|
if ((isNullOrUndefined(isImgAnnotation) || !isImgAnnotation) && parent.baseImgCanvas.width !== 0 &&
|
|
4194
4339
|
parent.baseImgCanvas.height !== 0) {
|
|
4340
|
+
if (this.imageBackgroundColor !== '') {
|
|
4341
|
+
ctx.fillStyle = this.imageBackgroundColor;
|
|
4342
|
+
ctx.fillRect(parent.img.destLeft, parent.img.destTop, parent.img.destWidth, parent.img.destHeight);
|
|
4343
|
+
}
|
|
4195
4344
|
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);
|
|
4196
4345
|
}
|
|
4197
4346
|
}
|
|
4347
|
+
if (parent.isSafari) {
|
|
4348
|
+
parent.notify('filter', { prop: 'apply-filter', onPropertyChange: false, value: { context: ctx } });
|
|
4349
|
+
}
|
|
4198
4350
|
};
|
|
4199
4351
|
Draw.prototype.downScale = function (canvas, width, height, isImgAnnotation) {
|
|
4200
4352
|
var parent = this.parent;
|
|
@@ -4535,6 +4687,7 @@ var Draw = /** @class */ (function () {
|
|
|
4535
4687
|
var frameChange = { cancel: false, previousFrameSetting: prevFrameSettings,
|
|
4536
4688
|
currentFrameSetting: currFrameSettings };
|
|
4537
4689
|
parent.trigger('frameChange', frameChange);
|
|
4690
|
+
parent.editCompleteArgs = frameChange;
|
|
4538
4691
|
if (!frameChange.cancel) {
|
|
4539
4692
|
this.setFrameObj(frameChange.currentFrameSetting);
|
|
4540
4693
|
}
|
|
@@ -4556,6 +4709,7 @@ var Draw = /** @class */ (function () {
|
|
|
4556
4709
|
var parent = this.parent;
|
|
4557
4710
|
if (this.straightenActObj && JSON.stringify(this.straightenActObj.activePoint) === JSON.stringify(activeObj.activePoint)) {
|
|
4558
4711
|
parent.activeObj = extend({}, this.straightenActObj, null, true);
|
|
4712
|
+
this.allowRedactStraighten = false;
|
|
4559
4713
|
if (parent.transform.straighten === 0) {
|
|
4560
4714
|
var destWidth = parent.img.destWidth;
|
|
4561
4715
|
var destHeight = parent.img.destHeight;
|
|
@@ -4727,12 +4881,18 @@ var Draw = /** @class */ (function () {
|
|
|
4727
4881
|
p3 = { x: destLeft + destWidth - (points[0].x / width), y: destTop + destHeight };
|
|
4728
4882
|
p4 = { x: destLeft, y: destTop + destHeight - (points[1].y / height) };
|
|
4729
4883
|
}
|
|
4730
|
-
else {
|
|
4884
|
+
else if (parent.transform.straighten < 0) {
|
|
4731
4885
|
p1 = { x: destLeft, y: destTop + (points[0].y / height) };
|
|
4732
4886
|
p2 = { x: destLeft + (points[1].x / width), y: destTop };
|
|
4733
4887
|
p3 = { x: destLeft + destWidth, y: destTop + destHeight - (points[0].y / height) };
|
|
4734
4888
|
p4 = { x: destLeft + destWidth - (points[1].x / width), y: destTop + destHeight };
|
|
4735
4889
|
}
|
|
4890
|
+
else if (parent.transform.straighten === 0) {
|
|
4891
|
+
p1 = { x: destLeft, y: destTop };
|
|
4892
|
+
p2 = { x: destLeft + destWidth, y: destTop };
|
|
4893
|
+
p3 = { x: destLeft + destWidth, y: destTop + destHeight };
|
|
4894
|
+
p4 = { x: destLeft, y: destTop + destHeight };
|
|
4895
|
+
}
|
|
4736
4896
|
p1.ratioX = (p1.x - destLeft) / destWidth;
|
|
4737
4897
|
p1.ratioY = (p1.y - destTop) / destHeight;
|
|
4738
4898
|
p2.ratioX = (p2.x - destLeft) / destWidth;
|
|
@@ -4746,6 +4906,30 @@ var Draw = /** @class */ (function () {
|
|
|
4746
4906
|
Draw.prototype.isLinesIntersect = function (obj) {
|
|
4747
4907
|
var parent = this.parent;
|
|
4748
4908
|
var point = parent.activeObj.activePoint;
|
|
4909
|
+
if (parent.activeObj.rotatedAngle !== 0) {
|
|
4910
|
+
var _a = parent.activeObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY, width = _a.width, height = _a.height;
|
|
4911
|
+
var center = { x: startX + (width / 2), y: startY +
|
|
4912
|
+
(height / 2) };
|
|
4913
|
+
var cosAngle = Math.cos(parent.activeObj.rotatedAngle);
|
|
4914
|
+
var sinAngle = Math.sin(parent.activeObj.rotatedAngle);
|
|
4915
|
+
var p1 = { x: cosAngle * (startX - center.x) - sinAngle * (startY - center.y) + center.x,
|
|
4916
|
+
y: sinAngle * (startX - center.x) + cosAngle * (startY - center.y) + center.y };
|
|
4917
|
+
var p2 = { x: cosAngle * (endX - center.x) - sinAngle * (startY - center.y) + center.x,
|
|
4918
|
+
y: sinAngle * (endX - center.x) + cosAngle * (startY - center.y) + center.y };
|
|
4919
|
+
var p3 = { x: cosAngle * (startX - center.x) - sinAngle * (endY - center.y) + center.x,
|
|
4920
|
+
y: sinAngle * (startX - center.x) + cosAngle * (endY - center.y) + center.y };
|
|
4921
|
+
var p4 = { x: cosAngle * (endX - center.x) - sinAngle * (endY - center.y) + center.x,
|
|
4922
|
+
y: sinAngle * (endX - center.x) + cosAngle * (endY - center.y) + center.y };
|
|
4923
|
+
var imgPoints_1 = this.imgCanvasPoints;
|
|
4924
|
+
var isTopIntersect_1 = this.doIntersect(p1, p2, imgPoints_1[0], imgPoints_1[1]);
|
|
4925
|
+
var isRightIntersect_1 = this.doIntersect(p2, p4, imgPoints_1[1], imgPoints_1[2]);
|
|
4926
|
+
var isBottomIntersect_1 = this.doIntersect(p3, p4, imgPoints_1[2], imgPoints_1[3]);
|
|
4927
|
+
var isLeftIntersect_1 = this.doIntersect(p1, p3, imgPoints_1[3], imgPoints_1[0]);
|
|
4928
|
+
if (obj) {
|
|
4929
|
+
obj['arr'] = [isTopIntersect_1, isRightIntersect_1, isBottomIntersect_1, isLeftIntersect_1];
|
|
4930
|
+
}
|
|
4931
|
+
return isTopIntersect_1 || isRightIntersect_1 || isBottomIntersect_1 || isLeftIntersect_1;
|
|
4932
|
+
}
|
|
4749
4933
|
var imgPoints = this.imgCanvasPoints;
|
|
4750
4934
|
var isTopIntersect = this.doIntersect({ x: point.startX, y: point.startY }, { x: point.endX, y: point.startY }, imgPoints[0], imgPoints[1]);
|
|
4751
4935
|
var isRightIntersect = this.doIntersect({ x: point.endX, y: point.startY }, { x: point.endX, y: point.endY }, imgPoints[1], imgPoints[2]);
|
|
@@ -4890,6 +5074,176 @@ var Draw = /** @class */ (function () {
|
|
|
4890
5074
|
parent.img.destHeight = destHeight;
|
|
4891
5075
|
}
|
|
4892
5076
|
};
|
|
5077
|
+
Draw.prototype.drawRedact = function (canvasDraw, obj) {
|
|
5078
|
+
var _a = obj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
|
|
5079
|
+
var _b = obj.activePoint, width = _b.width, height = _b.height;
|
|
5080
|
+
var isSaveCtx = false;
|
|
5081
|
+
var canvas = canvasDraw.canvas;
|
|
5082
|
+
if (canvas.id.indexOf('_tempCanvas') !== -1) {
|
|
5083
|
+
isSaveCtx = true;
|
|
5084
|
+
}
|
|
5085
|
+
var img = this.parent.img;
|
|
5086
|
+
if (width <= 0 || height <= 0) {
|
|
5087
|
+
return;
|
|
5088
|
+
}
|
|
5089
|
+
else if (this.parent.isCropTab) {
|
|
5090
|
+
canvasDraw.drawImage(obj.redactImage, 0, 0, obj.redactImage.width, obj.redactImage.height, startX, startY, width, height);
|
|
5091
|
+
}
|
|
5092
|
+
else {
|
|
5093
|
+
var offscreenCanvas = document.createElement('canvas');
|
|
5094
|
+
var offscreenCtx = offscreenCanvas.getContext('2d');
|
|
5095
|
+
var imageWidth = canvas.width;
|
|
5096
|
+
var imageHeight = canvas.height;
|
|
5097
|
+
var tempRatio = Math.min(imageWidth, imageHeight) / 1000;
|
|
5098
|
+
var straighten = this.parent.transform.straighten !== 0 ? this.parent.transform.straighten :
|
|
5099
|
+
this.parent.cropObj.straighten;
|
|
5100
|
+
if (this.allowRedactStraighten && straighten !== 0) {
|
|
5101
|
+
var tempCanvas = document.createElement('canvas');
|
|
5102
|
+
var tempCtx = tempCanvas.getContext('2d');
|
|
5103
|
+
if (isSaveCtx) {
|
|
5104
|
+
tempCanvas.width = canvas.width;
|
|
5105
|
+
tempCanvas.height = canvas.height;
|
|
5106
|
+
tempCtx.drawImage(canvas, 0, 0);
|
|
5107
|
+
}
|
|
5108
|
+
else {
|
|
5109
|
+
tempCanvas.width = img.destWidth;
|
|
5110
|
+
tempCanvas.height = img.destHeight;
|
|
5111
|
+
tempCtx.drawImage(this.lowerContext.canvas, img.destLeft, img.destTop, img.destWidth, img.destHeight, 0, 0, img.destWidth, img.destHeight);
|
|
5112
|
+
}
|
|
5113
|
+
var radians = -straighten * Math.PI / 180;
|
|
5114
|
+
var straightenCanvas = document.createElement('canvas');
|
|
5115
|
+
var straightenCtx = straightenCanvas.getContext('2d');
|
|
5116
|
+
straightenCanvas.width = tempCanvas.width;
|
|
5117
|
+
straightenCanvas.height = tempCanvas.height;
|
|
5118
|
+
if (img.destWidth > canvas.width && !isSaveCtx) {
|
|
5119
|
+
straightenCanvas.width = canvas.width;
|
|
5120
|
+
}
|
|
5121
|
+
if (img.destHeight > canvas.height && !isSaveCtx) {
|
|
5122
|
+
straightenCanvas.height = canvas.height;
|
|
5123
|
+
}
|
|
5124
|
+
straightenCtx.save();
|
|
5125
|
+
straightenCtx.translate(tempCanvas.width / 2, tempCanvas.height / 2);
|
|
5126
|
+
straightenCtx.rotate(radians);
|
|
5127
|
+
straightenCtx.drawImage(tempCanvas, -tempCanvas.width / 2, -tempCanvas.height / 2);
|
|
5128
|
+
straightenCtx.restore();
|
|
5129
|
+
if (img.destLeft > 0 && !isSaveCtx) {
|
|
5130
|
+
startX -= img.destLeft;
|
|
5131
|
+
endX -= img.destLeft;
|
|
5132
|
+
}
|
|
5133
|
+
if (img.destTop > 0 && !isSaveCtx) {
|
|
5134
|
+
startY -= img.destTop;
|
|
5135
|
+
endY -= img.destTop;
|
|
5136
|
+
}
|
|
5137
|
+
var center = { x: startX + (width / 2), y: startY + (height / 2) };
|
|
5138
|
+
var cosAngle = Math.cos(straighten * Math.PI / 180);
|
|
5139
|
+
var sinAngle = Math.sin(straighten * Math.PI / 180);
|
|
5140
|
+
var p1 = { x: cosAngle * (startX - center.x) - sinAngle * (startY - center.y) + center.x,
|
|
5141
|
+
y: sinAngle * (startX - center.x) + cosAngle * (startY - center.y) + center.y };
|
|
5142
|
+
var p2 = { x: cosAngle * (endX - center.x) - sinAngle * (startY - center.y) + center.x,
|
|
5143
|
+
y: sinAngle * (endX - center.x) + cosAngle * (startY - center.y) + center.y };
|
|
5144
|
+
var p3 = { x: cosAngle * (startX - center.x) - sinAngle * (endY - center.y) + center.x,
|
|
5145
|
+
y: sinAngle * (startX - center.x) + cosAngle * (endY - center.y) + center.y };
|
|
5146
|
+
if (!isSaveCtx) {
|
|
5147
|
+
center = { x: img.destWidth / 2, y: img.destHeight / 2 };
|
|
5148
|
+
if (img.destWidth > canvas.width) {
|
|
5149
|
+
center.x = canvas.width / 2;
|
|
5150
|
+
}
|
|
5151
|
+
if (img.destHeight > canvas.height) {
|
|
5152
|
+
center.y = canvas.height / 2;
|
|
5153
|
+
}
|
|
5154
|
+
}
|
|
5155
|
+
else {
|
|
5156
|
+
center = { x: canvas.width / 2, y: canvas.height / 2 };
|
|
5157
|
+
}
|
|
5158
|
+
cosAngle = Math.cos(radians);
|
|
5159
|
+
sinAngle = Math.sin(radians);
|
|
5160
|
+
var newP1 = { x: cosAngle * (p1.x - center.x) - sinAngle * (p1.y - center.y) + center.x,
|
|
5161
|
+
y: sinAngle * (p1.x - center.x) + cosAngle * (p1.y - center.y) + center.y };
|
|
5162
|
+
var newP2 = { x: cosAngle * (p2.x - center.x) - sinAngle * (p2.y - center.y) + center.x,
|
|
5163
|
+
y: sinAngle * (p2.x - center.x) + cosAngle * (p2.y - center.y) + center.y };
|
|
5164
|
+
var newP3 = { x: cosAngle * (p3.x - center.x) - sinAngle * (p3.y - center.y) + center.x,
|
|
5165
|
+
y: sinAngle * (p3.x - center.x) + cosAngle * (p3.y - center.y) + center.y };
|
|
5166
|
+
if (this.parent.activeObj.redactType === 'blur') {
|
|
5167
|
+
offscreenCanvas.width = width;
|
|
5168
|
+
offscreenCanvas.height = height;
|
|
5169
|
+
offscreenCtx.drawImage(straightenCanvas, newP1.x, newP1.y, newP2.x - newP1.x, newP3.y - newP2.y, 0, 0, width, height);
|
|
5170
|
+
}
|
|
5171
|
+
else {
|
|
5172
|
+
var pixelSize = (obj.redactPixelate / 100) * 20;
|
|
5173
|
+
if (isSaveCtx) {
|
|
5174
|
+
pixelSize = tempRatio * (obj.redactPixelate / 100) * 35;
|
|
5175
|
+
}
|
|
5176
|
+
offscreenCanvas.width = Math.ceil(width / pixelSize);
|
|
5177
|
+
offscreenCanvas.height = Math.ceil(height / pixelSize);
|
|
5178
|
+
offscreenCtx.drawImage(straightenCanvas, newP1.x, newP1.y, newP2.x - newP1.x, newP3.y - newP2.y, 0, 0, offscreenCanvas.width, offscreenCanvas.height);
|
|
5179
|
+
}
|
|
5180
|
+
}
|
|
5181
|
+
if (this.parent.activeObj.redactType === 'blur') {
|
|
5182
|
+
if (straighten === 0) {
|
|
5183
|
+
offscreenCanvas.width = width;
|
|
5184
|
+
offscreenCanvas.height = height;
|
|
5185
|
+
offscreenCtx.drawImage((isSaveCtx) ? canvas : this.lowerContext.canvas, startX, startY, width, height, 0, 0, width, height);
|
|
5186
|
+
}
|
|
5187
|
+
if (isSaveCtx) {
|
|
5188
|
+
var blur_1 = tempRatio * ((obj.redactBlur / 100) * 34);
|
|
5189
|
+
offscreenCtx.filter = "blur(" + blur_1 + "px)";
|
|
5190
|
+
}
|
|
5191
|
+
else {
|
|
5192
|
+
offscreenCtx.filter = "blur(" + (obj.redactBlur / 100) * 17 + "px)";
|
|
5193
|
+
}
|
|
5194
|
+
offscreenCtx.drawImage(offscreenCanvas, 0, 0);
|
|
5195
|
+
if (straighten === 0) {
|
|
5196
|
+
offscreenCtx.drawImage((isSaveCtx) ? canvas : this.lowerContext.canvas, startX, startY, width, height, 0, 0, width, height);
|
|
5197
|
+
}
|
|
5198
|
+
else {
|
|
5199
|
+
if (img.destLeft > 0 && !isSaveCtx) {
|
|
5200
|
+
startX += img.destLeft;
|
|
5201
|
+
endX += img.destLeft;
|
|
5202
|
+
}
|
|
5203
|
+
if (img.destTop > 0 && !isSaveCtx) {
|
|
5204
|
+
startY += img.destTop;
|
|
5205
|
+
endY += img.destTop;
|
|
5206
|
+
}
|
|
5207
|
+
}
|
|
5208
|
+
if (this.parent.isSafari) {
|
|
5209
|
+
this.parent.notify('filter', { prop: 'apply-filter', onPropertyChange: false, value: { context: offscreenCtx } });
|
|
5210
|
+
}
|
|
5211
|
+
canvasDraw.drawImage(offscreenCanvas, 0, 0, width, height, startX, startY, width, height);
|
|
5212
|
+
}
|
|
5213
|
+
else {
|
|
5214
|
+
var pixelSize = (obj.redactPixelate / 100) * 20;
|
|
5215
|
+
if (isSaveCtx) {
|
|
5216
|
+
pixelSize = tempRatio * (obj.redactPixelate / 100) * 35;
|
|
5217
|
+
}
|
|
5218
|
+
if (straighten === 0) {
|
|
5219
|
+
offscreenCanvas.width = Math.ceil(width / pixelSize);
|
|
5220
|
+
offscreenCanvas.height = Math.ceil(height / pixelSize);
|
|
5221
|
+
offscreenCtx.drawImage((isSaveCtx) ? canvas : this.lowerContext.canvas, startX, startY, width, height, 0, 0, offscreenCanvas.width, offscreenCanvas.height);
|
|
5222
|
+
}
|
|
5223
|
+
else {
|
|
5224
|
+
if (img.destLeft > 0 && !isSaveCtx) {
|
|
5225
|
+
startX += img.destLeft;
|
|
5226
|
+
endX += img.destLeft;
|
|
5227
|
+
}
|
|
5228
|
+
if (img.destTop > 0 && !isSaveCtx) {
|
|
5229
|
+
startY += img.destTop;
|
|
5230
|
+
endY += img.destTop;
|
|
5231
|
+
}
|
|
5232
|
+
}
|
|
5233
|
+
canvasDraw.imageSmoothingEnabled = false;
|
|
5234
|
+
canvasDraw.drawImage(offscreenCanvas, 0, 0, offscreenCanvas.width, offscreenCanvas.height, startX, startY, width, height);
|
|
5235
|
+
}
|
|
5236
|
+
obj.redactImage = this.parent.createElement('canvas');
|
|
5237
|
+
obj.redactImage.width = offscreenCanvas.width;
|
|
5238
|
+
obj.redactImage.height = offscreenCanvas.height;
|
|
5239
|
+
obj.redactImage.getContext('2d').drawImage(offscreenCanvas, 0, 0);
|
|
5240
|
+
canvasDraw.beginPath();
|
|
5241
|
+
canvasDraw.rect(startX, startY, width, height);
|
|
5242
|
+
canvasDraw.rect(startX, startY, width, height);
|
|
5243
|
+
canvasDraw.fill('evenodd');
|
|
5244
|
+
canvasDraw.closePath();
|
|
5245
|
+
}
|
|
5246
|
+
};
|
|
4893
5247
|
return Draw;
|
|
4894
5248
|
}());
|
|
4895
5249
|
export { Draw };
|