@syncfusion/ej2-image-editor 22.1.38 → 22.2.5
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 +16 -0
- 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 +223 -119
- package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
- package/dist/es6/ej2-image-editor.es5.js +223 -119
- 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 +11 -11
- package/src/image-editor/action/crop.d.ts +2 -0
- package/src/image-editor/action/crop.js +44 -27
- package/src/image-editor/action/draw.d.ts +1 -2
- package/src/image-editor/action/draw.js +60 -23
- package/src/image-editor/action/export.js +9 -2
- package/src/image-editor/action/filter.js +1 -8
- package/src/image-editor/action/freehand-draw.d.ts +1 -0
- package/src/image-editor/action/freehand-draw.js +39 -15
- package/src/image-editor/action/selection.js +28 -17
- package/src/image-editor/action/shape.js +34 -25
- package/src/image-editor/action/transform.js +2 -0
- package/src/image-editor/base/image-editor-model.d.ts +4 -4
- package/src/image-editor/base/image-editor.js +3 -2
- package/src/image-editor/base/interface.d.ts +4 -1
- package/src/image-editor/renderer/toolbar.js +3 -1
|
@@ -10,6 +10,7 @@ class Crop {
|
|
|
10
10
|
this.cropDestPoints = { startX: 0, startY: 0, width: 0, height: 0 }; // To redraw old image when navigate to crop tab
|
|
11
11
|
this.tempFlipPanPoint = { x: 0, y: 0 };
|
|
12
12
|
this.isPreventScaling = false;
|
|
13
|
+
this.isInitCrop = false;
|
|
13
14
|
this.parent = parent;
|
|
14
15
|
this.addEventListener();
|
|
15
16
|
}
|
|
@@ -24,7 +25,7 @@ class Crop {
|
|
|
24
25
|
this.parent.on('destroyed', this.destroy, this);
|
|
25
26
|
}
|
|
26
27
|
removeEventListener() {
|
|
27
|
-
this.parent.off('crop', this.
|
|
28
|
+
this.parent.off('crop', this.cropping);
|
|
28
29
|
this.parent.off('destroyed', this.destroy);
|
|
29
30
|
}
|
|
30
31
|
cropping(args) {
|
|
@@ -98,6 +99,7 @@ class Crop {
|
|
|
98
99
|
this.cropDestPoints = { startX: 0, startY: 0, width: 0, height: 0 };
|
|
99
100
|
this.tempFlipPanPoint = { x: 0, y: 0 };
|
|
100
101
|
this.isPreventScaling = false;
|
|
102
|
+
this.isInitCrop = false;
|
|
101
103
|
}
|
|
102
104
|
cropImg(isRotateCrop) {
|
|
103
105
|
const parent = this.parent;
|
|
@@ -151,7 +153,7 @@ class Crop {
|
|
|
151
153
|
parent.img.destWidth = maxDimension.width;
|
|
152
154
|
parent.img.destHeight = maxDimension.height;
|
|
153
155
|
const temp = this.lowerContext.filter;
|
|
154
|
-
parent.notify('
|
|
156
|
+
parent.notify('filter', { prop: 'updateBrightFilter', onPropertyChange: false });
|
|
155
157
|
this.lowerContext.drawImage(parent.baseImg, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, parent.img.destLeft, parent.img.destTop, parent.img.destWidth, parent.img.destHeight);
|
|
156
158
|
this.lowerContext.filter = 'none';
|
|
157
159
|
const activeObj = extend({}, parent.activeObj, {}, true);
|
|
@@ -203,6 +205,8 @@ class Crop {
|
|
|
203
205
|
parent.notify('transform', { prop: 'setPreventSelect', onPropertyChange: false, value: { bool: true } });
|
|
204
206
|
const coll = extend([], parent.rotateFlipColl, [], true);
|
|
205
207
|
this.panToSelRangle(true);
|
|
208
|
+
this.resetZoom();
|
|
209
|
+
const afterCropActions = extend([], parent.afterCropActions, [], true);
|
|
206
210
|
this.revertTransform('initial', coll);
|
|
207
211
|
activeObj = extend({}, parent.objColl[parent.objColl.length - 1], {}, true);
|
|
208
212
|
this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
|
|
@@ -211,6 +215,7 @@ class Crop {
|
|
|
211
215
|
parent.transform.degree = 0;
|
|
212
216
|
this.cropImg(true);
|
|
213
217
|
this.revertTransform('reverse', coll);
|
|
218
|
+
parent.afterCropActions = afterCropActions;
|
|
214
219
|
parent.currSelectionPoint = tempCurrSelObj;
|
|
215
220
|
parent.notify('transform', { prop: 'setPreventSelect', onPropertyChange: false, value: { bool: preventSelObj['bool'] } });
|
|
216
221
|
parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
|
|
@@ -261,18 +266,8 @@ class Crop {
|
|
|
261
266
|
}
|
|
262
267
|
}
|
|
263
268
|
}
|
|
264
|
-
|
|
269
|
+
resetZoom() {
|
|
265
270
|
const parent = this.parent;
|
|
266
|
-
parent.notify('transform', { prop: 'setReverseFlip', onPropertyChange: false, value: { isReverseFlip: true } });
|
|
267
|
-
parent.panPoint.totalPannedPoint.x += this.tempFlipPanPoint.x;
|
|
268
|
-
parent.panPoint.totalPannedPoint.y += this.tempFlipPanPoint.y;
|
|
269
|
-
const tempCurrFlipState = parent.transform.currFlipState;
|
|
270
|
-
const obj = { flipColl: null };
|
|
271
|
-
parent.notify('transform', { prop: 'getFlipColl', onPropertyChange: false, value: { obj: obj } });
|
|
272
|
-
const tempFlipColl = obj['flipColl'];
|
|
273
|
-
parent.notify('transform', { prop: 'setFlipColl', onPropertyChange: false, value: { flipColl: [] } });
|
|
274
|
-
parent.notify('shape', { prop: 'updImgRatioForActObj', onPropertyChange: false });
|
|
275
|
-
parent.objColl.push(parent.activeObj);
|
|
276
271
|
if (parent.transform.zoomFactor > 0) {
|
|
277
272
|
const zoomFactor = parent.transform.zoomFactor;
|
|
278
273
|
const isUndoRedo = parent.isUndoRedo;
|
|
@@ -284,11 +279,25 @@ class Crop {
|
|
|
284
279
|
parent.isUndoRedo = isUndoRedo;
|
|
285
280
|
parent.notify('draw', { prop: 'resetPanPoints', onPropertyChange: false });
|
|
286
281
|
}
|
|
282
|
+
}
|
|
283
|
+
flipCrop() {
|
|
284
|
+
const parent = this.parent;
|
|
285
|
+
parent.notify('transform', { prop: 'setReverseFlip', onPropertyChange: false, value: { isReverseFlip: true } });
|
|
286
|
+
parent.panPoint.totalPannedPoint.x += this.tempFlipPanPoint.x;
|
|
287
|
+
parent.panPoint.totalPannedPoint.y += this.tempFlipPanPoint.y;
|
|
288
|
+
const tempCurrFlipState = parent.transform.currFlipState;
|
|
289
|
+
const obj = { flipColl: null };
|
|
290
|
+
parent.notify('transform', { prop: 'getFlipColl', onPropertyChange: false, value: { obj: obj } });
|
|
291
|
+
const tempFlipColl = obj['flipColl'];
|
|
292
|
+
parent.notify('transform', { prop: 'setFlipColl', onPropertyChange: false, value: { flipColl: [] } });
|
|
293
|
+
parent.notify('shape', { prop: 'updImgRatioForActObj', onPropertyChange: false });
|
|
294
|
+
parent.objColl.push(parent.activeObj);
|
|
295
|
+
this.resetZoom();
|
|
287
296
|
parent.currSelectionPoint = extend({}, parent.objColl[parent.objColl.length - 1], {}, true);
|
|
288
297
|
this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
|
|
289
298
|
this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
|
|
290
299
|
const temp = this.lowerContext.filter;
|
|
291
|
-
parent.notify('
|
|
300
|
+
parent.notify('filter', { prop: 'updateBrightFilter', onPropertyChange: false });
|
|
292
301
|
this.lowerContext.drawImage(parent.baseImg, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, parent.img.destLeft, parent.img.destTop, parent.img.destWidth, parent.img.destHeight);
|
|
293
302
|
for (let i = 0, len = parent.objColl.length; i < len; i++) {
|
|
294
303
|
parent.objColl[i].shapeFlip = '';
|
|
@@ -309,7 +318,7 @@ class Crop {
|
|
|
309
318
|
parent.notify('draw', { prop: 'setDestPoints', onPropertyChange: false });
|
|
310
319
|
parent.notify('draw', { prop: 'currTransState', onPropertyChange: false,
|
|
311
320
|
value: { type: 'initial', isPreventDestination: null, context: null, isPreventCircleCrop: null } });
|
|
312
|
-
parent.notify('
|
|
321
|
+
parent.notify('filter', { prop: 'updateBrightFilter', onPropertyChange: false });
|
|
313
322
|
this.lowerContext.drawImage(parent.baseImg, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, parent.img.destLeft, parent.img.destTop, parent.img.destWidth, parent.img.destHeight);
|
|
314
323
|
this.lowerContext.filter = temp;
|
|
315
324
|
parent.notify('draw', { prop: 'setRotateZoom', onPropertyChange: false, value: { isRotateZoom: false } });
|
|
@@ -431,6 +440,7 @@ class Crop {
|
|
|
431
440
|
setCurrSelPoints(isSetDimension) {
|
|
432
441
|
const parent = this.parent;
|
|
433
442
|
const destPoint = this.cropDestPoints;
|
|
443
|
+
const filter = this.lowerContext.filter;
|
|
434
444
|
parent.img.srcLeft = 0;
|
|
435
445
|
parent.img.srcTop = 0;
|
|
436
446
|
parent.img.srcWidth = parent.baseImg.width;
|
|
@@ -458,6 +468,7 @@ class Crop {
|
|
|
458
468
|
}
|
|
459
469
|
parent.notify('filter', { prop: 'updateBrightFilter', onPropertyChange: false });
|
|
460
470
|
this.lowerContext.drawImage(parent.baseImg, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, parent.img.destLeft, parent.img.destTop, parent.img.destWidth, parent.img.destHeight);
|
|
471
|
+
this.lowerContext.filter = filter;
|
|
461
472
|
parent.notify('draw', { prop: 'currTransState', onPropertyChange: false,
|
|
462
473
|
value: { type: 'reverse', isPreventDestination: null, context: null, isPreventCircleCrop: true } });
|
|
463
474
|
let cropObjColl = extend([], parent.objColl, null, true);
|
|
@@ -523,6 +534,16 @@ class Crop {
|
|
|
523
534
|
parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate' } });
|
|
524
535
|
parent.notify('transform', { prop: 'setTempPanMove', onPropertyChange: false,
|
|
525
536
|
value: { point: null } });
|
|
537
|
+
if (!this.isInitCrop && parent.transform.degree === 0 && parent.cropObj.currFlipState !== '' &&
|
|
538
|
+
parent.cropObj.cropZoom !== 0) {
|
|
539
|
+
this.isInitCrop = true;
|
|
540
|
+
parent.notify('draw', { prop: 'performCancel', value: { isContextualToolbar: null } });
|
|
541
|
+
parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'croptransform',
|
|
542
|
+
isApplyBtn: false, isCropping: null, isZooming: null, cType: null } });
|
|
543
|
+
}
|
|
544
|
+
else {
|
|
545
|
+
this.isInitCrop = false;
|
|
546
|
+
}
|
|
526
547
|
}
|
|
527
548
|
else {
|
|
528
549
|
const temp = this.lowerContext.filter;
|
|
@@ -536,22 +557,18 @@ class Crop {
|
|
|
536
557
|
}
|
|
537
558
|
panToSelRangle(isReverse) {
|
|
538
559
|
const parent = this.parent;
|
|
539
|
-
const
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
isReverse ? -parent.cropObj.totalPannedClientPoint.y : parent.cropObj.totalPannedClientPoint.y;
|
|
545
|
-
if (parent.transform.degree
|
|
546
|
-
parent.img.destLeft += panX;
|
|
547
|
-
parent.img.destTop += panY;
|
|
548
|
-
parent.notify('transform', { prop: 'drawPannImage', value: { point: { x: panX, y: panY } } });
|
|
549
|
-
}
|
|
550
|
-
else {
|
|
560
|
+
const obj = extend({}, parent.currSelectionPoint, null, true);
|
|
561
|
+
parent.currSelectionPoint = null;
|
|
562
|
+
const panX = parent.transform.degree !== 0 ?
|
|
563
|
+
isReverse ? -parent.cropObj.totalPannedClientPoint.x : parent.cropObj.totalPannedClientPoint.x : 0;
|
|
564
|
+
const panY = parent.transform.degree !== 0 ?
|
|
565
|
+
isReverse ? -parent.cropObj.totalPannedClientPoint.y : parent.cropObj.totalPannedClientPoint.y : 0;
|
|
566
|
+
if (parent.transform.degree !== 0) {
|
|
551
567
|
parent.panPoint.currentPannedPoint = { x: panX, y: panY };
|
|
552
568
|
parent.notify('transform', { prop: 'drawPannedImage', value: { xDiff: panX, yDiff: panY } });
|
|
553
569
|
parent.panPoint.currentPannedPoint = { x: 0, y: 0 };
|
|
554
570
|
}
|
|
571
|
+
parent.currSelectionPoint = obj;
|
|
555
572
|
}
|
|
556
573
|
cropCircle(context, isSave, isFlip) {
|
|
557
574
|
const parent = this.parent;
|
|
@@ -824,8 +841,6 @@ class Crop {
|
|
|
824
841
|
|
|
825
842
|
class Draw {
|
|
826
843
|
constructor(parent) {
|
|
827
|
-
this.cancelObjColl = [];
|
|
828
|
-
this.cancelPointColl = [];
|
|
829
844
|
this.isInitialLoading = false; // Specifies whether image is loaded for the first time or not (for applying initial filter)
|
|
830
845
|
this.fileName = '';
|
|
831
846
|
this.isErrorImage = false;
|
|
@@ -1045,7 +1060,6 @@ class Draw {
|
|
|
1045
1060
|
}
|
|
1046
1061
|
reset() {
|
|
1047
1062
|
this.isInitialLoading = this.isErrorImage = this.isNewPath = false;
|
|
1048
|
-
this.cancelObjColl = this.cancelPointColl = [];
|
|
1049
1063
|
this.isShapeTextInserted = false;
|
|
1050
1064
|
this.initZoomValue = null;
|
|
1051
1065
|
this.tempFilter = '';
|
|
@@ -1930,12 +1944,30 @@ class Draw {
|
|
|
1930
1944
|
canvasDraw.stroke();
|
|
1931
1945
|
canvasDraw.lineWidth = tempLineWidth;
|
|
1932
1946
|
}
|
|
1947
|
+
manipulateSaveCtx(canvasDraw, x, y) {
|
|
1948
|
+
if (canvasDraw !== this.lowerContext && canvasDraw !== this.upperContext) {
|
|
1949
|
+
const obj = { width: 0, height: 0 };
|
|
1950
|
+
this.parent.notify('crop', { prop: 'calcRatio', onPropertyChange: false,
|
|
1951
|
+
value: { obj: obj, dimension: { width: canvasDraw.canvas.width, height: canvasDraw.canvas.height } } });
|
|
1952
|
+
const ratio = obj;
|
|
1953
|
+
if (x) {
|
|
1954
|
+
x *= (ratio.width);
|
|
1955
|
+
}
|
|
1956
|
+
if (y) {
|
|
1957
|
+
y *= (ratio.height);
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
return { x: x, y: y };
|
|
1961
|
+
}
|
|
1933
1962
|
arrow(canvasDraw, start) {
|
|
1934
1963
|
const parent = this.parent;
|
|
1935
1964
|
const actPoint = parent.activeObj.activePoint;
|
|
1936
1965
|
canvasDraw.lineWidth = (parent.activeObj.strokeSettings.strokeWidth);
|
|
1937
|
-
|
|
1938
|
-
|
|
1966
|
+
let x = this.arrowDimension['arrow']['width'];
|
|
1967
|
+
let y = this.arrowDimension['arrow']['height'];
|
|
1968
|
+
const point = this.manipulateSaveCtx(canvasDraw, x, y);
|
|
1969
|
+
x = point.x + parent.activeObj.strokeSettings.strokeWidth;
|
|
1970
|
+
y = point.y + parent.activeObj.strokeSettings.strokeWidth;
|
|
1939
1971
|
this.dx = actPoint.endX - actPoint.startX;
|
|
1940
1972
|
this.dy = actPoint.endY - actPoint.startY;
|
|
1941
1973
|
canvasDraw.fillStyle = parent.activeObj.strokeSettings.strokeColor;
|
|
@@ -1970,8 +2002,11 @@ class Draw {
|
|
|
1970
2002
|
arrowSolid(canvasDraw, start) {
|
|
1971
2003
|
const parent = this.parent;
|
|
1972
2004
|
const actPoint = parent.activeObj.activePoint;
|
|
1973
|
-
|
|
1974
|
-
|
|
2005
|
+
let x = this.arrowDimension['arrowSolid']['width'];
|
|
2006
|
+
let y = this.arrowDimension['arrowSolid']['height'];
|
|
2007
|
+
const point = this.manipulateSaveCtx(canvasDraw, x, y);
|
|
2008
|
+
x = point.x + parent.activeObj.strokeSettings.strokeWidth;
|
|
2009
|
+
y = point.y + parent.activeObj.strokeSettings.strokeWidth;
|
|
1975
2010
|
this.dx = actPoint.endX - actPoint.startX;
|
|
1976
2011
|
this.dy = actPoint.endY - actPoint.startY;
|
|
1977
2012
|
const angle = Math.atan2(this.dy, this.dx);
|
|
@@ -2021,8 +2056,11 @@ class Draw {
|
|
|
2021
2056
|
canvasDraw.lineWidth = (parent.activeObj.strokeSettings.strokeWidth);
|
|
2022
2057
|
canvasDraw.beginPath();
|
|
2023
2058
|
canvasDraw.fillStyle = parent.activeObj.strokeSettings.strokeColor;
|
|
2024
|
-
|
|
2025
|
-
|
|
2059
|
+
let x = this.arrowDimension['square']['width'];
|
|
2060
|
+
let y = this.arrowDimension['square']['height'];
|
|
2061
|
+
const point = this.manipulateSaveCtx(canvasDraw, x, y);
|
|
2062
|
+
x = point.x + parent.activeObj.strokeSettings.strokeWidth;
|
|
2063
|
+
y = point.y + parent.activeObj.strokeSettings.strokeWidth;
|
|
2026
2064
|
this.dx = actPoint.endX - actPoint.startX;
|
|
2027
2065
|
this.dy = actPoint.endY - actPoint.startY;
|
|
2028
2066
|
const angle = Math.atan2(this.dy, this.dx);
|
|
@@ -2077,8 +2115,11 @@ class Draw {
|
|
|
2077
2115
|
arrowSquareEnd(canvasDraw) {
|
|
2078
2116
|
const parent = this.parent;
|
|
2079
2117
|
const actPoint = parent.activeObj.activePoint;
|
|
2080
|
-
|
|
2081
|
-
|
|
2118
|
+
let x = this.arrowDimension['square']['width'];
|
|
2119
|
+
let y = this.arrowDimension['square']['height'];
|
|
2120
|
+
const point = this.manipulateSaveCtx(canvasDraw, x, y);
|
|
2121
|
+
x = point.x + parent.activeObj.strokeSettings.strokeWidth;
|
|
2122
|
+
y = point.y + parent.activeObj.strokeSettings.strokeWidth;
|
|
2082
2123
|
this.dx = actPoint.endX - actPoint.startX;
|
|
2083
2124
|
this.dy = actPoint.endY - actPoint.startY;
|
|
2084
2125
|
const angle = Math.atan2(this.dy, this.dx);
|
|
@@ -2140,7 +2181,9 @@ class Draw {
|
|
|
2140
2181
|
if ((start && parent.activeObj.triangleDirection === 'left') ||
|
|
2141
2182
|
(!start && parent.activeObj.triangleDirection === 'right')) {
|
|
2142
2183
|
canvasDraw.lineWidth = (parent.activeObj.strokeSettings.strokeWidth);
|
|
2143
|
-
|
|
2184
|
+
let circleRadius = this.arrowDimension['circle']['width'];
|
|
2185
|
+
const point = this.manipulateSaveCtx(canvasDraw, circleRadius, null);
|
|
2186
|
+
circleRadius = point.x + parent.activeObj.strokeSettings.strokeWidth;
|
|
2144
2187
|
canvasDraw.beginPath();
|
|
2145
2188
|
canvasDraw.arc(actPoint.endX, actPoint.endY, circleRadius, 0, 2 * Math.PI);
|
|
2146
2189
|
canvasDraw.stroke();
|
|
@@ -2188,7 +2231,9 @@ class Draw {
|
|
|
2188
2231
|
else if ((start && parent.activeObj.triangleDirection === 'right') ||
|
|
2189
2232
|
(!start && parent.activeObj.triangleDirection === 'left')) {
|
|
2190
2233
|
canvasDraw.lineWidth = (parent.activeObj.strokeSettings.strokeWidth);
|
|
2191
|
-
|
|
2234
|
+
let circleRadius = this.arrowDimension['circle']['width'];
|
|
2235
|
+
const point = this.manipulateSaveCtx(canvasDraw, circleRadius, null);
|
|
2236
|
+
circleRadius = point.x + parent.activeObj.strokeSettings.strokeWidth;
|
|
2192
2237
|
canvasDraw.beginPath();
|
|
2193
2238
|
canvasDraw.arc(actPoint.startX, actPoint.startY, circleRadius, 0, 2 * Math.PI);
|
|
2194
2239
|
canvasDraw.stroke();
|
|
@@ -2246,7 +2291,9 @@ class Draw {
|
|
|
2246
2291
|
(!start && (parent.activeObj.end === 'circleSolid' && parent.activeObj.start === 'none'))) {
|
|
2247
2292
|
this.shapeLine(canvasDraw, actPoint.startX, actPoint.startY, actPoint.endX, actPoint.endY);
|
|
2248
2293
|
}
|
|
2249
|
-
|
|
2294
|
+
let circleRadius = this.arrowDimension['circle']['width'];
|
|
2295
|
+
const point = this.manipulateSaveCtx(canvasDraw, circleRadius, null);
|
|
2296
|
+
circleRadius = point.x + parent.activeObj.strokeSettings.strokeWidth;
|
|
2250
2297
|
this.dx = actPoint.endX - actPoint.startX;
|
|
2251
2298
|
this.dy = actPoint.endY - actPoint.startY;
|
|
2252
2299
|
canvasDraw.save();
|
|
@@ -2267,7 +2314,9 @@ class Draw {
|
|
|
2267
2314
|
!start && (parent.activeObj.end === 'circleSolid' && parent.activeObj.start === 'none')) {
|
|
2268
2315
|
this.shapeLine(canvasDraw, actPoint.startX, actPoint.startY, actPoint.endX, actPoint.endY);
|
|
2269
2316
|
}
|
|
2270
|
-
|
|
2317
|
+
let circleRadius = this.arrowDimension['circle']['width'];
|
|
2318
|
+
const point = this.manipulateSaveCtx(canvasDraw, circleRadius, null);
|
|
2319
|
+
circleRadius = point.x + parent.activeObj.strokeSettings.strokeWidth;
|
|
2271
2320
|
this.dx = actPoint.endX - actPoint.startX;
|
|
2272
2321
|
this.dy = actPoint.endY - actPoint.startY;
|
|
2273
2322
|
canvasDraw.save();
|
|
@@ -2293,8 +2342,11 @@ class Draw {
|
|
|
2293
2342
|
(parent.activeObj.end === 'bar' && (parent.activeObj.start !== 'circle' && parent.activeObj.start !== 'square'))))) {
|
|
2294
2343
|
this.shapeLine(canvasDraw, actPoint.startX, actPoint.startY, actPoint.endX, actPoint.endY);
|
|
2295
2344
|
}
|
|
2296
|
-
|
|
2297
|
-
|
|
2345
|
+
let x = this.arrowDimension['bar']['width'];
|
|
2346
|
+
let y = this.arrowDimension['bar']['height'];
|
|
2347
|
+
const point = this.manipulateSaveCtx(canvasDraw, x, y);
|
|
2348
|
+
x = point.x + parent.activeObj.strokeSettings.strokeWidth;
|
|
2349
|
+
y = point.y + parent.activeObj.strokeSettings.strokeWidth;
|
|
2298
2350
|
this.dx = actPoint.endX - actPoint.startX;
|
|
2299
2351
|
this.dy = actPoint.endY - actPoint.startY;
|
|
2300
2352
|
const angle = Math.atan2(this.dy, this.dx);
|
|
@@ -2315,8 +2367,11 @@ class Draw {
|
|
|
2315
2367
|
(!start && (parent.activeObj.end === 'bar' && parent.activeObj.start === 'none'))) {
|
|
2316
2368
|
this.shapeLine(canvasDraw, actPoint.startX, actPoint.startY, actPoint.endX, actPoint.endY);
|
|
2317
2369
|
}
|
|
2318
|
-
|
|
2319
|
-
|
|
2370
|
+
let x = this.arrowDimension['bar']['width'];
|
|
2371
|
+
let y = this.arrowDimension['bar']['height'];
|
|
2372
|
+
const point = this.manipulateSaveCtx(canvasDraw, x, y);
|
|
2373
|
+
x = point.x + parent.activeObj.strokeSettings.strokeWidth;
|
|
2374
|
+
y = point.y + parent.activeObj.strokeSettings.strokeWidth;
|
|
2320
2375
|
this.dx = actPoint.endX - actPoint.startX;
|
|
2321
2376
|
this.dy = actPoint.endY - actPoint.startY;
|
|
2322
2377
|
const angle = Math.atan2(this.dy, this.dx);
|
|
@@ -3175,8 +3230,6 @@ class Draw {
|
|
|
3175
3230
|
parent.isCropTab = isCropTab;
|
|
3176
3231
|
this.resetPanPoints();
|
|
3177
3232
|
}
|
|
3178
|
-
this.cancelObjColl = extend([], parent.objColl, [], true);
|
|
3179
|
-
this.cancelPointColl = extend([], parent.pointColl, [], true);
|
|
3180
3233
|
parent.notify('freehand-draw', { prop: 'updateFHDColl', onPropertyChange: false });
|
|
3181
3234
|
parent.isCropTab = true;
|
|
3182
3235
|
parent.isCircleCrop = false;
|
|
@@ -3485,7 +3538,7 @@ class Draw {
|
|
|
3485
3538
|
parent.afterCropActions = obj.afterCropActions;
|
|
3486
3539
|
}
|
|
3487
3540
|
this.lowerContext.filter = obj.filter;
|
|
3488
|
-
parent.notify('filter', { prop: 'setBrightnessAdjusted', onPropertyChange: false, value: { isBrightnessAdjusted:
|
|
3541
|
+
parent.notify('filter', { prop: 'setBrightnessAdjusted', onPropertyChange: false, value: { isBrightnessAdjusted: obj.isBrightAdjust } });
|
|
3489
3542
|
const isCircleCrop = parent.isCircleCrop;
|
|
3490
3543
|
let currSelectionPoint;
|
|
3491
3544
|
if (isNullOrUndefined(parent.currSelectionPoint)) {
|
|
@@ -3581,6 +3634,7 @@ class Draw {
|
|
|
3581
3634
|
this.setTransformColl(this.lowerContext, 'initial');
|
|
3582
3635
|
}
|
|
3583
3636
|
parent.notify('transform', { prop: 'setDestPointsForFlipState', onPropertyChange: false });
|
|
3637
|
+
parent.notify('filter', { prop: 'updateBrightFilter', onPropertyChange: false });
|
|
3584
3638
|
this.lowerContext.drawImage(parent.baseImg, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, parent.img.destLeft, parent.img.destTop, parent.img.destWidth, parent.img.destHeight);
|
|
3585
3639
|
if (isObj) {
|
|
3586
3640
|
this.updateCurrTransState('reverse');
|
|
@@ -3908,7 +3962,7 @@ class Draw {
|
|
|
3908
3962
|
object['isInitialLoaded'] = this.isInitialLoading;
|
|
3909
3963
|
}
|
|
3910
3964
|
getFileExtensionFromURL(url) {
|
|
3911
|
-
const lastDotIndex = url.lastIndexOf(
|
|
3965
|
+
const lastDotIndex = url.lastIndexOf('.');
|
|
3912
3966
|
if (lastDotIndex !== -1) {
|
|
3913
3967
|
return url.slice(lastDotIndex + 1).toLowerCase();
|
|
3914
3968
|
}
|
|
@@ -4286,7 +4340,6 @@ class Export {
|
|
|
4286
4340
|
id: parent.element.id + '_tempCanvas', attrs: { name: 'canvasImage' }
|
|
4287
4341
|
});
|
|
4288
4342
|
const tempContext = tempCanvas.getContext('2d');
|
|
4289
|
-
tempContext.filter = this.lowerContext.filter;
|
|
4290
4343
|
tempCanvas.width = width;
|
|
4291
4344
|
tempCanvas.height = height;
|
|
4292
4345
|
const dimObj = { width: 0, height: 0 };
|
|
@@ -4295,9 +4348,9 @@ class Export {
|
|
|
4295
4348
|
const maxDimension = dimObj;
|
|
4296
4349
|
tempCanvas.style.maxWidth = maxDimension.width + 'px';
|
|
4297
4350
|
tempCanvas.style.maxHeight = maxDimension.height + 'px';
|
|
4298
|
-
tempContext.filter = this.lowerContext.filter;
|
|
4299
4351
|
const temp = this.lowerContext.filter;
|
|
4300
4352
|
parent.notify('filter', { prop: 'updateBrightFilter', onPropertyChange: false });
|
|
4353
|
+
tempContext.filter = this.lowerContext.filter;
|
|
4301
4354
|
tempContext.drawImage(parent.baseImg, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, 0, 0, width, height);
|
|
4302
4355
|
this.lowerContext.filter = temp;
|
|
4303
4356
|
if (parent.transform.degree !== 0 || parent.transform.currFlipState !== '') {
|
|
@@ -4328,6 +4381,14 @@ class Export {
|
|
|
4328
4381
|
if (parent.objColl[i].shape === 'text') {
|
|
4329
4382
|
parent.objColl[i].textSettings.fontSize *= ((ratio.width + ratio.height) / 2);
|
|
4330
4383
|
}
|
|
4384
|
+
else if (parent.objColl[i].shape === 'path') {
|
|
4385
|
+
for (let l = 0; l < parent.objColl[i].pointColl.length; l++) {
|
|
4386
|
+
parent.objColl[i].pointColl[l].x =
|
|
4387
|
+
(parent.objColl[i].pointColl[l].x - parent.img.destLeft) * ratio.width;
|
|
4388
|
+
parent.objColl[i].pointColl[l].y =
|
|
4389
|
+
(parent.objColl[i].pointColl[l].y - parent.img.destTop) * ratio.height;
|
|
4390
|
+
}
|
|
4391
|
+
}
|
|
4331
4392
|
parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'saveContext', obj: parent.objColl[i], isCropRatio: null,
|
|
4332
4393
|
points: null, isPreventDrag: true, saveContext: tempContext, isPreventSelection: null } });
|
|
4333
4394
|
}
|
|
@@ -4914,8 +4975,6 @@ class Filter {
|
|
|
4914
4975
|
parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false, value: { obj: selPointCollObj } });
|
|
4915
4976
|
prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
|
|
4916
4977
|
this.updateAdj(type, value);
|
|
4917
|
-
const filter = this.lowerContext.filter;
|
|
4918
|
-
this.lowerContext.filter = this.appliedFilter;
|
|
4919
4978
|
parent.notify('undo-redo', {
|
|
4920
4979
|
prop: 'updateUndoRedoColl',
|
|
4921
4980
|
onPropertyChange: false,
|
|
@@ -4932,7 +4991,6 @@ class Filter {
|
|
|
4932
4991
|
isCircleCrop: null
|
|
4933
4992
|
}
|
|
4934
4993
|
});
|
|
4935
|
-
this.lowerContext.filter = filter;
|
|
4936
4994
|
}
|
|
4937
4995
|
setFilter(type) {
|
|
4938
4996
|
const parent = this.parent;
|
|
@@ -4950,15 +5008,12 @@ class Filter {
|
|
|
4950
5008
|
value: { obj: selPointCollObj } });
|
|
4951
5009
|
prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
|
|
4952
5010
|
this.updateAdj(type, null);
|
|
4953
|
-
const filter = this.lowerContext.filter;
|
|
4954
|
-
this.lowerContext.filter = this.appliedFilter;
|
|
4955
5011
|
parent.notify('draw', { prop: 'setImageEdited', onPropertyChange: false });
|
|
4956
5012
|
parent.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
|
|
4957
5013
|
value: { operation: type, previousObj: prevObj, previousObjColl: prevObj.objColl,
|
|
4958
5014
|
previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
|
|
4959
5015
|
previousCropObj: prevCropObj, previousText: null,
|
|
4960
5016
|
currentText: null, previousFilter: prevFilter, isCircleCrop: null } });
|
|
4961
|
-
this.lowerContext.filter = filter;
|
|
4962
5017
|
}
|
|
4963
5018
|
setAdjustment(type) {
|
|
4964
5019
|
const splitWords = this.lowerContext.filter.split(' ');
|
|
@@ -5111,7 +5166,7 @@ class Filter {
|
|
|
5111
5166
|
totalPannedInternalPoint: { x: 0, y: 0 }, tempFlipPanPoint: { x: 0, y: 0 }, activeObj: {},
|
|
5112
5167
|
rotateFlipColl: [], degree: 0, currFlipState: '', zoomFactor: 0, previousZoomValue: 0,
|
|
5113
5168
|
destPoints: { startX: 0, startY: 0, width: 0, height: 0 },
|
|
5114
|
-
srcPoints: { startX: 0, startY: 0, width: 0, height: 0 }, filter: '' };
|
|
5169
|
+
srcPoints: { startX: 0, startY: 0, width: 0, height: 0 }, filter: '', isBrightAdjust: this.isBrightnessAdjusted };
|
|
5115
5170
|
obj.cropZoom = parent.transform.cropZoomFactor;
|
|
5116
5171
|
obj.defaultZoom = parent.transform.defaultZoomFactor;
|
|
5117
5172
|
obj.zoomFactor = parent.zoomSettings.zoomFactor;
|
|
@@ -5147,6 +5202,7 @@ class FreehandDrawing {
|
|
|
5147
5202
|
this.selPointColl = {};
|
|
5148
5203
|
this.currFHDIdx = 0; // Specifies id for every freehand drawing - uses while deleting
|
|
5149
5204
|
this.selPoints = [];
|
|
5205
|
+
this.dummyPoints = [];
|
|
5150
5206
|
this.tempFHDStyles = { strokeColor: null, fillColor: null, strokeWidth: null };
|
|
5151
5207
|
this.parent = parent;
|
|
5152
5208
|
this.addEventListener();
|
|
@@ -5300,6 +5356,7 @@ class FreehandDrawing {
|
|
|
5300
5356
|
this.fhdObj = { lastWidth: 0, lastVelocity: 0, time: 0, pointX: 0, pointY: 0 };
|
|
5301
5357
|
this.isFreehandDrawing = this.isFreehandPointMoved = false;
|
|
5302
5358
|
this.selPoints = [];
|
|
5359
|
+
this.dummyPoints = [];
|
|
5303
5360
|
this.freehandDownPoint = { x: 0, y: 0 };
|
|
5304
5361
|
this.selPointColl = {};
|
|
5305
5362
|
this.fhdHovIdx = null;
|
|
@@ -5348,7 +5405,12 @@ class FreehandDrawing {
|
|
|
5348
5405
|
if (parent.points[l + 1] && parent.points[l + 2] && parent.points[l + 2]) {
|
|
5349
5406
|
controlPoint1 = (this.calcCurveCP(parent.points[l + 0], parent.points[l + 1], parent.points[l + 2])).controlPoint2;
|
|
5350
5407
|
controlPoint2 = (this.calcCurveCP(parent.points[l + 1], parent.points[l + 2], parent.points[l + 3])).controlPoint1;
|
|
5351
|
-
|
|
5408
|
+
if (l === 0) {
|
|
5409
|
+
startPoint = parent.points[l];
|
|
5410
|
+
}
|
|
5411
|
+
else {
|
|
5412
|
+
startPoint = parent.points[l + 1];
|
|
5413
|
+
}
|
|
5352
5414
|
endPoint = parent.points[l + 2];
|
|
5353
5415
|
this.startDraw(context, controlPoint1, controlPoint2, startPoint, endPoint, minStrokeWidth, maxStrokeWidth);
|
|
5354
5416
|
}
|
|
@@ -5415,6 +5477,7 @@ class FreehandDrawing {
|
|
|
5415
5477
|
parent.pointColl[fhCnt].flipState = parent.transform.currFlipState;
|
|
5416
5478
|
parent.pointColl[fhCnt].id = 'pen_' + (this.currFHDIdx + 1);
|
|
5417
5479
|
parent.points = [];
|
|
5480
|
+
this.dummyPoints = [];
|
|
5418
5481
|
this.selPointColl[fhCnt] = {};
|
|
5419
5482
|
this.selPointColl[fhCnt].points = extend([], this.selPoints);
|
|
5420
5483
|
this.selPoints = [];
|
|
@@ -5462,15 +5525,21 @@ class FreehandDrawing {
|
|
|
5462
5525
|
parent.points.push({ x: x, y: y, ratioX: (x - parent.img.destLeft) / parent.img.destWidth,
|
|
5463
5526
|
ratioY: (y - parent.img.destTop) / parent.img.destHeight,
|
|
5464
5527
|
time: this.fhdObj.time });
|
|
5465
|
-
|
|
5466
|
-
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
|
|
5528
|
+
this.dummyPoints.push({ x: x, y: y, ratioX: (x - parent.img.destLeft) / parent.img.destWidth,
|
|
5529
|
+
ratioY: (y - parent.img.destTop) / parent.img.destHeight,
|
|
5530
|
+
time: this.fhdObj.time });
|
|
5531
|
+
if (this.dummyPoints.length > 2) {
|
|
5532
|
+
if (this.dummyPoints.length === 3) {
|
|
5533
|
+
this.dummyPoints.unshift(this.dummyPoints[0]);
|
|
5534
|
+
}
|
|
5535
|
+
const p0 = this.dummyPoints[0];
|
|
5536
|
+
const p1 = this.dummyPoints[1];
|
|
5537
|
+
const p2 = this.dummyPoints[2];
|
|
5538
|
+
const p3 = this.dummyPoints[3];
|
|
5470
5539
|
controlPoint1 = this.calcCurveCP(p0, p1, p2).controlPoint2;
|
|
5471
5540
|
controlPoint2 = this.calcCurveCP(p1, p2, p3).controlPoint1;
|
|
5472
|
-
startPoint =
|
|
5473
|
-
endPoint =
|
|
5541
|
+
startPoint = this.dummyPoints[1];
|
|
5542
|
+
endPoint = this.dummyPoints[2];
|
|
5474
5543
|
let minStrokeWidth = 0.5;
|
|
5475
5544
|
let maxStrokeWidth = 5;
|
|
5476
5545
|
if (!isNullOrUndefined(this.penStrokeWidth)) {
|
|
@@ -5478,6 +5547,7 @@ class FreehandDrawing {
|
|
|
5478
5547
|
}
|
|
5479
5548
|
this.startDraw(context, controlPoint1, controlPoint2, startPoint, endPoint, minStrokeWidth, maxStrokeWidth);
|
|
5480
5549
|
this.pointCounter++;
|
|
5550
|
+
this.dummyPoints.shift();
|
|
5481
5551
|
}
|
|
5482
5552
|
if (mouseDown) {
|
|
5483
5553
|
controlPoint1 = controlPoint2 = startPoint = endPoint = { x: x, y: y, time: new Date().getTime() };
|
|
@@ -5648,7 +5718,12 @@ class FreehandDrawing {
|
|
|
5648
5718
|
if (parent.points[l + 1] && parent.points[l + 2] && parent.points[l + 2]) {
|
|
5649
5719
|
controlPoint1 = (this.calcCurveCP(parent.points[l + 0], parent.points[l + 1], parent.points[l + 2])).controlPoint2;
|
|
5650
5720
|
controlPoint2 = (this.calcCurveCP(parent.points[l + 1], parent.points[l + 2], parent.points[l + 3])).controlPoint1;
|
|
5651
|
-
|
|
5721
|
+
if (l === 0) {
|
|
5722
|
+
startPoint = parent.points[l];
|
|
5723
|
+
}
|
|
5724
|
+
else {
|
|
5725
|
+
startPoint = parent.points[l + 1];
|
|
5726
|
+
}
|
|
5652
5727
|
endPoint = parent.points[l + 2];
|
|
5653
5728
|
this.startDraw(context, controlPoint1, controlPoint2, startPoint, endPoint, minStrokeWidth, maxStrokeWidth);
|
|
5654
5729
|
}
|
|
@@ -5774,18 +5849,21 @@ class FreehandDrawing {
|
|
|
5774
5849
|
if (isBlazor() && parent.events && parent.events.shapeChanging.hasDelegate === true) {
|
|
5775
5850
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
5776
5851
|
parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShape', shapeChangingArgs).then((shapeChangingArgs) => {
|
|
5777
|
-
parent.pointColl[this.fhdSelIdx].strokeColor =
|
|
5778
|
-
|
|
5852
|
+
parent.activeObj.strokeSettings.strokeColor = parent.pointColl[this.fhdSelIdx].strokeColor =
|
|
5853
|
+
shapeChangingArgs.currentShapeSettings.strokeColor;
|
|
5854
|
+
parent.activeObj.strokeSettings.strokeWidth = parent.pointColl[this.fhdSelIdx].strokeWidth =
|
|
5855
|
+
shapeChangingArgs.currentShapeSettings.strokeWidth;
|
|
5779
5856
|
parent.pointColl[this.fhdSelIdx].points = shapeChangingArgs.currentShapeSettings.points;
|
|
5780
5857
|
this.freehandRedraw(this.upperContext);
|
|
5781
|
-
parent.updateToolbar(parent.element, '
|
|
5782
|
-
parent.updateToolbar(parent.element, 'pen');
|
|
5858
|
+
parent.updateToolbar(parent.element, 'colorToolbar');
|
|
5783
5859
|
});
|
|
5784
5860
|
}
|
|
5785
5861
|
else {
|
|
5786
5862
|
parent.trigger('shapeChanging', shapeChangingArgs);
|
|
5787
|
-
parent.pointColl[this.fhdSelIdx].strokeColor =
|
|
5788
|
-
|
|
5863
|
+
parent.activeObj.strokeSettings.strokeColor = parent.pointColl[this.fhdSelIdx].strokeColor =
|
|
5864
|
+
shapeChangingArgs.currentShapeSettings.strokeColor;
|
|
5865
|
+
parent.activeObj.strokeSettings.strokeWidth = parent.pointColl[this.fhdSelIdx].strokeWidth =
|
|
5866
|
+
shapeChangingArgs.currentShapeSettings.strokeWidth;
|
|
5789
5867
|
parent.pointColl[this.fhdSelIdx].points = shapeChangingArgs.currentShapeSettings.points;
|
|
5790
5868
|
this.freehandRedraw(this.upperContext);
|
|
5791
5869
|
parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'pen',
|
|
@@ -6104,6 +6182,7 @@ class FreehandDrawing {
|
|
|
6104
6182
|
const parent = this.parent;
|
|
6105
6183
|
if (value) {
|
|
6106
6184
|
parent.points = [];
|
|
6185
|
+
this.dummyPoints = [];
|
|
6107
6186
|
parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
|
|
6108
6187
|
parent.togglePen = true;
|
|
6109
6188
|
parent.upperCanvas.style.cursor = parent.cursor = 'crosshair';
|
|
@@ -7027,12 +7106,8 @@ class Selection {
|
|
|
7027
7106
|
const previousShapeSettings = this.updatePrevShapeSettings();
|
|
7028
7107
|
const shapeResizingArgs = { action: 'resize', previousShapeSettings: previousShapeSettings };
|
|
7029
7108
|
const shapeMovingArgs = { action: 'move', previousShapeSettings: previousShapeSettings };
|
|
7030
|
-
|
|
7031
|
-
|
|
7032
|
-
}
|
|
7033
|
-
if (isNullOrUndefined(this.shapeMovingArgs)) {
|
|
7034
|
-
this.shapeMovingArgs = shapeMovingArgs;
|
|
7035
|
-
}
|
|
7109
|
+
this.shapeResizingArgs = shapeResizingArgs;
|
|
7110
|
+
this.shapeMovingArgs = shapeMovingArgs;
|
|
7036
7111
|
if (parent.activeObj.shape === 'text' && this.dragElement !== '') {
|
|
7037
7112
|
parent.notify('shape', { prop: 'updateFontRatio', onPropertyChange: false,
|
|
7038
7113
|
value: { obj: parent.activeObj, isTextArea: null } });
|
|
@@ -7231,8 +7306,8 @@ class Selection {
|
|
|
7231
7306
|
parent.activeObj.activePoint.width = parent.activeObj.activePoint.endX - parent.activeObj.activePoint.startX;
|
|
7232
7307
|
parent.activeObj.activePoint.height = parent.activeObj.activePoint.endY - parent.activeObj.activePoint.startY;
|
|
7233
7308
|
const currentShapeSettings = this.updatePrevShapeSettings();
|
|
7234
|
-
shapeResizingArgs.currentShapeSettings = currentShapeSettings;
|
|
7235
|
-
shapeMovingArgs.currentShapeSettings = currentShapeSettings;
|
|
7309
|
+
shapeResizingArgs.currentShapeSettings = this.shapeResizingArgs.currentShapeSettings = currentShapeSettings;
|
|
7310
|
+
shapeMovingArgs.currentShapeSettings = this.shapeMovingArgs.currentShapeSettings = currentShapeSettings;
|
|
7236
7311
|
if (type === 'resize') {
|
|
7237
7312
|
this.isCropSelection = false;
|
|
7238
7313
|
let splitWords;
|
|
@@ -7243,7 +7318,7 @@ class Selection {
|
|
|
7243
7318
|
this.isCropSelection = true;
|
|
7244
7319
|
}
|
|
7245
7320
|
if (!this.isCropSelection && this.parent.eventType !== 'resize' && isBlazor() && parent.events && this.parent.events.onShapeResizeStart.hasDelegate === true) {
|
|
7246
|
-
shapeResizingArgs.action = 'resize-start';
|
|
7321
|
+
shapeResizingArgs.action = this.currentDrawingShape !== '' ? 'drawing' : 'resize-start';
|
|
7247
7322
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
7248
7323
|
parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShapeResizeStart', shapeResizingArgs).then((shapeResizingArgs) => {
|
|
7249
7324
|
parent.notify('shape', { prop: 'updateShapeChangeEventArgs', onPropertyChange: false,
|
|
@@ -7251,6 +7326,9 @@ class Selection {
|
|
|
7251
7326
|
});
|
|
7252
7327
|
}
|
|
7253
7328
|
else if (!this.isCropSelection) {
|
|
7329
|
+
if (this.currentDrawingShape !== '') {
|
|
7330
|
+
shapeResizingArgs.action = 'drawing';
|
|
7331
|
+
}
|
|
7254
7332
|
parent.trigger('shapeChanging', shapeResizingArgs);
|
|
7255
7333
|
parent.notify('shape', { prop: 'updateShapeChangeEventArgs', onPropertyChange: false,
|
|
7256
7334
|
value: { shapeSettings: shapeResizingArgs.currentShapeSettings } });
|
|
@@ -7267,9 +7345,7 @@ class Selection {
|
|
|
7267
7345
|
startY: shapeResizingArgs.currentShapeSettings.startY,
|
|
7268
7346
|
width: shapeResizingArgs.currentShapeSettings.width,
|
|
7269
7347
|
height: shapeResizingArgs.currentShapeSettings.height } };
|
|
7270
|
-
|
|
7271
|
-
this.selectionResizingArgs = selectionResizingArgs;
|
|
7272
|
-
}
|
|
7348
|
+
this.selectionResizingArgs = selectionResizingArgs;
|
|
7273
7349
|
if (isBlazor() && isNullOrUndefined(this.parent.eventType) && parent.events &&
|
|
7274
7350
|
parent.events.onSelectionResizeStart.hasDelegate === true) {
|
|
7275
7351
|
selectionResizingArgs.action = 'resize-start';
|
|
@@ -9178,7 +9254,7 @@ class Selection {
|
|
|
9178
9254
|
else if (this.parent.eventType === 'resize') {
|
|
9179
9255
|
if (!this.isCropSelection && this.parent.events && this.parent.events.onShapeResizeEnd.hasDelegate === true) {
|
|
9180
9256
|
this.shapeResizingArgs.currentShapeSettings = this.updatePrevShapeSettings();
|
|
9181
|
-
this.shapeResizingArgs.action = 'resize-end';
|
|
9257
|
+
this.shapeResizingArgs.action = this.currentDrawingShape !== '' ? 'drawing' : 'resize-end';
|
|
9182
9258
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
9183
9259
|
this.parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShapeResizeEnd', this.shapeResizingArgs).then((shapeResizingArgs) => {
|
|
9184
9260
|
this.parent.notify('shape', { prop: 'updateShapeChangeEventArgs', onPropertyChange: false,
|
|
@@ -9597,7 +9673,8 @@ class Selection {
|
|
|
9597
9673
|
isApply = false;
|
|
9598
9674
|
}
|
|
9599
9675
|
else if (parent.upperCanvas.style.cursor !== 'default' && parent.upperCanvas.style.cursor !== 'grab' &&
|
|
9600
|
-
parent.upperCanvas.style.cursor !== 'crosshair' && parent.upperCanvas.style.cursor !== 'pointer'
|
|
9676
|
+
parent.upperCanvas.style.cursor !== 'crosshair' && parent.upperCanvas.style.cursor !== 'pointer' &&
|
|
9677
|
+
parent.upperCanvas.style.cursor !== 'move') {
|
|
9601
9678
|
isApply = false;
|
|
9602
9679
|
}
|
|
9603
9680
|
else {
|
|
@@ -10342,9 +10419,20 @@ class Selection {
|
|
|
10342
10419
|
if (isNullOrUndefined(actObj.activePoint)) {
|
|
10343
10420
|
return;
|
|
10344
10421
|
}
|
|
10345
|
-
|
|
10346
|
-
|
|
10422
|
+
const radius = actObj.topLeftCircle ? actObj.topLeftCircle.radius : 0;
|
|
10423
|
+
if ((x >= Math.floor(actObj.activePoint.startX) &&
|
|
10424
|
+
x <= Math.ceil(actObj.activePoint.endX) &&
|
|
10425
|
+
y >= Math.floor(actObj.activePoint.startY) &&
|
|
10426
|
+
y <= Math.ceil(actObj.activePoint.endY))) {
|
|
10427
|
+
isInside = true;
|
|
10428
|
+
}
|
|
10429
|
+
else if (radius !== 0 && (x >= Math.floor(actObj.activePoint.startX) - radius &&
|
|
10430
|
+
x <= Math.ceil(actObj.activePoint.endX) + radius &&
|
|
10431
|
+
y >= Math.floor(actObj.activePoint.startY) - radius &&
|
|
10432
|
+
y <= Math.ceil(actObj.activePoint.endY) + radius)) {
|
|
10347
10433
|
isInside = true;
|
|
10434
|
+
this.tempActiveObj = { activePoint: { startX: 0, startY: 0, endX: 0, endY: 0, width: 0, height: 0 },
|
|
10435
|
+
flipObjColl: [], triangle: [], triangleRatio: [] };
|
|
10348
10436
|
}
|
|
10349
10437
|
else if (actObj.shape === 'text' && this.dragElement !== '') {
|
|
10350
10438
|
isInside = true;
|
|
@@ -10434,7 +10522,9 @@ class Selection {
|
|
|
10434
10522
|
setTextBoxStylesToActObj() {
|
|
10435
10523
|
const parent = this.parent;
|
|
10436
10524
|
parent.activeObj.textSettings.fontFamily = parent.textArea.style.fontFamily;
|
|
10437
|
-
parent.activeObj.strokeSettings.strokeColor = parent.textArea.style.color !== ''
|
|
10525
|
+
parent.activeObj.strokeSettings.strokeColor = parent.textArea.style.color !== '' &&
|
|
10526
|
+
parent.textArea.style.color.split('(')[1] && parent.textArea.style.color.split('(')[1].split(',')[0] &&
|
|
10527
|
+
parent.textArea.style.color.split('(')[1].split(',')[1] && parent.textArea.style.color.split('(')[1].split(',')[2] ?
|
|
10438
10528
|
this.rgbToHex(parseFloat(parent.textArea.style.color.split('(')[1].split(',')[0]), parseFloat(parent.textArea.style.color.split('(')[1].split(',')[1]), parseFloat(parent.textArea.style.color.split('(')[1].split(',')[2])) :
|
|
10439
10529
|
parent.textArea.style.color;
|
|
10440
10530
|
if (parent.textArea.style.fontWeight === 'bold') {
|
|
@@ -11261,6 +11351,9 @@ class Shape {
|
|
|
11261
11351
|
isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
|
|
11262
11352
|
parent.notify('toolbar', { prop: 'update-toolbar-items', onPropertyChange: false });
|
|
11263
11353
|
}
|
|
11354
|
+
else {
|
|
11355
|
+
parent.updateToolbar(parent.element, 'text');
|
|
11356
|
+
}
|
|
11264
11357
|
}
|
|
11265
11358
|
initializeTextShape(text, fontFamily, fontSize, bold, italic, strokeColor) {
|
|
11266
11359
|
const parent = this.parent;
|
|
@@ -11292,14 +11385,10 @@ class Shape {
|
|
|
11292
11385
|
if (x && y) {
|
|
11293
11386
|
if ((x !== parent.activeObj.activePoint.startX) && (y !== parent.activeObj.activePoint.startY)) {
|
|
11294
11387
|
this.updateTextFromTextArea();
|
|
11295
|
-
this.applyActObj();
|
|
11296
11388
|
}
|
|
11297
11389
|
}
|
|
11298
11390
|
else {
|
|
11299
11391
|
this.updateTextFromTextArea();
|
|
11300
|
-
this.apply(parent.activeObj.shape, parent.activeObj);
|
|
11301
|
-
parent.objColl.push(parent.activeObj);
|
|
11302
|
-
this.refreshActiveObj();
|
|
11303
11392
|
parent.textArea.style.transform = '';
|
|
11304
11393
|
parent.notify('toolbar', { prop: 'refresh-main-toolbar', onPropertyChange: false });
|
|
11305
11394
|
}
|
|
@@ -11402,7 +11491,7 @@ class Shape {
|
|
|
11402
11491
|
parent.activeObj.strokeSettings.fillColor = shapeSettings.fillColor;
|
|
11403
11492
|
switch (parent.activeObj.shape) {
|
|
11404
11493
|
case 'ellipse':
|
|
11405
|
-
parent.activeObj.activePoint.width = shapeSettings.radius
|
|
11494
|
+
parent.activeObj.activePoint.width = shapeSettings.radius * 2;
|
|
11406
11495
|
break;
|
|
11407
11496
|
case 'line':
|
|
11408
11497
|
case 'arrow':
|
|
@@ -11478,23 +11567,20 @@ class Shape {
|
|
|
11478
11567
|
}
|
|
11479
11568
|
updateTextFromTextArea() {
|
|
11480
11569
|
const parent = this.parent;
|
|
11570
|
+
let allowUndoRedo = false;
|
|
11571
|
+
const prevCropObj = extend({}, parent.cropObj, {}, true);
|
|
11572
|
+
const object = { currObj: {} };
|
|
11573
|
+
parent.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
|
|
11574
|
+
const prevObj = object['currObj'];
|
|
11575
|
+
prevObj.objColl = extend([], parent.objColl, [], true);
|
|
11576
|
+
prevObj.pointColl = extend([], parent.pointColl, [], true);
|
|
11577
|
+
prevObj.afterCropActions = extend([], this.parent.afterCropActions, [], true);
|
|
11578
|
+
const selPointCollObj = { selPointColl: null };
|
|
11579
|
+
parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
|
|
11580
|
+
value: { obj: selPointCollObj } });
|
|
11581
|
+
prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
|
|
11481
11582
|
if (parent.activeObj.keyHistory !== parent.textArea.value) {
|
|
11482
|
-
|
|
11483
|
-
const object = { currObj: {} };
|
|
11484
|
-
parent.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
|
|
11485
|
-
const prevObj = object['currObj'];
|
|
11486
|
-
prevObj.objColl = extend([], parent.objColl, [], true);
|
|
11487
|
-
prevObj.pointColl = extend([], parent.pointColl, [], true);
|
|
11488
|
-
prevObj.afterCropActions = extend([], this.parent.afterCropActions, [], true);
|
|
11489
|
-
const selPointCollObj = { selPointColl: null };
|
|
11490
|
-
parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
|
|
11491
|
-
value: { obj: selPointCollObj } });
|
|
11492
|
-
prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
|
|
11493
|
-
parent.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
|
|
11494
|
-
value: { operation: 'text', previousObj: prevObj, previousObjColl: prevObj.objColl,
|
|
11495
|
-
previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
|
|
11496
|
-
previousCropObj: prevCropObj, previousText: parent.activeObj.keyHistory,
|
|
11497
|
-
currentText: parent.textArea.value, previousFilter: null, isCircleCrop: null } });
|
|
11583
|
+
allowUndoRedo = true;
|
|
11498
11584
|
}
|
|
11499
11585
|
parent.activeObj.keyHistory = parent.textArea.value;
|
|
11500
11586
|
parent.textArea.style.display = 'none';
|
|
@@ -11518,6 +11604,19 @@ class Shape {
|
|
|
11518
11604
|
parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: parent.activeObj.activePoint, obj: parent.activeObj,
|
|
11519
11605
|
isMouseMove: null, x: null, y: null } });
|
|
11520
11606
|
this.updImgRatioForActObj();
|
|
11607
|
+
if (allowUndoRedo) {
|
|
11608
|
+
this.apply(parent.activeObj.shape, parent.activeObj);
|
|
11609
|
+
parent.objColl.push(extend({}, parent.activeObj, {}, true));
|
|
11610
|
+
parent.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
|
|
11611
|
+
value: { operation: 'text', previousObj: prevObj, previousObjColl: prevObj.objColl,
|
|
11612
|
+
previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
|
|
11613
|
+
previousCropObj: prevCropObj, previousText: parent.activeObj.keyHistory,
|
|
11614
|
+
currentText: parent.textArea.value, previousFilter: null, isCircleCrop: null } });
|
|
11615
|
+
}
|
|
11616
|
+
else {
|
|
11617
|
+
this.apply(parent.activeObj.shape, parent.activeObj);
|
|
11618
|
+
parent.objColl.push(extend({}, parent.activeObj, {}, true));
|
|
11619
|
+
}
|
|
11521
11620
|
}
|
|
11522
11621
|
iterateObjColl() {
|
|
11523
11622
|
const parent = this.parent;
|
|
@@ -12186,11 +12285,13 @@ class Shape {
|
|
|
12186
12285
|
parent.activeObj.pointColl.pop();
|
|
12187
12286
|
}
|
|
12188
12287
|
this.updatePathRatio(parent.activeObj);
|
|
12288
|
+
parent.objColl.push(parent.activeObj);
|
|
12189
12289
|
parent.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
|
|
12190
12290
|
value: { operation: 'shapeTransform', previousObj: prevObj, previousObjColl: prevObj.objColl,
|
|
12191
12291
|
previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
|
|
12192
12292
|
previousCropObj: prevCropObj, previousText: null,
|
|
12193
12293
|
currentText: null, previousFilter: null, isCircleCrop: null } });
|
|
12294
|
+
parent.objColl.pop();
|
|
12194
12295
|
parent.notify('selection', { prop: 'mouseUpEventHandler', value: { e: e } });
|
|
12195
12296
|
parent.notify('draw', { prop: 'setNewPath', value: { bool: true } });
|
|
12196
12297
|
if (parent.objColl[parent.objColl.length - 1]) {
|
|
@@ -12612,8 +12713,7 @@ class Shape {
|
|
|
12612
12713
|
const object = { arrowDimension: null };
|
|
12613
12714
|
parent.notify('draw', { prop: 'getArrowDimension', onPropertyChange: false, value: { obj: object } });
|
|
12614
12715
|
let length;
|
|
12615
|
-
|
|
12616
|
-
if (degree === 0 || degree === 180 || degree === -180) {
|
|
12716
|
+
if (Math.abs(obj.activePoint.width) > Math.abs(obj.activePoint.height)) {
|
|
12617
12717
|
length = Math.abs(obj.activePoint.width);
|
|
12618
12718
|
}
|
|
12619
12719
|
else {
|
|
@@ -12632,8 +12732,7 @@ class Shape {
|
|
|
12632
12732
|
const object = { arrowDimension: null };
|
|
12633
12733
|
this.parent.notify('draw', { prop: 'getArrowDimension', onPropertyChange: false, value: { obj: object } });
|
|
12634
12734
|
let length;
|
|
12635
|
-
|
|
12636
|
-
if (degree === 0 || degree === 180 || degree === -180) {
|
|
12735
|
+
if (Math.abs(obj.activePoint.width) > Math.abs(obj.activePoint.height)) {
|
|
12637
12736
|
length = Math.abs(obj.activePoint.width);
|
|
12638
12737
|
}
|
|
12639
12738
|
else {
|
|
@@ -14661,6 +14760,7 @@ class Transform {
|
|
|
14661
14760
|
}
|
|
14662
14761
|
drawPannImage(point) {
|
|
14663
14762
|
const parent = this.parent;
|
|
14763
|
+
const filter = this.lowerContext.filter;
|
|
14664
14764
|
const destPoints = { startX: parent.img.destLeft, startY: parent.img.destTop, width: parent.img.destWidth,
|
|
14665
14765
|
height: parent.img.destHeight };
|
|
14666
14766
|
this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
|
|
@@ -14677,6 +14777,7 @@ class Transform {
|
|
|
14677
14777
|
parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
|
|
14678
14778
|
value: { context: this.lowerContext, isSave: null, isFlip: true } });
|
|
14679
14779
|
}
|
|
14780
|
+
this.lowerContext.filter = filter;
|
|
14680
14781
|
parent.notify('draw', { prop: 'updateCurrTransState', onPropertyChange: false,
|
|
14681
14782
|
value: { type: 'reverse', isPreventDestination: null, isRotatePan: null } });
|
|
14682
14783
|
parent.img.destLeft = destPoints.startX;
|
|
@@ -16248,7 +16349,8 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
|
|
|
16248
16349
|
this.cropObj = { cropZoom: 0, defaultZoom: 0, totalPannedPoint: { x: 0, y: 0 }, totalPannedClientPoint: { x: 0, y: 0 },
|
|
16249
16350
|
totalPannedInternalPoint: { x: 0, y: 0 }, tempFlipPanPoint: { x: 0, y: 0 }, activeObj: {}, rotateFlipColl: [],
|
|
16250
16351
|
degree: 0, currFlipState: '', destPoints: { startX: 0, startY: 0, width: 0, height: 0 },
|
|
16251
|
-
srcPoints: { startX: 0, startY: 0, width: 0, height: 0 }, filter: '',
|
|
16352
|
+
srcPoints: { startX: 0, startY: 0, width: 0, height: 0 }, filter: '', isBrightAdjust: false,
|
|
16353
|
+
zoomFactor: 0, previousZoomValue: 0 };
|
|
16252
16354
|
// Stored transformations performed after cropping
|
|
16253
16355
|
/** @hidden */
|
|
16254
16356
|
this.afterCropActions = [];
|
|
@@ -16824,7 +16926,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
|
|
|
16824
16926
|
totalPannedInternalPoint: { x: 0, y: 0 }, tempFlipPanPoint: { x: 0, y: 0 }, activeObj: {},
|
|
16825
16927
|
rotateFlipColl: [], degree: 0, currFlipState: '', zoomFactor: 0, previousZoomValue: 0,
|
|
16826
16928
|
destPoints: { startX: 0, startY: 0, width: 0, height: 0 },
|
|
16827
|
-
srcPoints: { startX: 0, startY: 0, width: 0, height: 0 }, filter: '' };
|
|
16929
|
+
srcPoints: { startX: 0, startY: 0, width: 0, height: 0 }, filter: '', isBrightAdjust: false };
|
|
16828
16930
|
this.afterCropActions = [];
|
|
16829
16931
|
this.currentFilter = '';
|
|
16830
16932
|
const obj = { initialZoomValue: false };
|
|
@@ -20472,7 +20574,6 @@ class ToolbarModule {
|
|
|
20472
20574
|
}
|
|
20473
20575
|
spanElem.className = 'e-pen-stroke-width';
|
|
20474
20576
|
strokeWidthBtn.appendChild(spanElem);
|
|
20475
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
20476
20577
|
const drpDownBtn = new DropDownButton({ items: strokeWidthItems,
|
|
20477
20578
|
open: (args) => {
|
|
20478
20579
|
if (Browser.isDevice) {
|
|
@@ -21399,6 +21500,9 @@ class ToolbarModule {
|
|
|
21399
21500
|
}
|
|
21400
21501
|
updateToolbarItems() {
|
|
21401
21502
|
const parent = this.parent;
|
|
21503
|
+
if (!parent.isImageLoaded) {
|
|
21504
|
+
return;
|
|
21505
|
+
}
|
|
21402
21506
|
const selFillElem = parent.element.querySelector('.e-fill.e-template .e-dropdownbtn-preview');
|
|
21403
21507
|
const selStrokeElem = parent.element.querySelector('.e-stroke.e-template .e-dropdownbtn-preview');
|
|
21404
21508
|
const selTextStrokeElem = parent.element.querySelector('.e-text-font-color.e-template .e-dropdownbtn-preview');
|