@syncfusion/ej2-image-editor 22.1.39 → 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 +8 -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 +216 -117
- package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
- package/dist/es6/ej2-image-editor.es5.js +216 -117
- 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 +41 -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 +38 -13
- package/src/image-editor/action/selection.js +28 -17
- package/src/image-editor/action/shape.js +31 -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;
|
|
@@ -538,18 +559,11 @@ class Crop {
|
|
|
538
559
|
const parent = this.parent;
|
|
539
560
|
const obj = extend({}, parent.currSelectionPoint, null, true);
|
|
540
561
|
parent.currSelectionPoint = null;
|
|
541
|
-
const panX = parent.transform.degree
|
|
542
|
-
isReverse ? -parent.cropObj.
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
isReverse ? -parent.cropObj.totalPannedClientPoint.y : parent.cropObj.totalPannedClientPoint.y;
|
|
547
|
-
if (parent.transform.degree === 0) {
|
|
548
|
-
parent.img.destLeft += panX;
|
|
549
|
-
parent.img.destTop += panY;
|
|
550
|
-
parent.notify('transform', { prop: 'drawPannImage', value: { point: { x: panX, y: panY } } });
|
|
551
|
-
}
|
|
552
|
-
else {
|
|
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) {
|
|
553
567
|
parent.panPoint.currentPannedPoint = { x: panX, y: panY };
|
|
554
568
|
parent.notify('transform', { prop: 'drawPannedImage', value: { xDiff: panX, yDiff: panY } });
|
|
555
569
|
parent.panPoint.currentPannedPoint = { x: 0, y: 0 };
|
|
@@ -827,8 +841,6 @@ class Crop {
|
|
|
827
841
|
|
|
828
842
|
class Draw {
|
|
829
843
|
constructor(parent) {
|
|
830
|
-
this.cancelObjColl = [];
|
|
831
|
-
this.cancelPointColl = [];
|
|
832
844
|
this.isInitialLoading = false; // Specifies whether image is loaded for the first time or not (for applying initial filter)
|
|
833
845
|
this.fileName = '';
|
|
834
846
|
this.isErrorImage = false;
|
|
@@ -1048,7 +1060,6 @@ class Draw {
|
|
|
1048
1060
|
}
|
|
1049
1061
|
reset() {
|
|
1050
1062
|
this.isInitialLoading = this.isErrorImage = this.isNewPath = false;
|
|
1051
|
-
this.cancelObjColl = this.cancelPointColl = [];
|
|
1052
1063
|
this.isShapeTextInserted = false;
|
|
1053
1064
|
this.initZoomValue = null;
|
|
1054
1065
|
this.tempFilter = '';
|
|
@@ -1933,12 +1944,30 @@ class Draw {
|
|
|
1933
1944
|
canvasDraw.stroke();
|
|
1934
1945
|
canvasDraw.lineWidth = tempLineWidth;
|
|
1935
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
|
+
}
|
|
1936
1962
|
arrow(canvasDraw, start) {
|
|
1937
1963
|
const parent = this.parent;
|
|
1938
1964
|
const actPoint = parent.activeObj.activePoint;
|
|
1939
1965
|
canvasDraw.lineWidth = (parent.activeObj.strokeSettings.strokeWidth);
|
|
1940
|
-
|
|
1941
|
-
|
|
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;
|
|
1942
1971
|
this.dx = actPoint.endX - actPoint.startX;
|
|
1943
1972
|
this.dy = actPoint.endY - actPoint.startY;
|
|
1944
1973
|
canvasDraw.fillStyle = parent.activeObj.strokeSettings.strokeColor;
|
|
@@ -1973,8 +2002,11 @@ class Draw {
|
|
|
1973
2002
|
arrowSolid(canvasDraw, start) {
|
|
1974
2003
|
const parent = this.parent;
|
|
1975
2004
|
const actPoint = parent.activeObj.activePoint;
|
|
1976
|
-
|
|
1977
|
-
|
|
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;
|
|
1978
2010
|
this.dx = actPoint.endX - actPoint.startX;
|
|
1979
2011
|
this.dy = actPoint.endY - actPoint.startY;
|
|
1980
2012
|
const angle = Math.atan2(this.dy, this.dx);
|
|
@@ -2024,8 +2056,11 @@ class Draw {
|
|
|
2024
2056
|
canvasDraw.lineWidth = (parent.activeObj.strokeSettings.strokeWidth);
|
|
2025
2057
|
canvasDraw.beginPath();
|
|
2026
2058
|
canvasDraw.fillStyle = parent.activeObj.strokeSettings.strokeColor;
|
|
2027
|
-
|
|
2028
|
-
|
|
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;
|
|
2029
2064
|
this.dx = actPoint.endX - actPoint.startX;
|
|
2030
2065
|
this.dy = actPoint.endY - actPoint.startY;
|
|
2031
2066
|
const angle = Math.atan2(this.dy, this.dx);
|
|
@@ -2080,8 +2115,11 @@ class Draw {
|
|
|
2080
2115
|
arrowSquareEnd(canvasDraw) {
|
|
2081
2116
|
const parent = this.parent;
|
|
2082
2117
|
const actPoint = parent.activeObj.activePoint;
|
|
2083
|
-
|
|
2084
|
-
|
|
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;
|
|
2085
2123
|
this.dx = actPoint.endX - actPoint.startX;
|
|
2086
2124
|
this.dy = actPoint.endY - actPoint.startY;
|
|
2087
2125
|
const angle = Math.atan2(this.dy, this.dx);
|
|
@@ -2143,7 +2181,9 @@ class Draw {
|
|
|
2143
2181
|
if ((start && parent.activeObj.triangleDirection === 'left') ||
|
|
2144
2182
|
(!start && parent.activeObj.triangleDirection === 'right')) {
|
|
2145
2183
|
canvasDraw.lineWidth = (parent.activeObj.strokeSettings.strokeWidth);
|
|
2146
|
-
|
|
2184
|
+
let circleRadius = this.arrowDimension['circle']['width'];
|
|
2185
|
+
const point = this.manipulateSaveCtx(canvasDraw, circleRadius, null);
|
|
2186
|
+
circleRadius = point.x + parent.activeObj.strokeSettings.strokeWidth;
|
|
2147
2187
|
canvasDraw.beginPath();
|
|
2148
2188
|
canvasDraw.arc(actPoint.endX, actPoint.endY, circleRadius, 0, 2 * Math.PI);
|
|
2149
2189
|
canvasDraw.stroke();
|
|
@@ -2191,7 +2231,9 @@ class Draw {
|
|
|
2191
2231
|
else if ((start && parent.activeObj.triangleDirection === 'right') ||
|
|
2192
2232
|
(!start && parent.activeObj.triangleDirection === 'left')) {
|
|
2193
2233
|
canvasDraw.lineWidth = (parent.activeObj.strokeSettings.strokeWidth);
|
|
2194
|
-
|
|
2234
|
+
let circleRadius = this.arrowDimension['circle']['width'];
|
|
2235
|
+
const point = this.manipulateSaveCtx(canvasDraw, circleRadius, null);
|
|
2236
|
+
circleRadius = point.x + parent.activeObj.strokeSettings.strokeWidth;
|
|
2195
2237
|
canvasDraw.beginPath();
|
|
2196
2238
|
canvasDraw.arc(actPoint.startX, actPoint.startY, circleRadius, 0, 2 * Math.PI);
|
|
2197
2239
|
canvasDraw.stroke();
|
|
@@ -2249,7 +2291,9 @@ class Draw {
|
|
|
2249
2291
|
(!start && (parent.activeObj.end === 'circleSolid' && parent.activeObj.start === 'none'))) {
|
|
2250
2292
|
this.shapeLine(canvasDraw, actPoint.startX, actPoint.startY, actPoint.endX, actPoint.endY);
|
|
2251
2293
|
}
|
|
2252
|
-
|
|
2294
|
+
let circleRadius = this.arrowDimension['circle']['width'];
|
|
2295
|
+
const point = this.manipulateSaveCtx(canvasDraw, circleRadius, null);
|
|
2296
|
+
circleRadius = point.x + parent.activeObj.strokeSettings.strokeWidth;
|
|
2253
2297
|
this.dx = actPoint.endX - actPoint.startX;
|
|
2254
2298
|
this.dy = actPoint.endY - actPoint.startY;
|
|
2255
2299
|
canvasDraw.save();
|
|
@@ -2270,7 +2314,9 @@ class Draw {
|
|
|
2270
2314
|
!start && (parent.activeObj.end === 'circleSolid' && parent.activeObj.start === 'none')) {
|
|
2271
2315
|
this.shapeLine(canvasDraw, actPoint.startX, actPoint.startY, actPoint.endX, actPoint.endY);
|
|
2272
2316
|
}
|
|
2273
|
-
|
|
2317
|
+
let circleRadius = this.arrowDimension['circle']['width'];
|
|
2318
|
+
const point = this.manipulateSaveCtx(canvasDraw, circleRadius, null);
|
|
2319
|
+
circleRadius = point.x + parent.activeObj.strokeSettings.strokeWidth;
|
|
2274
2320
|
this.dx = actPoint.endX - actPoint.startX;
|
|
2275
2321
|
this.dy = actPoint.endY - actPoint.startY;
|
|
2276
2322
|
canvasDraw.save();
|
|
@@ -2296,8 +2342,11 @@ class Draw {
|
|
|
2296
2342
|
(parent.activeObj.end === 'bar' && (parent.activeObj.start !== 'circle' && parent.activeObj.start !== 'square'))))) {
|
|
2297
2343
|
this.shapeLine(canvasDraw, actPoint.startX, actPoint.startY, actPoint.endX, actPoint.endY);
|
|
2298
2344
|
}
|
|
2299
|
-
|
|
2300
|
-
|
|
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;
|
|
2301
2350
|
this.dx = actPoint.endX - actPoint.startX;
|
|
2302
2351
|
this.dy = actPoint.endY - actPoint.startY;
|
|
2303
2352
|
const angle = Math.atan2(this.dy, this.dx);
|
|
@@ -2318,8 +2367,11 @@ class Draw {
|
|
|
2318
2367
|
(!start && (parent.activeObj.end === 'bar' && parent.activeObj.start === 'none'))) {
|
|
2319
2368
|
this.shapeLine(canvasDraw, actPoint.startX, actPoint.startY, actPoint.endX, actPoint.endY);
|
|
2320
2369
|
}
|
|
2321
|
-
|
|
2322
|
-
|
|
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;
|
|
2323
2375
|
this.dx = actPoint.endX - actPoint.startX;
|
|
2324
2376
|
this.dy = actPoint.endY - actPoint.startY;
|
|
2325
2377
|
const angle = Math.atan2(this.dy, this.dx);
|
|
@@ -3178,8 +3230,6 @@ class Draw {
|
|
|
3178
3230
|
parent.isCropTab = isCropTab;
|
|
3179
3231
|
this.resetPanPoints();
|
|
3180
3232
|
}
|
|
3181
|
-
this.cancelObjColl = extend([], parent.objColl, [], true);
|
|
3182
|
-
this.cancelPointColl = extend([], parent.pointColl, [], true);
|
|
3183
3233
|
parent.notify('freehand-draw', { prop: 'updateFHDColl', onPropertyChange: false });
|
|
3184
3234
|
parent.isCropTab = true;
|
|
3185
3235
|
parent.isCircleCrop = false;
|
|
@@ -3488,7 +3538,7 @@ class Draw {
|
|
|
3488
3538
|
parent.afterCropActions = obj.afterCropActions;
|
|
3489
3539
|
}
|
|
3490
3540
|
this.lowerContext.filter = obj.filter;
|
|
3491
|
-
parent.notify('filter', { prop: 'setBrightnessAdjusted', onPropertyChange: false, value: { isBrightnessAdjusted:
|
|
3541
|
+
parent.notify('filter', { prop: 'setBrightnessAdjusted', onPropertyChange: false, value: { isBrightnessAdjusted: obj.isBrightAdjust } });
|
|
3492
3542
|
const isCircleCrop = parent.isCircleCrop;
|
|
3493
3543
|
let currSelectionPoint;
|
|
3494
3544
|
if (isNullOrUndefined(parent.currSelectionPoint)) {
|
|
@@ -3584,6 +3634,7 @@ class Draw {
|
|
|
3584
3634
|
this.setTransformColl(this.lowerContext, 'initial');
|
|
3585
3635
|
}
|
|
3586
3636
|
parent.notify('transform', { prop: 'setDestPointsForFlipState', onPropertyChange: false });
|
|
3637
|
+
parent.notify('filter', { prop: 'updateBrightFilter', onPropertyChange: false });
|
|
3587
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);
|
|
3588
3639
|
if (isObj) {
|
|
3589
3640
|
this.updateCurrTransState('reverse');
|
|
@@ -3911,7 +3962,7 @@ class Draw {
|
|
|
3911
3962
|
object['isInitialLoaded'] = this.isInitialLoading;
|
|
3912
3963
|
}
|
|
3913
3964
|
getFileExtensionFromURL(url) {
|
|
3914
|
-
const lastDotIndex = url.lastIndexOf(
|
|
3965
|
+
const lastDotIndex = url.lastIndexOf('.');
|
|
3915
3966
|
if (lastDotIndex !== -1) {
|
|
3916
3967
|
return url.slice(lastDotIndex + 1).toLowerCase();
|
|
3917
3968
|
}
|
|
@@ -4289,7 +4340,6 @@ class Export {
|
|
|
4289
4340
|
id: parent.element.id + '_tempCanvas', attrs: { name: 'canvasImage' }
|
|
4290
4341
|
});
|
|
4291
4342
|
const tempContext = tempCanvas.getContext('2d');
|
|
4292
|
-
tempContext.filter = this.lowerContext.filter;
|
|
4293
4343
|
tempCanvas.width = width;
|
|
4294
4344
|
tempCanvas.height = height;
|
|
4295
4345
|
const dimObj = { width: 0, height: 0 };
|
|
@@ -4298,9 +4348,9 @@ class Export {
|
|
|
4298
4348
|
const maxDimension = dimObj;
|
|
4299
4349
|
tempCanvas.style.maxWidth = maxDimension.width + 'px';
|
|
4300
4350
|
tempCanvas.style.maxHeight = maxDimension.height + 'px';
|
|
4301
|
-
tempContext.filter = this.lowerContext.filter;
|
|
4302
4351
|
const temp = this.lowerContext.filter;
|
|
4303
4352
|
parent.notify('filter', { prop: 'updateBrightFilter', onPropertyChange: false });
|
|
4353
|
+
tempContext.filter = this.lowerContext.filter;
|
|
4304
4354
|
tempContext.drawImage(parent.baseImg, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, 0, 0, width, height);
|
|
4305
4355
|
this.lowerContext.filter = temp;
|
|
4306
4356
|
if (parent.transform.degree !== 0 || parent.transform.currFlipState !== '') {
|
|
@@ -4331,6 +4381,14 @@ class Export {
|
|
|
4331
4381
|
if (parent.objColl[i].shape === 'text') {
|
|
4332
4382
|
parent.objColl[i].textSettings.fontSize *= ((ratio.width + ratio.height) / 2);
|
|
4333
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
|
+
}
|
|
4334
4392
|
parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'saveContext', obj: parent.objColl[i], isCropRatio: null,
|
|
4335
4393
|
points: null, isPreventDrag: true, saveContext: tempContext, isPreventSelection: null } });
|
|
4336
4394
|
}
|
|
@@ -4917,8 +4975,6 @@ class Filter {
|
|
|
4917
4975
|
parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false, value: { obj: selPointCollObj } });
|
|
4918
4976
|
prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
|
|
4919
4977
|
this.updateAdj(type, value);
|
|
4920
|
-
const filter = this.lowerContext.filter;
|
|
4921
|
-
this.lowerContext.filter = this.appliedFilter;
|
|
4922
4978
|
parent.notify('undo-redo', {
|
|
4923
4979
|
prop: 'updateUndoRedoColl',
|
|
4924
4980
|
onPropertyChange: false,
|
|
@@ -4935,7 +4991,6 @@ class Filter {
|
|
|
4935
4991
|
isCircleCrop: null
|
|
4936
4992
|
}
|
|
4937
4993
|
});
|
|
4938
|
-
this.lowerContext.filter = filter;
|
|
4939
4994
|
}
|
|
4940
4995
|
setFilter(type) {
|
|
4941
4996
|
const parent = this.parent;
|
|
@@ -4953,15 +5008,12 @@ class Filter {
|
|
|
4953
5008
|
value: { obj: selPointCollObj } });
|
|
4954
5009
|
prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
|
|
4955
5010
|
this.updateAdj(type, null);
|
|
4956
|
-
const filter = this.lowerContext.filter;
|
|
4957
|
-
this.lowerContext.filter = this.appliedFilter;
|
|
4958
5011
|
parent.notify('draw', { prop: 'setImageEdited', onPropertyChange: false });
|
|
4959
5012
|
parent.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
|
|
4960
5013
|
value: { operation: type, previousObj: prevObj, previousObjColl: prevObj.objColl,
|
|
4961
5014
|
previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
|
|
4962
5015
|
previousCropObj: prevCropObj, previousText: null,
|
|
4963
5016
|
currentText: null, previousFilter: prevFilter, isCircleCrop: null } });
|
|
4964
|
-
this.lowerContext.filter = filter;
|
|
4965
5017
|
}
|
|
4966
5018
|
setAdjustment(type) {
|
|
4967
5019
|
const splitWords = this.lowerContext.filter.split(' ');
|
|
@@ -5114,7 +5166,7 @@ class Filter {
|
|
|
5114
5166
|
totalPannedInternalPoint: { x: 0, y: 0 }, tempFlipPanPoint: { x: 0, y: 0 }, activeObj: {},
|
|
5115
5167
|
rotateFlipColl: [], degree: 0, currFlipState: '', zoomFactor: 0, previousZoomValue: 0,
|
|
5116
5168
|
destPoints: { startX: 0, startY: 0, width: 0, height: 0 },
|
|
5117
|
-
srcPoints: { startX: 0, startY: 0, width: 0, height: 0 }, filter: '' };
|
|
5169
|
+
srcPoints: { startX: 0, startY: 0, width: 0, height: 0 }, filter: '', isBrightAdjust: this.isBrightnessAdjusted };
|
|
5118
5170
|
obj.cropZoom = parent.transform.cropZoomFactor;
|
|
5119
5171
|
obj.defaultZoom = parent.transform.defaultZoomFactor;
|
|
5120
5172
|
obj.zoomFactor = parent.zoomSettings.zoomFactor;
|
|
@@ -5150,6 +5202,7 @@ class FreehandDrawing {
|
|
|
5150
5202
|
this.selPointColl = {};
|
|
5151
5203
|
this.currFHDIdx = 0; // Specifies id for every freehand drawing - uses while deleting
|
|
5152
5204
|
this.selPoints = [];
|
|
5205
|
+
this.dummyPoints = [];
|
|
5153
5206
|
this.tempFHDStyles = { strokeColor: null, fillColor: null, strokeWidth: null };
|
|
5154
5207
|
this.parent = parent;
|
|
5155
5208
|
this.addEventListener();
|
|
@@ -5303,6 +5356,7 @@ class FreehandDrawing {
|
|
|
5303
5356
|
this.fhdObj = { lastWidth: 0, lastVelocity: 0, time: 0, pointX: 0, pointY: 0 };
|
|
5304
5357
|
this.isFreehandDrawing = this.isFreehandPointMoved = false;
|
|
5305
5358
|
this.selPoints = [];
|
|
5359
|
+
this.dummyPoints = [];
|
|
5306
5360
|
this.freehandDownPoint = { x: 0, y: 0 };
|
|
5307
5361
|
this.selPointColl = {};
|
|
5308
5362
|
this.fhdHovIdx = null;
|
|
@@ -5351,7 +5405,12 @@ class FreehandDrawing {
|
|
|
5351
5405
|
if (parent.points[l + 1] && parent.points[l + 2] && parent.points[l + 2]) {
|
|
5352
5406
|
controlPoint1 = (this.calcCurveCP(parent.points[l + 0], parent.points[l + 1], parent.points[l + 2])).controlPoint2;
|
|
5353
5407
|
controlPoint2 = (this.calcCurveCP(parent.points[l + 1], parent.points[l + 2], parent.points[l + 3])).controlPoint1;
|
|
5354
|
-
|
|
5408
|
+
if (l === 0) {
|
|
5409
|
+
startPoint = parent.points[l];
|
|
5410
|
+
}
|
|
5411
|
+
else {
|
|
5412
|
+
startPoint = parent.points[l + 1];
|
|
5413
|
+
}
|
|
5355
5414
|
endPoint = parent.points[l + 2];
|
|
5356
5415
|
this.startDraw(context, controlPoint1, controlPoint2, startPoint, endPoint, minStrokeWidth, maxStrokeWidth);
|
|
5357
5416
|
}
|
|
@@ -5418,6 +5477,7 @@ class FreehandDrawing {
|
|
|
5418
5477
|
parent.pointColl[fhCnt].flipState = parent.transform.currFlipState;
|
|
5419
5478
|
parent.pointColl[fhCnt].id = 'pen_' + (this.currFHDIdx + 1);
|
|
5420
5479
|
parent.points = [];
|
|
5480
|
+
this.dummyPoints = [];
|
|
5421
5481
|
this.selPointColl[fhCnt] = {};
|
|
5422
5482
|
this.selPointColl[fhCnt].points = extend([], this.selPoints);
|
|
5423
5483
|
this.selPoints = [];
|
|
@@ -5465,15 +5525,21 @@ class FreehandDrawing {
|
|
|
5465
5525
|
parent.points.push({ x: x, y: y, ratioX: (x - parent.img.destLeft) / parent.img.destWidth,
|
|
5466
5526
|
ratioY: (y - parent.img.destTop) / parent.img.destHeight,
|
|
5467
5527
|
time: this.fhdObj.time });
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
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];
|
|
5473
5539
|
controlPoint1 = this.calcCurveCP(p0, p1, p2).controlPoint2;
|
|
5474
5540
|
controlPoint2 = this.calcCurveCP(p1, p2, p3).controlPoint1;
|
|
5475
|
-
startPoint =
|
|
5476
|
-
endPoint =
|
|
5541
|
+
startPoint = this.dummyPoints[1];
|
|
5542
|
+
endPoint = this.dummyPoints[2];
|
|
5477
5543
|
let minStrokeWidth = 0.5;
|
|
5478
5544
|
let maxStrokeWidth = 5;
|
|
5479
5545
|
if (!isNullOrUndefined(this.penStrokeWidth)) {
|
|
@@ -5481,6 +5547,7 @@ class FreehandDrawing {
|
|
|
5481
5547
|
}
|
|
5482
5548
|
this.startDraw(context, controlPoint1, controlPoint2, startPoint, endPoint, minStrokeWidth, maxStrokeWidth);
|
|
5483
5549
|
this.pointCounter++;
|
|
5550
|
+
this.dummyPoints.shift();
|
|
5484
5551
|
}
|
|
5485
5552
|
if (mouseDown) {
|
|
5486
5553
|
controlPoint1 = controlPoint2 = startPoint = endPoint = { x: x, y: y, time: new Date().getTime() };
|
|
@@ -5651,7 +5718,12 @@ class FreehandDrawing {
|
|
|
5651
5718
|
if (parent.points[l + 1] && parent.points[l + 2] && parent.points[l + 2]) {
|
|
5652
5719
|
controlPoint1 = (this.calcCurveCP(parent.points[l + 0], parent.points[l + 1], parent.points[l + 2])).controlPoint2;
|
|
5653
5720
|
controlPoint2 = (this.calcCurveCP(parent.points[l + 1], parent.points[l + 2], parent.points[l + 3])).controlPoint1;
|
|
5654
|
-
|
|
5721
|
+
if (l === 0) {
|
|
5722
|
+
startPoint = parent.points[l];
|
|
5723
|
+
}
|
|
5724
|
+
else {
|
|
5725
|
+
startPoint = parent.points[l + 1];
|
|
5726
|
+
}
|
|
5655
5727
|
endPoint = parent.points[l + 2];
|
|
5656
5728
|
this.startDraw(context, controlPoint1, controlPoint2, startPoint, endPoint, minStrokeWidth, maxStrokeWidth);
|
|
5657
5729
|
}
|
|
@@ -5777,8 +5849,10 @@ class FreehandDrawing {
|
|
|
5777
5849
|
if (isBlazor() && parent.events && parent.events.shapeChanging.hasDelegate === true) {
|
|
5778
5850
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
5779
5851
|
parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShape', shapeChangingArgs).then((shapeChangingArgs) => {
|
|
5780
|
-
parent.activeObj.strokeSettings.strokeColor = parent.pointColl[this.fhdSelIdx].strokeColor =
|
|
5781
|
-
|
|
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;
|
|
5782
5856
|
parent.pointColl[this.fhdSelIdx].points = shapeChangingArgs.currentShapeSettings.points;
|
|
5783
5857
|
this.freehandRedraw(this.upperContext);
|
|
5784
5858
|
parent.updateToolbar(parent.element, 'colorToolbar');
|
|
@@ -5786,8 +5860,10 @@ class FreehandDrawing {
|
|
|
5786
5860
|
}
|
|
5787
5861
|
else {
|
|
5788
5862
|
parent.trigger('shapeChanging', shapeChangingArgs);
|
|
5789
|
-
parent.activeObj.strokeSettings.strokeColor = parent.pointColl[this.fhdSelIdx].strokeColor =
|
|
5790
|
-
|
|
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;
|
|
5791
5867
|
parent.pointColl[this.fhdSelIdx].points = shapeChangingArgs.currentShapeSettings.points;
|
|
5792
5868
|
this.freehandRedraw(this.upperContext);
|
|
5793
5869
|
parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'pen',
|
|
@@ -6106,6 +6182,7 @@ class FreehandDrawing {
|
|
|
6106
6182
|
const parent = this.parent;
|
|
6107
6183
|
if (value) {
|
|
6108
6184
|
parent.points = [];
|
|
6185
|
+
this.dummyPoints = [];
|
|
6109
6186
|
parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
|
|
6110
6187
|
parent.togglePen = true;
|
|
6111
6188
|
parent.upperCanvas.style.cursor = parent.cursor = 'crosshair';
|
|
@@ -7029,12 +7106,8 @@ class Selection {
|
|
|
7029
7106
|
const previousShapeSettings = this.updatePrevShapeSettings();
|
|
7030
7107
|
const shapeResizingArgs = { action: 'resize', previousShapeSettings: previousShapeSettings };
|
|
7031
7108
|
const shapeMovingArgs = { action: 'move', previousShapeSettings: previousShapeSettings };
|
|
7032
|
-
|
|
7033
|
-
|
|
7034
|
-
}
|
|
7035
|
-
if (isNullOrUndefined(this.shapeMovingArgs)) {
|
|
7036
|
-
this.shapeMovingArgs = shapeMovingArgs;
|
|
7037
|
-
}
|
|
7109
|
+
this.shapeResizingArgs = shapeResizingArgs;
|
|
7110
|
+
this.shapeMovingArgs = shapeMovingArgs;
|
|
7038
7111
|
if (parent.activeObj.shape === 'text' && this.dragElement !== '') {
|
|
7039
7112
|
parent.notify('shape', { prop: 'updateFontRatio', onPropertyChange: false,
|
|
7040
7113
|
value: { obj: parent.activeObj, isTextArea: null } });
|
|
@@ -7233,8 +7306,8 @@ class Selection {
|
|
|
7233
7306
|
parent.activeObj.activePoint.width = parent.activeObj.activePoint.endX - parent.activeObj.activePoint.startX;
|
|
7234
7307
|
parent.activeObj.activePoint.height = parent.activeObj.activePoint.endY - parent.activeObj.activePoint.startY;
|
|
7235
7308
|
const currentShapeSettings = this.updatePrevShapeSettings();
|
|
7236
|
-
shapeResizingArgs.currentShapeSettings = currentShapeSettings;
|
|
7237
|
-
shapeMovingArgs.currentShapeSettings = currentShapeSettings;
|
|
7309
|
+
shapeResizingArgs.currentShapeSettings = this.shapeResizingArgs.currentShapeSettings = currentShapeSettings;
|
|
7310
|
+
shapeMovingArgs.currentShapeSettings = this.shapeMovingArgs.currentShapeSettings = currentShapeSettings;
|
|
7238
7311
|
if (type === 'resize') {
|
|
7239
7312
|
this.isCropSelection = false;
|
|
7240
7313
|
let splitWords;
|
|
@@ -7245,7 +7318,7 @@ class Selection {
|
|
|
7245
7318
|
this.isCropSelection = true;
|
|
7246
7319
|
}
|
|
7247
7320
|
if (!this.isCropSelection && this.parent.eventType !== 'resize' && isBlazor() && parent.events && this.parent.events.onShapeResizeStart.hasDelegate === true) {
|
|
7248
|
-
shapeResizingArgs.action = 'resize-start';
|
|
7321
|
+
shapeResizingArgs.action = this.currentDrawingShape !== '' ? 'drawing' : 'resize-start';
|
|
7249
7322
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
7250
7323
|
parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShapeResizeStart', shapeResizingArgs).then((shapeResizingArgs) => {
|
|
7251
7324
|
parent.notify('shape', { prop: 'updateShapeChangeEventArgs', onPropertyChange: false,
|
|
@@ -7253,6 +7326,9 @@ class Selection {
|
|
|
7253
7326
|
});
|
|
7254
7327
|
}
|
|
7255
7328
|
else if (!this.isCropSelection) {
|
|
7329
|
+
if (this.currentDrawingShape !== '') {
|
|
7330
|
+
shapeResizingArgs.action = 'drawing';
|
|
7331
|
+
}
|
|
7256
7332
|
parent.trigger('shapeChanging', shapeResizingArgs);
|
|
7257
7333
|
parent.notify('shape', { prop: 'updateShapeChangeEventArgs', onPropertyChange: false,
|
|
7258
7334
|
value: { shapeSettings: shapeResizingArgs.currentShapeSettings } });
|
|
@@ -7269,9 +7345,7 @@ class Selection {
|
|
|
7269
7345
|
startY: shapeResizingArgs.currentShapeSettings.startY,
|
|
7270
7346
|
width: shapeResizingArgs.currentShapeSettings.width,
|
|
7271
7347
|
height: shapeResizingArgs.currentShapeSettings.height } };
|
|
7272
|
-
|
|
7273
|
-
this.selectionResizingArgs = selectionResizingArgs;
|
|
7274
|
-
}
|
|
7348
|
+
this.selectionResizingArgs = selectionResizingArgs;
|
|
7275
7349
|
if (isBlazor() && isNullOrUndefined(this.parent.eventType) && parent.events &&
|
|
7276
7350
|
parent.events.onSelectionResizeStart.hasDelegate === true) {
|
|
7277
7351
|
selectionResizingArgs.action = 'resize-start';
|
|
@@ -9180,7 +9254,7 @@ class Selection {
|
|
|
9180
9254
|
else if (this.parent.eventType === 'resize') {
|
|
9181
9255
|
if (!this.isCropSelection && this.parent.events && this.parent.events.onShapeResizeEnd.hasDelegate === true) {
|
|
9182
9256
|
this.shapeResizingArgs.currentShapeSettings = this.updatePrevShapeSettings();
|
|
9183
|
-
this.shapeResizingArgs.action = 'resize-end';
|
|
9257
|
+
this.shapeResizingArgs.action = this.currentDrawingShape !== '' ? 'drawing' : 'resize-end';
|
|
9184
9258
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
9185
9259
|
this.parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShapeResizeEnd', this.shapeResizingArgs).then((shapeResizingArgs) => {
|
|
9186
9260
|
this.parent.notify('shape', { prop: 'updateShapeChangeEventArgs', onPropertyChange: false,
|
|
@@ -9599,7 +9673,8 @@ class Selection {
|
|
|
9599
9673
|
isApply = false;
|
|
9600
9674
|
}
|
|
9601
9675
|
else if (parent.upperCanvas.style.cursor !== 'default' && parent.upperCanvas.style.cursor !== 'grab' &&
|
|
9602
|
-
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') {
|
|
9603
9678
|
isApply = false;
|
|
9604
9679
|
}
|
|
9605
9680
|
else {
|
|
@@ -10344,9 +10419,20 @@ class Selection {
|
|
|
10344
10419
|
if (isNullOrUndefined(actObj.activePoint)) {
|
|
10345
10420
|
return;
|
|
10346
10421
|
}
|
|
10347
|
-
|
|
10348
|
-
|
|
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)) {
|
|
10349
10433
|
isInside = true;
|
|
10434
|
+
this.tempActiveObj = { activePoint: { startX: 0, startY: 0, endX: 0, endY: 0, width: 0, height: 0 },
|
|
10435
|
+
flipObjColl: [], triangle: [], triangleRatio: [] };
|
|
10350
10436
|
}
|
|
10351
10437
|
else if (actObj.shape === 'text' && this.dragElement !== '') {
|
|
10352
10438
|
isInside = true;
|
|
@@ -10436,7 +10522,9 @@ class Selection {
|
|
|
10436
10522
|
setTextBoxStylesToActObj() {
|
|
10437
10523
|
const parent = this.parent;
|
|
10438
10524
|
parent.activeObj.textSettings.fontFamily = parent.textArea.style.fontFamily;
|
|
10439
|
-
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] ?
|
|
10440
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])) :
|
|
10441
10529
|
parent.textArea.style.color;
|
|
10442
10530
|
if (parent.textArea.style.fontWeight === 'bold') {
|
|
@@ -11297,14 +11385,10 @@ class Shape {
|
|
|
11297
11385
|
if (x && y) {
|
|
11298
11386
|
if ((x !== parent.activeObj.activePoint.startX) && (y !== parent.activeObj.activePoint.startY)) {
|
|
11299
11387
|
this.updateTextFromTextArea();
|
|
11300
|
-
this.applyActObj();
|
|
11301
11388
|
}
|
|
11302
11389
|
}
|
|
11303
11390
|
else {
|
|
11304
11391
|
this.updateTextFromTextArea();
|
|
11305
|
-
this.apply(parent.activeObj.shape, parent.activeObj);
|
|
11306
|
-
parent.objColl.push(parent.activeObj);
|
|
11307
|
-
this.refreshActiveObj();
|
|
11308
11392
|
parent.textArea.style.transform = '';
|
|
11309
11393
|
parent.notify('toolbar', { prop: 'refresh-main-toolbar', onPropertyChange: false });
|
|
11310
11394
|
}
|
|
@@ -11407,7 +11491,7 @@ class Shape {
|
|
|
11407
11491
|
parent.activeObj.strokeSettings.fillColor = shapeSettings.fillColor;
|
|
11408
11492
|
switch (parent.activeObj.shape) {
|
|
11409
11493
|
case 'ellipse':
|
|
11410
|
-
parent.activeObj.activePoint.width = shapeSettings.radius
|
|
11494
|
+
parent.activeObj.activePoint.width = shapeSettings.radius * 2;
|
|
11411
11495
|
break;
|
|
11412
11496
|
case 'line':
|
|
11413
11497
|
case 'arrow':
|
|
@@ -11483,23 +11567,20 @@ class Shape {
|
|
|
11483
11567
|
}
|
|
11484
11568
|
updateTextFromTextArea() {
|
|
11485
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);
|
|
11486
11582
|
if (parent.activeObj.keyHistory !== parent.textArea.value) {
|
|
11487
|
-
|
|
11488
|
-
const object = { currObj: {} };
|
|
11489
|
-
parent.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
|
|
11490
|
-
const prevObj = object['currObj'];
|
|
11491
|
-
prevObj.objColl = extend([], parent.objColl, [], true);
|
|
11492
|
-
prevObj.pointColl = extend([], parent.pointColl, [], true);
|
|
11493
|
-
prevObj.afterCropActions = extend([], this.parent.afterCropActions, [], true);
|
|
11494
|
-
const selPointCollObj = { selPointColl: null };
|
|
11495
|
-
parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
|
|
11496
|
-
value: { obj: selPointCollObj } });
|
|
11497
|
-
prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
|
|
11498
|
-
parent.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
|
|
11499
|
-
value: { operation: 'text', previousObj: prevObj, previousObjColl: prevObj.objColl,
|
|
11500
|
-
previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
|
|
11501
|
-
previousCropObj: prevCropObj, previousText: parent.activeObj.keyHistory,
|
|
11502
|
-
currentText: parent.textArea.value, previousFilter: null, isCircleCrop: null } });
|
|
11583
|
+
allowUndoRedo = true;
|
|
11503
11584
|
}
|
|
11504
11585
|
parent.activeObj.keyHistory = parent.textArea.value;
|
|
11505
11586
|
parent.textArea.style.display = 'none';
|
|
@@ -11523,6 +11604,19 @@ class Shape {
|
|
|
11523
11604
|
parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: parent.activeObj.activePoint, obj: parent.activeObj,
|
|
11524
11605
|
isMouseMove: null, x: null, y: null } });
|
|
11525
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
|
+
}
|
|
11526
11620
|
}
|
|
11527
11621
|
iterateObjColl() {
|
|
11528
11622
|
const parent = this.parent;
|
|
@@ -12191,11 +12285,13 @@ class Shape {
|
|
|
12191
12285
|
parent.activeObj.pointColl.pop();
|
|
12192
12286
|
}
|
|
12193
12287
|
this.updatePathRatio(parent.activeObj);
|
|
12288
|
+
parent.objColl.push(parent.activeObj);
|
|
12194
12289
|
parent.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
|
|
12195
12290
|
value: { operation: 'shapeTransform', previousObj: prevObj, previousObjColl: prevObj.objColl,
|
|
12196
12291
|
previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
|
|
12197
12292
|
previousCropObj: prevCropObj, previousText: null,
|
|
12198
12293
|
currentText: null, previousFilter: null, isCircleCrop: null } });
|
|
12294
|
+
parent.objColl.pop();
|
|
12199
12295
|
parent.notify('selection', { prop: 'mouseUpEventHandler', value: { e: e } });
|
|
12200
12296
|
parent.notify('draw', { prop: 'setNewPath', value: { bool: true } });
|
|
12201
12297
|
if (parent.objColl[parent.objColl.length - 1]) {
|
|
@@ -12617,8 +12713,7 @@ class Shape {
|
|
|
12617
12713
|
const object = { arrowDimension: null };
|
|
12618
12714
|
parent.notify('draw', { prop: 'getArrowDimension', onPropertyChange: false, value: { obj: object } });
|
|
12619
12715
|
let length;
|
|
12620
|
-
|
|
12621
|
-
if (degree === 0 || degree === 180 || degree === -180) {
|
|
12716
|
+
if (Math.abs(obj.activePoint.width) > Math.abs(obj.activePoint.height)) {
|
|
12622
12717
|
length = Math.abs(obj.activePoint.width);
|
|
12623
12718
|
}
|
|
12624
12719
|
else {
|
|
@@ -12637,8 +12732,7 @@ class Shape {
|
|
|
12637
12732
|
const object = { arrowDimension: null };
|
|
12638
12733
|
this.parent.notify('draw', { prop: 'getArrowDimension', onPropertyChange: false, value: { obj: object } });
|
|
12639
12734
|
let length;
|
|
12640
|
-
|
|
12641
|
-
if (degree === 0 || degree === 180 || degree === -180) {
|
|
12735
|
+
if (Math.abs(obj.activePoint.width) > Math.abs(obj.activePoint.height)) {
|
|
12642
12736
|
length = Math.abs(obj.activePoint.width);
|
|
12643
12737
|
}
|
|
12644
12738
|
else {
|
|
@@ -14666,6 +14760,7 @@ class Transform {
|
|
|
14666
14760
|
}
|
|
14667
14761
|
drawPannImage(point) {
|
|
14668
14762
|
const parent = this.parent;
|
|
14763
|
+
const filter = this.lowerContext.filter;
|
|
14669
14764
|
const destPoints = { startX: parent.img.destLeft, startY: parent.img.destTop, width: parent.img.destWidth,
|
|
14670
14765
|
height: parent.img.destHeight };
|
|
14671
14766
|
this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
|
|
@@ -14682,6 +14777,7 @@ class Transform {
|
|
|
14682
14777
|
parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
|
|
14683
14778
|
value: { context: this.lowerContext, isSave: null, isFlip: true } });
|
|
14684
14779
|
}
|
|
14780
|
+
this.lowerContext.filter = filter;
|
|
14685
14781
|
parent.notify('draw', { prop: 'updateCurrTransState', onPropertyChange: false,
|
|
14686
14782
|
value: { type: 'reverse', isPreventDestination: null, isRotatePan: null } });
|
|
14687
14783
|
parent.img.destLeft = destPoints.startX;
|
|
@@ -16253,7 +16349,8 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
|
|
|
16253
16349
|
this.cropObj = { cropZoom: 0, defaultZoom: 0, totalPannedPoint: { x: 0, y: 0 }, totalPannedClientPoint: { x: 0, y: 0 },
|
|
16254
16350
|
totalPannedInternalPoint: { x: 0, y: 0 }, tempFlipPanPoint: { x: 0, y: 0 }, activeObj: {}, rotateFlipColl: [],
|
|
16255
16351
|
degree: 0, currFlipState: '', destPoints: { startX: 0, startY: 0, width: 0, height: 0 },
|
|
16256
|
-
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 };
|
|
16257
16354
|
// Stored transformations performed after cropping
|
|
16258
16355
|
/** @hidden */
|
|
16259
16356
|
this.afterCropActions = [];
|
|
@@ -16829,7 +16926,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
|
|
|
16829
16926
|
totalPannedInternalPoint: { x: 0, y: 0 }, tempFlipPanPoint: { x: 0, y: 0 }, activeObj: {},
|
|
16830
16927
|
rotateFlipColl: [], degree: 0, currFlipState: '', zoomFactor: 0, previousZoomValue: 0,
|
|
16831
16928
|
destPoints: { startX: 0, startY: 0, width: 0, height: 0 },
|
|
16832
|
-
srcPoints: { startX: 0, startY: 0, width: 0, height: 0 }, filter: '' };
|
|
16929
|
+
srcPoints: { startX: 0, startY: 0, width: 0, height: 0 }, filter: '', isBrightAdjust: false };
|
|
16833
16930
|
this.afterCropActions = [];
|
|
16834
16931
|
this.currentFilter = '';
|
|
16835
16932
|
const obj = { initialZoomValue: false };
|
|
@@ -20477,7 +20574,6 @@ class ToolbarModule {
|
|
|
20477
20574
|
}
|
|
20478
20575
|
spanElem.className = 'e-pen-stroke-width';
|
|
20479
20576
|
strokeWidthBtn.appendChild(spanElem);
|
|
20480
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
20481
20577
|
const drpDownBtn = new DropDownButton({ items: strokeWidthItems,
|
|
20482
20578
|
open: (args) => {
|
|
20483
20579
|
if (Browser.isDevice) {
|
|
@@ -21404,6 +21500,9 @@ class ToolbarModule {
|
|
|
21404
21500
|
}
|
|
21405
21501
|
updateToolbarItems() {
|
|
21406
21502
|
const parent = this.parent;
|
|
21503
|
+
if (!parent.isImageLoaded) {
|
|
21504
|
+
return;
|
|
21505
|
+
}
|
|
21407
21506
|
const selFillElem = parent.element.querySelector('.e-fill.e-template .e-dropdownbtn-preview');
|
|
21408
21507
|
const selStrokeElem = parent.element.querySelector('.e-stroke.e-template .e-dropdownbtn-preview');
|
|
21409
21508
|
const selTextStrokeElem = parent.element.querySelector('.e-text-font-color.e-template .e-dropdownbtn-preview');
|