@syncfusion/ej2-image-editor 22.2.10 → 23.1.36
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 +18 -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 +4272 -687
- package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
- package/dist/es6/ej2-image-editor.es5.js +4234 -640
- package/dist/es6/ej2-image-editor.es5.js.map +1 -1
- package/dist/global/ej2-image-editor.min.js +2 -2
- package/dist/global/ej2-image-editor.min.js.map +1 -1
- package/dist/global/index.d.ts +1 -1
- package/package.json +12 -12
- package/src/image-editor/action/crop.js +47 -30
- package/src/image-editor/action/draw.d.ts +16 -0
- package/src/image-editor/action/draw.js +827 -81
- package/src/image-editor/action/export.d.ts +3 -0
- package/src/image-editor/action/export.js +84 -20
- package/src/image-editor/action/filter.d.ts +0 -1
- package/src/image-editor/action/filter.js +28 -41
- package/src/image-editor/action/freehand-draw.js +45 -32
- package/src/image-editor/action/selection.d.ts +6 -0
- package/src/image-editor/action/selection.js +380 -66
- package/src/image-editor/action/shape.d.ts +8 -0
- package/src/image-editor/action/shape.js +286 -91
- package/src/image-editor/action/transform.d.ts +9 -0
- package/src/image-editor/action/transform.js +402 -52
- package/src/image-editor/action/undo-redo.d.ts +1 -0
- package/src/image-editor/action/undo-redo.js +138 -10
- package/src/image-editor/base/enum.d.ts +38 -1
- package/src/image-editor/base/enum.js +39 -0
- package/src/image-editor/base/image-editor-model.d.ts +16 -2
- package/src/image-editor/base/image-editor.d.ts +134 -7
- package/src/image-editor/base/image-editor.js +611 -69
- package/src/image-editor/base/interface.d.ts +233 -2
- package/src/image-editor/renderer/toolbar.d.ts +25 -0
- package/src/image-editor/renderer/toolbar.js +1273 -72
- package/styles/bootstrap-dark.css +68 -1
- package/styles/bootstrap.css +68 -1
- package/styles/bootstrap4.css +68 -1
- package/styles/bootstrap5-dark.css +68 -1
- package/styles/bootstrap5.css +68 -1
- package/styles/fabric-dark.css +68 -1
- package/styles/fabric.css +68 -1
- package/styles/fluent-dark.css +68 -1
- package/styles/fluent.css +68 -1
- package/styles/highcontrast-light.css +70 -3
- package/styles/highcontrast.css +69 -7
- package/styles/image-editor/_bootstrap-dark-definition.scss +1 -0
- package/styles/image-editor/_bootstrap-definition.scss +1 -0
- package/styles/image-editor/_bootstrap4-definition.scss +1 -0
- package/styles/image-editor/_bootstrap5-definition.scss +1 -0
- package/styles/image-editor/_fabric-dark-definition.scss +1 -0
- package/styles/image-editor/_fabric-definition.scss +1 -0
- package/styles/image-editor/_fluent-definition.scss +1 -0
- package/styles/image-editor/_fusionnew-definition.scss +1 -0
- package/styles/image-editor/_highcontrast-definition.scss +2 -1
- package/styles/image-editor/_highcontrast-light-definition.scss +2 -1
- package/styles/image-editor/_layout.scss +92 -0
- package/styles/image-editor/_material-dark-definition.scss +1 -0
- package/styles/image-editor/_material-definition.scss +1 -0
- package/styles/image-editor/_material3-definition.scss +2 -1
- package/styles/image-editor/_tailwind-definition.scss +1 -0
- package/styles/image-editor/_theme.scss +4 -2
- package/styles/image-editor/bootstrap-dark.css +68 -1
- package/styles/image-editor/bootstrap-dark.scss +1 -1
- package/styles/image-editor/bootstrap.css +68 -1
- package/styles/image-editor/bootstrap.scss +1 -1
- package/styles/image-editor/bootstrap4.css +68 -1
- package/styles/image-editor/bootstrap4.scss +1 -1
- package/styles/image-editor/bootstrap5-dark.css +68 -1
- package/styles/image-editor/bootstrap5-dark.scss +1 -1
- package/styles/image-editor/bootstrap5.css +68 -1
- package/styles/image-editor/bootstrap5.scss +1 -1
- package/styles/image-editor/fabric-dark.css +68 -1
- package/styles/image-editor/fabric-dark.scss +1 -1
- package/styles/image-editor/fabric.css +68 -1
- package/styles/image-editor/fabric.scss +1 -1
- package/styles/image-editor/fluent-dark.css +68 -1
- package/styles/image-editor/fluent-dark.scss +1 -1
- package/styles/image-editor/fluent.css +68 -1
- package/styles/image-editor/fluent.scss +1 -1
- package/styles/image-editor/highcontrast-light.css +70 -3
- package/styles/image-editor/highcontrast-light.scss +1 -1
- package/styles/image-editor/highcontrast.css +69 -7
- package/styles/image-editor/highcontrast.scss +1 -1
- package/styles/image-editor/icons/_bootstrap-dark.scss +1 -0
- package/styles/image-editor/icons/_bootstrap.scss +1 -0
- package/styles/image-editor/icons/_bootstrap4.scss +1 -0
- package/styles/image-editor/icons/_bootstrap5.scss +1 -0
- package/styles/image-editor/icons/_fabric-dark.scss +1 -0
- package/styles/image-editor/icons/_fabric.scss +1 -0
- package/styles/image-editor/icons/_fluent.scss +1 -0
- package/styles/image-editor/icons/_fusionnew.scss +1 -0
- package/styles/image-editor/icons/_highcontrast-light.scss +1 -0
- package/styles/image-editor/icons/_highcontrast.scss +1 -0
- package/styles/image-editor/icons/_material-dark.scss +1 -0
- package/styles/image-editor/icons/_material.scss +1 -0
- package/styles/image-editor/icons/_material3.scss +1 -0
- package/styles/image-editor/icons/_tailwind.scss +1 -0
- package/styles/image-editor/material-dark.css +68 -2
- package/styles/image-editor/material-dark.scss +1 -1
- package/styles/image-editor/material.css +68 -2
- package/styles/image-editor/material.scss +1 -1
- package/styles/image-editor/material3-dark.css +73 -4
- package/styles/image-editor/material3-dark.scss +1 -1
- package/styles/image-editor/material3.css +73 -4
- package/styles/image-editor/material3.scss +1 -1
- package/styles/image-editor/tailwind-dark.css +68 -2
- package/styles/image-editor/tailwind-dark.scss +1 -1
- package/styles/image-editor/tailwind.css +68 -2
- package/styles/image-editor/tailwind.scss +1 -1
- package/styles/material-dark.css +68 -2
- package/styles/material.css +68 -2
- package/styles/material3-dark.css +73 -4
- package/styles/material3-dark.scss +1 -1
- package/styles/material3.css +73 -4
- package/styles/material3.scss +1 -1
- package/styles/tailwind-dark.css +68 -2
- package/styles/tailwind.css +68 -2
|
@@ -21,9 +21,13 @@ var Draw = /** @class */ (function () {
|
|
|
21
21
|
this.isImageEdited = false;
|
|
22
22
|
this.isFileChanged = false;
|
|
23
23
|
this.isNewPath = false;
|
|
24
|
+
this.isResizeSelect = false;
|
|
24
25
|
this.arrowDimension = { bar: { width: 10, height: 32, ratioX: null, ratioY: null },
|
|
25
26
|
arrow: { width: 24, height: 24, ratioX: null, ratioY: null }, arrowSolid: { width: 32, height: 32, ratioX: null, ratioY: null },
|
|
26
27
|
circle: { width: 10, height: 10, ratioX: null, ratioY: null }, square: { width: 20, height: 20, ratioX: null, ratioY: null } };
|
|
28
|
+
this.tempFrame = 'none';
|
|
29
|
+
this.origDim = { width: 0, height: 0 };
|
|
30
|
+
this.isImageApply = false;
|
|
27
31
|
this.parent = parent;
|
|
28
32
|
this.addEventListener();
|
|
29
33
|
}
|
|
@@ -66,7 +70,7 @@ var Draw = /** @class */ (function () {
|
|
|
66
70
|
this.setTransform(args.value['context'], args.value['value'], args.value['isReverse']);
|
|
67
71
|
break;
|
|
68
72
|
case 'render-image':
|
|
69
|
-
this.renderImage(args.value['isMouseWheel']);
|
|
73
|
+
this.renderImage(args.value['isMouseWheel'], args.value['isPreventClearRect'], args.value['isFrame']);
|
|
70
74
|
break;
|
|
71
75
|
case 'draw-image-to-canvas':
|
|
72
76
|
this.drawImgToCanvas(args.value['dimension']);
|
|
@@ -202,6 +206,36 @@ var Draw = /** @class */ (function () {
|
|
|
202
206
|
case 'moveToSelectionRange':
|
|
203
207
|
this.moveToSelectionRange(args.value['type'], args.value['activeObj']);
|
|
204
208
|
break;
|
|
209
|
+
case 'setResizeSelect':
|
|
210
|
+
this.isResizeSelect = args.value['bool'];
|
|
211
|
+
break;
|
|
212
|
+
case 'applyFrame':
|
|
213
|
+
this.applyFrame(args.value['ctx'], args.value['frame'], args.value['preventImg']);
|
|
214
|
+
break;
|
|
215
|
+
case 'getTempFrame':
|
|
216
|
+
args.value['obj']['tempFrame'] = this.tempFrame;
|
|
217
|
+
break;
|
|
218
|
+
case 'drawImage':
|
|
219
|
+
this.drawImage();
|
|
220
|
+
break;
|
|
221
|
+
case 'setTempFrame':
|
|
222
|
+
this.tempFrame = args.value['frame'];
|
|
223
|
+
break;
|
|
224
|
+
case 'downScaleImgCanvas':
|
|
225
|
+
this.downScaleImgCanvas(args.value['ctx'], args.value['isImgAnnotation'], args.value['isHFlip'], args.value['isVFlip']);
|
|
226
|
+
break;
|
|
227
|
+
case 'downScale':
|
|
228
|
+
this.downScale(args.value['canvas'], args.value['width'], args.value['height']);
|
|
229
|
+
break;
|
|
230
|
+
case 'resetFrameZoom':
|
|
231
|
+
this.resetFrameZoom();
|
|
232
|
+
break;
|
|
233
|
+
case 'triggerFrameChange':
|
|
234
|
+
args.value['obj']['frameChangeEventArgs'] = this.triggerFrameChange(args.value['prevFrameSettings']);
|
|
235
|
+
break;
|
|
236
|
+
case 'setImageApply':
|
|
237
|
+
this.isImageApply = args.value['bool'];
|
|
238
|
+
break;
|
|
205
239
|
}
|
|
206
240
|
};
|
|
207
241
|
Draw.prototype.getModuleName = function () {
|
|
@@ -220,10 +254,13 @@ var Draw = /** @class */ (function () {
|
|
|
220
254
|
}
|
|
221
255
|
};
|
|
222
256
|
Draw.prototype.reset = function () {
|
|
223
|
-
this.isInitialLoading = this.isErrorImage = this.isNewPath = false;
|
|
257
|
+
this.isInitialLoading = this.isErrorImage = this.isNewPath = this.isResizeSelect = false;
|
|
224
258
|
this.isShapeTextInserted = false;
|
|
259
|
+
this.tempFrame = 'none';
|
|
260
|
+
this.isImageApply = false;
|
|
225
261
|
this.initZoomValue = null;
|
|
226
262
|
this.tempFilter = '';
|
|
263
|
+
this.origDim = { width: 0, height: 0 };
|
|
227
264
|
this.currSelPoint = null;
|
|
228
265
|
this.isRotateZoom = false;
|
|
229
266
|
this.tempAdjValue = '';
|
|
@@ -239,6 +276,9 @@ var Draw = /** @class */ (function () {
|
|
|
239
276
|
arrow: { width: 24, height: 24, ratioX: null, ratioY: null }, arrowSolid: { width: 32, height: 32, ratioX: null, ratioY: null },
|
|
240
277
|
circle: { width: 10, height: 10, ratioX: null, ratioY: null }, square: { width: 20, height: 20, ratioX: null, ratioY: null } };
|
|
241
278
|
};
|
|
279
|
+
Draw.prototype.drawImage = function () {
|
|
280
|
+
this.applyFrame(this.lowerContext, this.parent.frameObj.type);
|
|
281
|
+
};
|
|
242
282
|
Draw.prototype.drawObject = function (canvas, obj, isCropRatio, points, isPreventDrag, saveContext, isPreventSelection) {
|
|
243
283
|
var parent = this.parent;
|
|
244
284
|
var actPoint = parent.activeObj.activePoint;
|
|
@@ -342,7 +382,7 @@ var Draw = /** @class */ (function () {
|
|
|
342
382
|
Draw.prototype.setDragLimit = function () {
|
|
343
383
|
var parent = this.parent;
|
|
344
384
|
var actPoint = parent.activeObj.activePoint;
|
|
345
|
-
if (actPoint && parent.activeObj.rotatedAngle === 0) {
|
|
385
|
+
if (actPoint && parent.activeObj.shape !== 'image' && parent.activeObj.shape !== 'line' && parent.activeObj.rotatedAngle === 0) {
|
|
346
386
|
if (actPoint.startX < parent.img.destLeft) {
|
|
347
387
|
actPoint.startX = parent.img.destLeft;
|
|
348
388
|
actPoint.endX = actPoint.startX + actPoint.width;
|
|
@@ -501,22 +541,22 @@ var Draw = /** @class */ (function () {
|
|
|
501
541
|
parent.activeObj.activePoint.startY += diffY;
|
|
502
542
|
parent.activeObj.activePoint.endY += diffY;
|
|
503
543
|
if (parent.activeObj.activePoint.startX < (parent.img.destLeft >= 7.5 ? parent.img.destLeft : 7.5)) {
|
|
504
|
-
var diff = ((parent.img.destLeft >= 7.5 ? parent.img.destLeft : 0) - parent.activeObj.activePoint.startX)
|
|
544
|
+
var diff = ((parent.img.destLeft >= 7.5 ? parent.img.destLeft : 0) - parent.activeObj.activePoint.startX);
|
|
505
545
|
parent.activeObj.activePoint.startX += diff;
|
|
506
546
|
parent.activeObj.activePoint.endX += diff;
|
|
507
547
|
}
|
|
508
548
|
else if (parent.activeObj.activePoint.endX > parent.img.destLeft + parent.img.destWidth) {
|
|
509
|
-
var diff = (parent.activeObj.activePoint.endX - (parent.img.destLeft + parent.img.destWidth))
|
|
549
|
+
var diff = (parent.activeObj.activePoint.endX - (parent.img.destLeft + parent.img.destWidth));
|
|
510
550
|
parent.activeObj.activePoint.startX -= diff;
|
|
511
551
|
parent.activeObj.activePoint.endX -= diff;
|
|
512
552
|
}
|
|
513
|
-
if (parent.activeObj.activePoint.startY < (parent.img.destTop
|
|
514
|
-
var diff = ((parent.img.destTop
|
|
553
|
+
if (parent.activeObj.activePoint.startY < (parent.img.destTop >= 7.5 ? parent.img.destTop : 7.5)) {
|
|
554
|
+
var diff = ((parent.img.destTop >= 7.5 ? parent.img.destTop : 0) - parent.activeObj.activePoint.startY);
|
|
515
555
|
parent.activeObj.activePoint.startY += diff;
|
|
516
556
|
parent.activeObj.activePoint.endY += diff;
|
|
517
557
|
}
|
|
518
558
|
else if (parent.activeObj.activePoint.endY > parent.img.destTop + parent.img.destHeight) {
|
|
519
|
-
var diff = (parent.activeObj.activePoint.endY - (parent.img.destTop + parent.img.destHeight))
|
|
559
|
+
var diff = (parent.activeObj.activePoint.endY - (parent.img.destTop + parent.img.destHeight));
|
|
520
560
|
parent.activeObj.activePoint.startY -= diff;
|
|
521
561
|
parent.activeObj.activePoint.endY -= diff;
|
|
522
562
|
}
|
|
@@ -725,7 +765,7 @@ var Draw = /** @class */ (function () {
|
|
|
725
765
|
}
|
|
726
766
|
if (parent.currObjType.shape.toLowerCase() === 'rectangle' || parent.currObjType.shape.toLowerCase() === 'ellipse'
|
|
727
767
|
|| parent.currObjType.shape.toLowerCase() === 'line' || parent.activeObj.shape === 'arrow' ||
|
|
728
|
-
parent.activeObj.shape === 'path') {
|
|
768
|
+
parent.activeObj.shape === 'path' || parent.activeObj.shape === 'image') {
|
|
729
769
|
parent.activeObj.shape = parent.currObjType.shape;
|
|
730
770
|
}
|
|
731
771
|
canvasDraw.strokeStyle = parent.activeObj.strokeSettings.strokeColor;
|
|
@@ -855,6 +895,12 @@ var Draw = /** @class */ (function () {
|
|
|
855
895
|
case 'text':
|
|
856
896
|
this.shapeText(canvasDraw);
|
|
857
897
|
break;
|
|
898
|
+
case 'image':
|
|
899
|
+
this.shapeImage(canvasDraw);
|
|
900
|
+
if (isNullOrUndefined(isPreventSelection) && canvasDraw === this.upperContext) {
|
|
901
|
+
this.drawOuterSelection(canvasDraw);
|
|
902
|
+
}
|
|
903
|
+
break;
|
|
858
904
|
case 'crop-square':
|
|
859
905
|
case 'crop-3:4':
|
|
860
906
|
case 'crop-4:3':
|
|
@@ -1544,7 +1590,70 @@ var Draw = /** @class */ (function () {
|
|
|
1544
1590
|
parent.activeObj.rotatedAngle = angle;
|
|
1545
1591
|
}
|
|
1546
1592
|
};
|
|
1593
|
+
Draw.prototype.shapeImage = function (canvasDraw) {
|
|
1594
|
+
var parent = this.parent;
|
|
1595
|
+
var ctx = parent.activeObj.imageCanvas.getContext('2d');
|
|
1596
|
+
if (canvasDraw === this.lowerContext && this.isImageApply) {
|
|
1597
|
+
var dimObj = { width: 0, height: 0 };
|
|
1598
|
+
parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
|
|
1599
|
+
value: { width: parent.activeObj.imageElement.width, height: parent.activeObj.imageElement.height, obj: dimObj, isImgShape: null } });
|
|
1600
|
+
if (parent.activeObj.activePoint.width < (dimObj['width'] / 5) || parent.activeObj.activePoint.height < (dimObj['height'] / 5)) {
|
|
1601
|
+
ctx.clearRect(0, 0, parent.activeObj.imageCanvas.width, parent.activeObj.imageCanvas.height);
|
|
1602
|
+
parent.notify('draw', { prop: 'downScaleImgCanvas', onPropertyChange: false,
|
|
1603
|
+
value: { ctx: ctx, isImgAnnotation: true, isHFlip: null, isVFlip: null } });
|
|
1604
|
+
parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate' } });
|
|
1605
|
+
this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
|
|
1606
|
+
parent.notify('selection', { prop: 'setImageClarity', onPropertyChange: false, value: { bool: false } });
|
|
1607
|
+
this.isImageApply = false;
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
var imgPoint = { startX: 0, startY: 0, width: 0, height: 0 };
|
|
1611
|
+
imgPoint.width = parent.activeObj.activePoint.width;
|
|
1612
|
+
imgPoint.height = parent.activeObj.activePoint.height;
|
|
1613
|
+
if (parent.activeObj.flipObjColl.length === 4) {
|
|
1614
|
+
parent.activeObj.flipObjColl = [];
|
|
1615
|
+
parent.activeObj.shapeFlip = '';
|
|
1616
|
+
}
|
|
1617
|
+
for (var j = 0, len = parent.activeObj.flipObjColl.length; j < len; j++) {
|
|
1618
|
+
if (parent.activeObj.flipObjColl[j].toLowerCase() === 'horizontal') {
|
|
1619
|
+
canvasDraw.translate(canvasDraw.canvas.width, 0);
|
|
1620
|
+
canvasDraw.scale(-1, 1);
|
|
1621
|
+
parent.activeObj.activePoint = this.updateActPoint('horizontal', canvasDraw);
|
|
1622
|
+
}
|
|
1623
|
+
else if (parent.activeObj.flipObjColl[j].toLowerCase() === 'vertical') {
|
|
1624
|
+
canvasDraw.translate(0, canvasDraw.canvas.height);
|
|
1625
|
+
canvasDraw.scale(1, -1);
|
|
1626
|
+
parent.activeObj.activePoint = this.updateActPoint('vertical', canvasDraw);
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
imgPoint.startX = ((parent.activeObj.activePoint.width - imgPoint.width) / 2) + parent.activeObj.activePoint.startX;
|
|
1630
|
+
imgPoint.startY = ((parent.activeObj.activePoint.height - imgPoint.height) / 2) + parent.activeObj.activePoint.startY;
|
|
1631
|
+
var temp = canvasDraw.globalAlpha;
|
|
1632
|
+
canvasDraw.globalAlpha = parent.activeObj.imageTransparency;
|
|
1633
|
+
if (parent.activeObj.shapeDegree !== parent.transform.degree) {
|
|
1634
|
+
this.rotateImage(canvasDraw);
|
|
1635
|
+
}
|
|
1636
|
+
else {
|
|
1637
|
+
canvasDraw.drawImage(parent.activeObj.imageCanvas, imgPoint.startX, imgPoint.startY, imgPoint.width, imgPoint.height);
|
|
1638
|
+
}
|
|
1639
|
+
canvasDraw.globalAlpha = temp;
|
|
1640
|
+
for (var k = 0, len = parent.activeObj.flipObjColl.length; k < len; k++) {
|
|
1641
|
+
if (parent.activeObj.flipObjColl[k].toLowerCase() === 'horizontal') {
|
|
1642
|
+
canvasDraw.translate(canvasDraw.canvas.width, 0);
|
|
1643
|
+
canvasDraw.scale(-1, 1);
|
|
1644
|
+
parent.activeObj.activePoint = this.updateActPoint('horizontal', canvasDraw);
|
|
1645
|
+
}
|
|
1646
|
+
else if (parent.activeObj.flipObjColl[k].toLowerCase() === 'vertical') {
|
|
1647
|
+
canvasDraw.translate(0, canvasDraw.canvas.height);
|
|
1648
|
+
canvasDraw.scale(1, -1);
|
|
1649
|
+
parent.activeObj.activePoint = this.updateActPoint('vertical', canvasDraw);
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
parent.currObjType.isText = false;
|
|
1653
|
+
};
|
|
1547
1654
|
Draw.prototype.shapeText = function (canvasDraw) {
|
|
1655
|
+
var filter = canvasDraw.filter;
|
|
1656
|
+
canvasDraw.filter = 'none';
|
|
1548
1657
|
var parent = this.parent;
|
|
1549
1658
|
var actPoint = parent.activeObj.activePoint;
|
|
1550
1659
|
var rows = parent.activeObj.keyHistory.split('\n');
|
|
@@ -1617,6 +1726,7 @@ var Draw = /** @class */ (function () {
|
|
|
1617
1726
|
}
|
|
1618
1727
|
}
|
|
1619
1728
|
}
|
|
1729
|
+
canvasDraw.filter = filter;
|
|
1620
1730
|
parent.currObjType.isText = false;
|
|
1621
1731
|
};
|
|
1622
1732
|
Draw.prototype.updateActPoint = function (degree, canvasDraw) {
|
|
@@ -1651,6 +1761,66 @@ var Draw = /** @class */ (function () {
|
|
|
1651
1761
|
}
|
|
1652
1762
|
return actPoint;
|
|
1653
1763
|
};
|
|
1764
|
+
Draw.prototype.rotateImage = function (canvasDraw) {
|
|
1765
|
+
var parent = this.parent;
|
|
1766
|
+
var degree;
|
|
1767
|
+
if (parent.activeObj.shapeDegree === 0) {
|
|
1768
|
+
degree = parent.transform.degree;
|
|
1769
|
+
}
|
|
1770
|
+
else {
|
|
1771
|
+
degree = parent.transform.degree - parent.activeObj.shapeDegree;
|
|
1772
|
+
}
|
|
1773
|
+
if (degree === -450) {
|
|
1774
|
+
degree = -90;
|
|
1775
|
+
}
|
|
1776
|
+
if (degree < 0) {
|
|
1777
|
+
degree = 360 + degree;
|
|
1778
|
+
}
|
|
1779
|
+
var imgPoint = { startX: 0, startY: 0, width: 0, height: 0 };
|
|
1780
|
+
imgPoint.width = degree % 90 === 0 && degree % 180 !== 0 ? parent.activeObj.activePoint.height : parent.activeObj.activePoint.width;
|
|
1781
|
+
imgPoint.height = degree % 90 === 0 && degree % 180 !== 0 ? parent.activeObj.activePoint.width :
|
|
1782
|
+
parent.activeObj.activePoint.height;
|
|
1783
|
+
imgPoint.startX = parent.activeObj.activePoint.startX;
|
|
1784
|
+
imgPoint.startY = parent.activeObj.activePoint.startY;
|
|
1785
|
+
var startX = imgPoint.startX;
|
|
1786
|
+
var startY = imgPoint.startY;
|
|
1787
|
+
if (degree % 360 === 0 && (parent.transform.degree !== -360 || parent.transform.currFlipState === '')) {
|
|
1788
|
+
canvasDraw.drawImage(parent.activeObj.imageCanvas, imgPoint.startX, imgPoint.startY, imgPoint.width, imgPoint.height);
|
|
1789
|
+
}
|
|
1790
|
+
else if (degree % 90 === 0 && degree % 180 !== 0) {
|
|
1791
|
+
canvasDraw.translate(parent.lowerCanvas.width / 2, parent.lowerCanvas.height / 2);
|
|
1792
|
+
canvasDraw.rotate(Math.PI / 180 * degree);
|
|
1793
|
+
canvasDraw.translate(-parent.lowerCanvas.height / 2, -parent.lowerCanvas.width / 2);
|
|
1794
|
+
if (degree % 90 === 0 && degree % 270 !== 0) {
|
|
1795
|
+
startY = parent.lowerCanvas.width - (parent.activeObj.activePoint.startX + parent.activeObj.activePoint.width);
|
|
1796
|
+
startY += ((parent.activeObj.activePoint.width - imgPoint.height) / 2);
|
|
1797
|
+
startX = imgPoint.startY;
|
|
1798
|
+
}
|
|
1799
|
+
else if (degree % 270 === 0) {
|
|
1800
|
+
startX = parent.lowerCanvas.height - (parent.activeObj.activePoint.startY + parent.activeObj.activePoint.height);
|
|
1801
|
+
startX += ((parent.activeObj.activePoint.height - imgPoint.width) / 2);
|
|
1802
|
+
startY = imgPoint.startX;
|
|
1803
|
+
}
|
|
1804
|
+
canvasDraw.drawImage(parent.activeObj.imageCanvas, startX, startY, imgPoint.width, imgPoint.height);
|
|
1805
|
+
canvasDraw.translate(parent.lowerCanvas.height / 2, parent.lowerCanvas.width / 2);
|
|
1806
|
+
canvasDraw.rotate(Math.PI / 180 * -degree);
|
|
1807
|
+
canvasDraw.translate(-parent.lowerCanvas.width / 2, -parent.lowerCanvas.height / 2);
|
|
1808
|
+
}
|
|
1809
|
+
else {
|
|
1810
|
+
canvasDraw.translate(parent.lowerCanvas.width / 2, parent.lowerCanvas.height / 2);
|
|
1811
|
+
canvasDraw.rotate(Math.PI / 180 * degree);
|
|
1812
|
+
startX = parent.lowerCanvas.width - (imgPoint.startX + imgPoint.width);
|
|
1813
|
+
startY = parent.lowerCanvas.height - (imgPoint.startY + imgPoint.height);
|
|
1814
|
+
canvasDraw.translate(-parent.lowerCanvas.width / 2, -parent.lowerCanvas.height / 2);
|
|
1815
|
+
canvasDraw.drawImage(parent.activeObj.imageCanvas, startX, startY, imgPoint.width, imgPoint.height);
|
|
1816
|
+
canvasDraw.translate(parent.lowerCanvas.width / 2, parent.lowerCanvas.height / 2);
|
|
1817
|
+
canvasDraw.rotate(Math.PI / 180 * -degree);
|
|
1818
|
+
canvasDraw.translate(-parent.lowerCanvas.width / 2, -parent.lowerCanvas.height / 2);
|
|
1819
|
+
}
|
|
1820
|
+
if (parent.transform.degree === 360 || parent.transform.degree === -360) {
|
|
1821
|
+
parent.transform.degree = 0;
|
|
1822
|
+
}
|
|
1823
|
+
};
|
|
1654
1824
|
Draw.prototype.rotateText = function (canvasDraw) {
|
|
1655
1825
|
var parent = this.parent;
|
|
1656
1826
|
var startX = parent.activeObj.activePoint.startX;
|
|
@@ -1755,7 +1925,7 @@ var Draw = /** @class */ (function () {
|
|
|
1755
1925
|
if (parent.transform.degree % 90 === 0 && parent.transform.degree % 180 !== 0) {
|
|
1756
1926
|
var obj = { width: 0, height: 0 };
|
|
1757
1927
|
parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
|
|
1758
|
-
value: { width: parent.img.srcHeight, height: parent.img.srcWidth, obj: obj } });
|
|
1928
|
+
value: { width: parent.img.srcHeight, height: parent.img.srcWidth, obj: obj, isImgShape: null } });
|
|
1759
1929
|
maxDimension = obj;
|
|
1760
1930
|
if (this.isRotateZoom) {
|
|
1761
1931
|
maxDimension.width += (maxDimension.width * parent.transform.zoomFactor);
|
|
@@ -1771,7 +1941,7 @@ var Draw = /** @class */ (function () {
|
|
|
1771
1941
|
else {
|
|
1772
1942
|
var obj = { width: 0, height: 0 };
|
|
1773
1943
|
parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
|
|
1774
|
-
value: { width: parent.img.srcWidth, height: parent.img.srcHeight, obj: obj } });
|
|
1944
|
+
value: { width: parent.img.srcWidth, height: parent.img.srcHeight, obj: obj, isImgShape: null } });
|
|
1775
1945
|
maxDimension = obj;
|
|
1776
1946
|
if (this.isRotateZoom) {
|
|
1777
1947
|
maxDimension.width += (maxDimension.width * parent.transform.zoomFactor);
|
|
@@ -1795,12 +1965,12 @@ var Draw = /** @class */ (function () {
|
|
|
1795
1965
|
this.setDestPoints();
|
|
1796
1966
|
}
|
|
1797
1967
|
}
|
|
1798
|
-
this.currTransState(type, null, null, isRotatePan);
|
|
1799
|
-
if (parent.transform.degree === 0 && parent.transform.currFlipState === '') {
|
|
1800
|
-
parent.img.destLeft = destLeft;
|
|
1801
|
-
parent.img.destTop = destTop;
|
|
1802
|
-
}
|
|
1803
1968
|
if (parent.isCircleCrop || (parent.currSelectionPoint && parent.currSelectionPoint.shape === 'crop-circle')) {
|
|
1969
|
+
this.currTransState(type, true, null, isRotatePan);
|
|
1970
|
+
if (parent.transform.degree === 0 && parent.transform.currFlipState === '') {
|
|
1971
|
+
parent.img.destLeft = destLeft;
|
|
1972
|
+
parent.img.destTop = destTop;
|
|
1973
|
+
}
|
|
1804
1974
|
if (isRotatePan) {
|
|
1805
1975
|
parent.img.destLeft += parent.panPoint.totalPannedClientPoint.x;
|
|
1806
1976
|
parent.img.destTop +=
|
|
@@ -1814,6 +1984,13 @@ var Draw = /** @class */ (function () {
|
|
|
1814
1984
|
parent.panPoint.totalPannedClientPoint.y;
|
|
1815
1985
|
}
|
|
1816
1986
|
}
|
|
1987
|
+
else {
|
|
1988
|
+
this.currTransState(type, null, null, isRotatePan);
|
|
1989
|
+
if (parent.transform.degree === 0 && parent.transform.currFlipState === '') {
|
|
1990
|
+
parent.img.destLeft = destLeft;
|
|
1991
|
+
parent.img.destTop = destTop;
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1817
1994
|
};
|
|
1818
1995
|
Draw.prototype.currTransState = function (type, isPreventDimension, context, isPreventCircleCrop) {
|
|
1819
1996
|
var parent = this.parent;
|
|
@@ -1900,33 +2077,33 @@ var Draw = /** @class */ (function () {
|
|
|
1900
2077
|
this.isInitialLoading = false;
|
|
1901
2078
|
}
|
|
1902
2079
|
var temp = this.lowerContext.filter;
|
|
1903
|
-
parent.notify('filter', { prop: 'updateBrightFilter', onPropertyChange: false });
|
|
1904
2080
|
this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
|
|
1905
|
-
this.
|
|
2081
|
+
this.drawImage();
|
|
1906
2082
|
if ((parent.currSelectionPoint && parent.currSelectionPoint.shape === 'crop-circle') || parent.isCircleCrop) {
|
|
1907
2083
|
parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
|
|
1908
2084
|
value: { context: this.lowerContext, isSave: null, isFlip: null } });
|
|
1909
2085
|
}
|
|
1910
2086
|
this.lowerContext.filter = temp;
|
|
1911
2087
|
};
|
|
1912
|
-
Draw.prototype.renderImage = function (isMouseWheel) {
|
|
2088
|
+
Draw.prototype.renderImage = function (isMouseWheel, isPreventClearRect, isFrame) {
|
|
1913
2089
|
var parent = this.parent;
|
|
1914
2090
|
var temp = this.lowerContext.filter;
|
|
1915
2091
|
parent.notify('shape', { prop: 'applyActObj', onPropertyChange: false, value: { isMouseDown: null } });
|
|
1916
|
-
|
|
1917
|
-
|
|
2092
|
+
if (isNullOrUndefined(isPreventClearRect)) {
|
|
2093
|
+
this.upperContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
|
|
2094
|
+
this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
|
|
2095
|
+
}
|
|
1918
2096
|
if (isMouseWheel) {
|
|
1919
2097
|
this.setTransformColl(this.lowerContext, 'initial');
|
|
1920
2098
|
}
|
|
1921
2099
|
else {
|
|
1922
|
-
if (parent.transform.zoomFactor
|
|
2100
|
+
if (parent.transform.zoomFactor !== 0) {
|
|
1923
2101
|
this.isRotateZoom = true;
|
|
1924
2102
|
}
|
|
1925
2103
|
this.updateCurrTransState('initial');
|
|
1926
2104
|
}
|
|
1927
|
-
parent.notify('filter', { prop: 'updateBrightFilter', onPropertyChange: false });
|
|
1928
2105
|
parent.notify('transform', { prop: 'setDestPointsForFlipState', onPropertyChange: false });
|
|
1929
|
-
this.
|
|
2106
|
+
this.drawImage();
|
|
1930
2107
|
parent.notify('transform', { prop: 'setDestPointsForFlipState', onPropertyChange: false });
|
|
1931
2108
|
if (isMouseWheel) {
|
|
1932
2109
|
this.setTransformColl(this.lowerContext, 'reverse');
|
|
@@ -1936,10 +2113,17 @@ var Draw = /** @class */ (function () {
|
|
|
1936
2113
|
this.isRotateZoom = false;
|
|
1937
2114
|
}
|
|
1938
2115
|
this.lowerContext.filter = 'none';
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
2116
|
+
if (isFrame) {
|
|
2117
|
+
parent.notify('shape', { prop: 'zoomObjColl', onPropertyChange: false, value: { isPreventApply: null } });
|
|
2118
|
+
parent.notify('freehand-draw', { prop: 'zoomFHDColl', onPropertyChange: false, value: { isPreventApply: null } });
|
|
2119
|
+
}
|
|
2120
|
+
else {
|
|
2121
|
+
parent.notify('shape', { prop: 'iterateObjColl', onPropertyChange: false });
|
|
2122
|
+
parent.notify('freehand-draw', { prop: 'freehandRedraw', onPropertyChange: false,
|
|
2123
|
+
value: { context: this.lowerContext, points: null } });
|
|
2124
|
+
}
|
|
1942
2125
|
this.lowerContext.filter = temp;
|
|
2126
|
+
this.clearOuterCanvas(this.lowerContext);
|
|
1943
2127
|
if (parent.isCircleCrop || (parent.currSelectionPoint && parent.currSelectionPoint.shape === 'crop-circle')) {
|
|
1944
2128
|
parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
|
|
1945
2129
|
value: { context: this.lowerContext, isSave: null, isFlip: null } });
|
|
@@ -1956,6 +2140,7 @@ var Draw = /** @class */ (function () {
|
|
|
1956
2140
|
proxy.lowerContext.drawImage(parent.baseImg, 0, 0, proxy.parent.lowerCanvas.width, proxy.parent.lowerCanvas.height);
|
|
1957
2141
|
hideSpinner(parent.element);
|
|
1958
2142
|
parent.element.style.opacity = '1';
|
|
2143
|
+
proxy.updateBaseImgCanvas();
|
|
1959
2144
|
proxy.updateCanvas();
|
|
1960
2145
|
if (parent.currObjType.isUndoZoom) {
|
|
1961
2146
|
parent.currObjType.isUndoZoom = false;
|
|
@@ -2003,18 +2188,26 @@ var Draw = /** @class */ (function () {
|
|
|
2003
2188
|
parent.trigger('fileOpened', fileOpened);
|
|
2004
2189
|
}
|
|
2005
2190
|
};
|
|
2191
|
+
Draw.prototype.updateBaseImgCanvas = function () {
|
|
2192
|
+
var parent = this.parent;
|
|
2193
|
+
parent.baseImgCanvas.width = parent.baseImg.width;
|
|
2194
|
+
parent.baseImgCanvas.height = parent.baseImg.height;
|
|
2195
|
+
parent.baseImgCanvas.getContext('2d').drawImage(parent.baseImg, 0, 0);
|
|
2196
|
+
};
|
|
2006
2197
|
Draw.prototype.updateCanvas = function () {
|
|
2007
2198
|
var parent = this.parent;
|
|
2008
2199
|
var fileOpened = { fileName: this.fileName, fileType: this.fileType, isValidImage: true };
|
|
2009
|
-
parent.img.srcWidth = parent.
|
|
2010
|
-
parent.img.srcHeight = parent.
|
|
2200
|
+
parent.img.srcWidth = parent.baseImgCanvas.width;
|
|
2201
|
+
parent.img.srcHeight = parent.baseImgCanvas.height;
|
|
2011
2202
|
var obj = { width: 0, height: 0 };
|
|
2012
2203
|
parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
|
|
2013
|
-
value: { width: parent.img.srcWidth, height: parent.img.srcHeight, obj: obj } });
|
|
2204
|
+
value: { width: parent.img.srcWidth, height: parent.img.srcHeight, obj: obj, isImgShape: null } });
|
|
2014
2205
|
var maxDimension = obj;
|
|
2015
2206
|
parent.img.destLeft = (parent.lowerCanvas.clientWidth - maxDimension.width) / 2;
|
|
2016
2207
|
parent.img.destTop = (parent.lowerCanvas.clientHeight - maxDimension.height) / 2;
|
|
2017
2208
|
this.drawImgToCanvas(maxDimension);
|
|
2209
|
+
this.origDim.width = parent.img.destWidth;
|
|
2210
|
+
this.origDim.height = parent.img.destHeight;
|
|
2018
2211
|
this.zoomCrop.width = parent.img.destWidth;
|
|
2019
2212
|
this.zoomCrop.height = parent.img.destHeight;
|
|
2020
2213
|
parent.notify('transform', { prop: 'setCropDimension', onPropertyChange: false,
|
|
@@ -2055,11 +2248,27 @@ var Draw = /** @class */ (function () {
|
|
|
2055
2248
|
}
|
|
2056
2249
|
this.isImageEdited = false;
|
|
2057
2250
|
};
|
|
2251
|
+
Draw.prototype.resetFrameZoom = function () {
|
|
2252
|
+
var parent = this.parent;
|
|
2253
|
+
if (!isNullOrUndefined(parent.tempFrameZoomLevel)) {
|
|
2254
|
+
var temp = parent.tempFrameZoomLevel;
|
|
2255
|
+
parent.tempFrameZoomLevel = null;
|
|
2256
|
+
parent.notify('transform', { prop: 'resetZoom', onPropertyChange: false });
|
|
2257
|
+
parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
2258
|
+
value: { zoomFactor: temp, zoomPoint: null, isResize: true } });
|
|
2259
|
+
}
|
|
2260
|
+
};
|
|
2058
2261
|
Draw.prototype.performCancel = function (isContextualToolbar) {
|
|
2059
2262
|
var parent = this.parent;
|
|
2060
2263
|
isContextualToolbar = isContextualToolbar ? isContextualToolbar : false;
|
|
2061
2264
|
var obj = { bool: false };
|
|
2265
|
+
parent.allowDownScale = true;
|
|
2062
2266
|
parent.notify('selection', { prop: 'getFreehandDrawEditing', onPropertyChange: false, value: { obj: obj } });
|
|
2267
|
+
if (JSON.stringify(parent.frameObj) !== JSON.stringify(parent.tempFrameObj)) {
|
|
2268
|
+
extend(parent.frameObj, parent.tempFrameObj);
|
|
2269
|
+
this.renderImage(null, null, true);
|
|
2270
|
+
}
|
|
2271
|
+
this.resetFrameZoom();
|
|
2063
2272
|
if (obj['bool']) {
|
|
2064
2273
|
parent.notify('freehand-draw', { prop: 'cancelFhd', onPropertyChange: false });
|
|
2065
2274
|
if (!isBlazor()) {
|
|
@@ -2143,8 +2352,14 @@ var Draw = /** @class */ (function () {
|
|
|
2143
2352
|
}
|
|
2144
2353
|
else {
|
|
2145
2354
|
this.cancelItems();
|
|
2146
|
-
parent.
|
|
2147
|
-
|
|
2355
|
+
if (parent.transform.zoomFactor > 0) {
|
|
2356
|
+
parent.togglePan = true;
|
|
2357
|
+
parent.notify('selection', { prop: 'setDragCanvas', value: { bool: true } });
|
|
2358
|
+
}
|
|
2359
|
+
else {
|
|
2360
|
+
parent.togglePan = false;
|
|
2361
|
+
parent.notify('selection', { prop: 'setDragCanvas', value: { bool: false } });
|
|
2362
|
+
}
|
|
2148
2363
|
}
|
|
2149
2364
|
}
|
|
2150
2365
|
this.isShapeTextInserted = false;
|
|
@@ -2157,8 +2372,10 @@ var Draw = /** @class */ (function () {
|
|
|
2157
2372
|
Draw.prototype.cancelItems = function () {
|
|
2158
2373
|
var parent = this.parent;
|
|
2159
2374
|
var isCropSelection = false;
|
|
2375
|
+
var ascpectIcon = this.parent.element.querySelector('#' + this.parent.element.id + '_aspectratio');
|
|
2376
|
+
var nonAspectIcon = this.parent.element.querySelector('#' + this.parent.element.id + '_nonaspectratio');
|
|
2160
2377
|
var splitWords;
|
|
2161
|
-
var shapes = ['rectangle', 'ellipse', 'line', 'arrow', 'path'];
|
|
2378
|
+
var shapes = ['rectangle', 'ellipse', 'line', 'arrow', 'path', 'image'];
|
|
2162
2379
|
if (parent.activeObj.shape !== undefined) {
|
|
2163
2380
|
splitWords = parent.activeObj.shape.split('-');
|
|
2164
2381
|
}
|
|
@@ -2172,6 +2389,54 @@ var Draw = /** @class */ (function () {
|
|
|
2172
2389
|
parent.isCropTab = false;
|
|
2173
2390
|
parent.transform.zoomFactor = parent.transform.defaultZoomFactor;
|
|
2174
2391
|
}
|
|
2392
|
+
if (parent.isResize) {
|
|
2393
|
+
if (ascpectIcon || nonAspectIcon || parent.currentToolbar == "resize-toolbar") {
|
|
2394
|
+
var obj = { width: null, height: null };
|
|
2395
|
+
parent.notify('selection', { prop: 'getNumTextValue', onPropertyChange: false, value: { obj: obj } });
|
|
2396
|
+
var point = { x: obj['width'], y: obj['height'] };
|
|
2397
|
+
var aspectRatioElement = this.parent.element.querySelector('#' + this.parent.element.id + '_aspectratio');
|
|
2398
|
+
var blrAspRatElem = this.parent.element.querySelector(".e-ie-toolbar-aspect-ratio-btn");
|
|
2399
|
+
if (point && point.x && point.y && !isNullOrUndefined(this.parent.aspectWidth)) {
|
|
2400
|
+
if (aspectRatioElement || (blrAspRatElem && !blrAspRatElem.classList.contains("e-hidden"))) {
|
|
2401
|
+
parent.notify('transform', { prop: 'resizeImage', value: { width: parent.aspectWidth, height: parent.aspectHeight } });
|
|
2402
|
+
}
|
|
2403
|
+
else {
|
|
2404
|
+
var bool = parent.currObjType.isUndoAction;
|
|
2405
|
+
parent.currObjType.isUndoAction = false;
|
|
2406
|
+
parent.notify('transform', { prop: 'resizeCrop', value: { width: parent.aspectWidth, height: parent.aspectHeight } });
|
|
2407
|
+
parent.currObjType.isUndoAction = bool;
|
|
2408
|
+
}
|
|
2409
|
+
}
|
|
2410
|
+
var obj1 = { prevCropObj: parent.prevCropObj };
|
|
2411
|
+
var obj2 = { prevObj: parent.prevObj };
|
|
2412
|
+
this.parent.notify('toolbar', { prop: 'getPrevCropObj', onPropertyChange: false, value: { obj: obj1 } });
|
|
2413
|
+
this.parent.notify('toolbar', { prop: 'getPrevObj', onPropertyChange: false, value: { obj: obj2 } });
|
|
2414
|
+
if (obj1['prevCropObj'] && obj2['prevObj']) {
|
|
2415
|
+
if (!aspectRatioElement) {
|
|
2416
|
+
parent.objColl = [];
|
|
2417
|
+
parent.pointColl = [];
|
|
2418
|
+
parent.freehandCounter = 0;
|
|
2419
|
+
parent.cropObj = extend({}, obj1['prevCropObj'], {}, true);
|
|
2420
|
+
this.setCurrentObj(obj2['prevObj']);
|
|
2421
|
+
parent.objColl = obj2['prevObj']['objColl'];
|
|
2422
|
+
parent.pointColl = obj2['prevObj']['pointColl'];
|
|
2423
|
+
parent.freehandCounter = parent.pointColl.length;
|
|
2424
|
+
parent.notify('shape', { prop: 'zoomObjColl', onPropertyChange: false, value: { isPreventApply: null } });
|
|
2425
|
+
parent.notify('freehand-draw', { prop: 'zoomFHDColl', onPropertyChange: false, value: { isPreventApply: null } });
|
|
2426
|
+
}
|
|
2427
|
+
this.parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
2428
|
+
value: { zoomFactor: -this.parent.transform.zoomFactor, zoomPoint: null, isResize: true } });
|
|
2429
|
+
this.parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
2430
|
+
value: { zoomFactor: obj2['prevObj']['defaultZoom'], zoomPoint: null, isResize: true } });
|
|
2431
|
+
if (obj2['prevObj'].zoomFactor) {
|
|
2432
|
+
parent.setProperties({ zoomSettings: { zoomFactor: obj2['prevObj'].zoomFactor } }, true);
|
|
2433
|
+
}
|
|
2434
|
+
parent.notify('transform', { prop: 'setPreviousZoomValue', onPropertyChange: false,
|
|
2435
|
+
value: { previousZoomValue: parent.zoomSettings.zoomFactor } });
|
|
2436
|
+
}
|
|
2437
|
+
parent.isResize = false;
|
|
2438
|
+
}
|
|
2439
|
+
}
|
|
2175
2440
|
if (parent.togglePen) {
|
|
2176
2441
|
this.cancelPen();
|
|
2177
2442
|
}
|
|
@@ -2285,10 +2550,17 @@ var Draw = /** @class */ (function () {
|
|
|
2285
2550
|
else {
|
|
2286
2551
|
var object = { appliedUndoRedoColl: [] };
|
|
2287
2552
|
parent.notify('undo-redo', { prop: 'getAppliedUndoRedoColl', value: { obj: object } });
|
|
2288
|
-
var
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2553
|
+
var obj = void 0;
|
|
2554
|
+
for (var i = 0; i < object['appliedUndoRedoColl'].length; i++) {
|
|
2555
|
+
for (var j = 0; j < object['appliedUndoRedoColl'][i].currentObjColl.length; j++) {
|
|
2556
|
+
if (this.prevActObj && this.prevActObj.currIndex &&
|
|
2557
|
+
object['appliedUndoRedoColl'][i].currentObjColl[j].currIndex === this.prevActObj.currIndex) {
|
|
2558
|
+
obj = object['appliedUndoRedoColl'][i].currentObjColl[0];
|
|
2559
|
+
break;
|
|
2560
|
+
}
|
|
2561
|
+
}
|
|
2562
|
+
}
|
|
2563
|
+
if (this.prevActObj && obj) {
|
|
2292
2564
|
parent.activeObj = this.prevActObj;
|
|
2293
2565
|
this.prevActObj = null;
|
|
2294
2566
|
parent.notify('selection', { prop: 'redrawShape', onPropertyChange: false, value: { obj: parent.activeObj } });
|
|
@@ -2344,6 +2616,7 @@ var Draw = /** @class */ (function () {
|
|
|
2344
2616
|
Draw.prototype.select = function (type, startX, startY, width, height) {
|
|
2345
2617
|
var parent = this.parent;
|
|
2346
2618
|
if (!parent.disabled && parent.isImageLoaded) {
|
|
2619
|
+
parent.allowDownScale = false;
|
|
2347
2620
|
var object = { currObj: {} };
|
|
2348
2621
|
parent.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
|
|
2349
2622
|
var previousObj = object['currObj'];
|
|
@@ -2355,7 +2628,8 @@ var Draw = /** @class */ (function () {
|
|
|
2355
2628
|
value: { obj: selPointCollObj } });
|
|
2356
2629
|
previousObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
|
|
2357
2630
|
parent.notify('crop', { prop: 'setPreviousCropCurrentObj', onPropertyChange: false, value: { obj: previousObj } });
|
|
2358
|
-
if (parent.transform.zoomFactor > 0 && parent.activeObj.shape &&
|
|
2631
|
+
if (parent.transform.zoomFactor > 0 && parent.activeObj.shape &&
|
|
2632
|
+
parent.activeObj.shape.split('-')[0] === 'crop' && isNullOrUndefined(this.currSelPoint)) {
|
|
2359
2633
|
this.currSelPoint = extend({}, parent.activeObj, {}, true);
|
|
2360
2634
|
}
|
|
2361
2635
|
var isPrevent = false;
|
|
@@ -2385,7 +2659,7 @@ var Draw = /** @class */ (function () {
|
|
|
2385
2659
|
(parent.transform.degree !== 0 && parent.panPoint.totalPannedInternalPoint.x !== 0 &&
|
|
2386
2660
|
parent.panPoint.totalPannedInternalPoint.y !== 0 && !isPrevent)) {
|
|
2387
2661
|
parent.isCircleCrop = false;
|
|
2388
|
-
if (parent.transform.defaultZoomFactor !== 0) {
|
|
2662
|
+
if (parent.transform.defaultZoomFactor !== 0 && !this.isResizeSelect) {
|
|
2389
2663
|
var isCropTab = parent.isCropTab;
|
|
2390
2664
|
parent.isCropTab = false;
|
|
2391
2665
|
parent.notify('transform', { prop: 'resetZoom', onPropertyChange: false });
|
|
@@ -2395,7 +2669,9 @@ var Draw = /** @class */ (function () {
|
|
|
2395
2669
|
parent.notify('freehand-draw', { prop: 'updateFHDColl', onPropertyChange: false });
|
|
2396
2670
|
parent.isCropTab = true;
|
|
2397
2671
|
parent.isCircleCrop = false;
|
|
2398
|
-
|
|
2672
|
+
if (!this.isResizeSelect) {
|
|
2673
|
+
parent.notify('crop', { prop: 'setCurrSelPoints', onPropertyChange: false, value: { isSetDimension: true } });
|
|
2674
|
+
}
|
|
2399
2675
|
parent.transform.zoomFactor = parent.transform.cropZoomFactor;
|
|
2400
2676
|
if (isNullOrUndefined(parent.cropObj.activeObj.shape)) {
|
|
2401
2677
|
parent.currObjType.shape = 'crop-' + type.toLowerCase();
|
|
@@ -2589,8 +2865,7 @@ var Draw = /** @class */ (function () {
|
|
|
2589
2865
|
if (parent.transform.degree === 0) {
|
|
2590
2866
|
parent.notify('transform', { prop: 'setDestPointsForFlipState', onPropertyChange: false });
|
|
2591
2867
|
}
|
|
2592
|
-
|
|
2593
|
-
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);
|
|
2868
|
+
this.drawImage();
|
|
2594
2869
|
this.updateCurrTransState('reverse');
|
|
2595
2870
|
if (parent.transform.degree === 0 && parent.rotateFlipColl.length > 0) {
|
|
2596
2871
|
parent.img.destLeft += parent.panPoint.totalPannedPoint.x;
|
|
@@ -2655,16 +2930,15 @@ var Draw = /** @class */ (function () {
|
|
|
2655
2930
|
parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
|
|
2656
2931
|
value: { context: this.lowerContext, isSave: null, isFlip: null } });
|
|
2657
2932
|
}
|
|
2658
|
-
var tempFilter = this.lowerContext.filter;
|
|
2659
|
-
this.lowerContext.filter = parent.getDefaultFilter();
|
|
2660
|
-
parent.notify('shape', { prop: 'iterateObjColl', onPropertyChange: false });
|
|
2661
|
-
parent.notify('freehand-draw', { prop: 'freehandRedraw', onPropertyChange: false,
|
|
2662
|
-
value: { context: this.lowerContext, points: null } });
|
|
2663
|
-
this.lowerContext.filter = tempFilter;
|
|
2664
2933
|
};
|
|
2665
2934
|
Draw.prototype.setCurrentObj = function (obj) {
|
|
2666
2935
|
var parent = this.parent;
|
|
2667
2936
|
var isObj = obj ? true : false;
|
|
2937
|
+
if (!isObj) {
|
|
2938
|
+
parent.cropObj.aspectWidth = parent.aspectWidth;
|
|
2939
|
+
parent.cropObj.aspectHeight = parent.aspectHeight;
|
|
2940
|
+
parent.cropObj.frame = parent.frameObj.type;
|
|
2941
|
+
}
|
|
2668
2942
|
obj = obj ? obj : parent.cropObj;
|
|
2669
2943
|
parent.transform.cropZoomFactor = obj.cropZoom;
|
|
2670
2944
|
parent.transform.defaultZoomFactor = obj.defaultZoom;
|
|
@@ -2688,6 +2962,7 @@ var Draw = /** @class */ (function () {
|
|
|
2688
2962
|
parent.notify('crop', { prop: 'setTempFlipPanPoint', onPropertyChange: false, value: { point: point } });
|
|
2689
2963
|
parent.rotateFlipColl = extend([], obj.rotateFlipColl, [], true);
|
|
2690
2964
|
parent.transform.degree = obj.degree;
|
|
2965
|
+
parent.frameObj.type = obj.frame;
|
|
2691
2966
|
parent.transform.currFlipState = obj.currFlipState;
|
|
2692
2967
|
parent.img.destLeft = obj.destPoints.startX;
|
|
2693
2968
|
parent.img.destTop = obj.destPoints.startY;
|
|
@@ -2697,6 +2972,8 @@ var Draw = /** @class */ (function () {
|
|
|
2697
2972
|
parent.img.srcTop = obj.srcPoints.startY;
|
|
2698
2973
|
parent.img.srcWidth = obj.srcPoints.width;
|
|
2699
2974
|
parent.img.srcHeight = obj.srcPoints.height;
|
|
2975
|
+
parent.aspectWidth = obj.aspectWidth;
|
|
2976
|
+
parent.aspectHeight = obj.aspectHeight;
|
|
2700
2977
|
if (obj.afterCropActions) {
|
|
2701
2978
|
parent.afterCropActions = obj.afterCropActions;
|
|
2702
2979
|
}
|
|
@@ -2797,8 +3074,7 @@ var Draw = /** @class */ (function () {
|
|
|
2797
3074
|
this.setTransformColl(this.lowerContext, 'initial');
|
|
2798
3075
|
}
|
|
2799
3076
|
parent.notify('transform', { prop: 'setDestPointsForFlipState', onPropertyChange: false });
|
|
2800
|
-
|
|
2801
|
-
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);
|
|
3077
|
+
this.drawImage();
|
|
2802
3078
|
if (isObj) {
|
|
2803
3079
|
this.updateCurrTransState('reverse');
|
|
2804
3080
|
}
|
|
@@ -2822,18 +3098,20 @@ var Draw = /** @class */ (function () {
|
|
|
2822
3098
|
parent.img.srcTop = obj.srcPoints.startY;
|
|
2823
3099
|
parent.img.srcWidth = obj.srcPoints.width;
|
|
2824
3100
|
parent.img.srcHeight = obj.srcPoints.height;
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
3101
|
+
if (obj.activeObj.activePoint.width !== 0 && obj.activeObj.activePoint.height !== 0) {
|
|
3102
|
+
var destPoints = { startX: parent.img.destLeft, startY: parent.img.destTop, width: parent.img.destWidth,
|
|
3103
|
+
height: parent.img.destHeight };
|
|
3104
|
+
parent.img.destLeft = obj.activeObj.activePoint.startX;
|
|
3105
|
+
parent.img.destTop = obj.activeObj.activePoint.startY;
|
|
3106
|
+
parent.img.destWidth = obj.activeObj.activePoint.width;
|
|
3107
|
+
parent.img.destHeight = obj.activeObj.activePoint.height;
|
|
3108
|
+
parent.notify('shape', { prop: 'zoomObjColl', onPropertyChange: false, value: { isPreventApply: null } });
|
|
3109
|
+
parent.notify('freehand-draw', { prop: 'zoomFHDColl', onPropertyChange: false, value: { isPreventApply: null } });
|
|
3110
|
+
parent.img.destLeft = destPoints.startX;
|
|
3111
|
+
parent.img.destTop = destPoints.startY;
|
|
3112
|
+
parent.img.destWidth = destPoints.width;
|
|
3113
|
+
parent.img.destHeight = destPoints.height;
|
|
3114
|
+
}
|
|
2837
3115
|
}
|
|
2838
3116
|
parent.activeObj = activeObj;
|
|
2839
3117
|
this.lowerContext.filter = temp;
|
|
@@ -2847,11 +3125,11 @@ var Draw = /** @class */ (function () {
|
|
|
2847
3125
|
parent.setProperties({ zoomSettings: { zoomPoint: { x: x, y: y } } }, true);
|
|
2848
3126
|
if (type === 'zoomIn') {
|
|
2849
3127
|
parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
2850
|
-
value: { zoomFactor: .1, zoomPoint: null } });
|
|
3128
|
+
value: { zoomFactor: .1, zoomPoint: null }, isResize: null });
|
|
2851
3129
|
}
|
|
2852
3130
|
else if (type === 'zoomOut') {
|
|
2853
3131
|
parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
2854
|
-
value: { zoomFactor: -.1, zoomPoint: null } });
|
|
3132
|
+
value: { zoomFactor: -.1, zoomPoint: null }, isResize: null });
|
|
2855
3133
|
}
|
|
2856
3134
|
parent.isUndoRedo = isUndoRedo;
|
|
2857
3135
|
if (parent.transform.zoomFactor > 0) {
|
|
@@ -2963,7 +3241,7 @@ var Draw = /** @class */ (function () {
|
|
|
2963
3241
|
this.renderImage(true);
|
|
2964
3242
|
var obj = { width: 0, height: 0 };
|
|
2965
3243
|
parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
|
|
2966
|
-
value: { width: parent.img.srcWidth, height: parent.img.srcHeight, obj: obj } });
|
|
3244
|
+
value: { width: parent.img.srcWidth, height: parent.img.srcHeight, obj: obj, isImgShape: null } });
|
|
2967
3245
|
var maxDimension = obj;
|
|
2968
3246
|
maxDimension.width += (maxDimension.width * parent.transform.zoomFactor);
|
|
2969
3247
|
maxDimension.height += (maxDimension.height * parent.transform.zoomFactor);
|
|
@@ -3075,11 +3353,19 @@ var Draw = /** @class */ (function () {
|
|
|
3075
3353
|
this.isImageEdited = false;
|
|
3076
3354
|
};
|
|
3077
3355
|
Draw.prototype.showDialogPopup = function () {
|
|
3356
|
+
var headerObj = { key: 'ConfirmDialogHeader' };
|
|
3357
|
+
this.parent.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: headerObj } });
|
|
3358
|
+
var contentObj = { key: 'ConfirmDialogContent' };
|
|
3359
|
+
this.parent.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: contentObj } });
|
|
3360
|
+
var yesObj = { key: 'Yes' };
|
|
3361
|
+
this.parent.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: yesObj } });
|
|
3362
|
+
var noObj = { key: 'No' };
|
|
3363
|
+
this.parent.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: noObj } });
|
|
3078
3364
|
this.parent.element.querySelector('#' + this.parent.element.id + '_dialog').style.display = 'block';
|
|
3079
3365
|
var dialog = new Dialog({
|
|
3080
|
-
header: '
|
|
3366
|
+
header: headerObj['value'],
|
|
3081
3367
|
closeOnEscape: true,
|
|
3082
|
-
content: '<span>
|
|
3368
|
+
content: '<span>' + contentObj['value'] + '</span>',
|
|
3083
3369
|
target: document.getElementById('target'),
|
|
3084
3370
|
width: '285px',
|
|
3085
3371
|
isModal: true,
|
|
@@ -3087,10 +3373,10 @@ var Draw = /** @class */ (function () {
|
|
|
3087
3373
|
close: this.dlgCloseBtnClick.bind(this),
|
|
3088
3374
|
buttons: [
|
|
3089
3375
|
{ click: this.dlgCloseBtnClick.bind(this),
|
|
3090
|
-
buttonModel: { content: '
|
|
3376
|
+
buttonModel: { content: noObj['value'], iconCss: 'e-icons e-close' }
|
|
3091
3377
|
},
|
|
3092
3378
|
{ click: this.dlgBtnClick.bind(this),
|
|
3093
|
-
buttonModel: { content: '
|
|
3379
|
+
buttonModel: { content: yesObj['value'], isPrimary: true, iconCss: 'e-icons e-check' } }
|
|
3094
3380
|
]
|
|
3095
3381
|
});
|
|
3096
3382
|
dialog.appendTo('#' + this.parent.element.id + '_dialog');
|
|
@@ -3116,6 +3402,7 @@ var Draw = /** @class */ (function () {
|
|
|
3116
3402
|
}
|
|
3117
3403
|
};
|
|
3118
3404
|
Draw.prototype.open = function (data) {
|
|
3405
|
+
document.getElementById(this.parent.element.id + '_dropArea').style.display = 'none';
|
|
3119
3406
|
if (!this.parent.disabled) {
|
|
3120
3407
|
this.openURL = data;
|
|
3121
3408
|
this.restoreOldImage();
|
|
@@ -3133,11 +3420,20 @@ var Draw = /** @class */ (function () {
|
|
|
3133
3420
|
};
|
|
3134
3421
|
Draw.prototype.fileSelect = function (inputElement, args) {
|
|
3135
3422
|
var parent = this.parent;
|
|
3423
|
+
document.getElementById(parent.element.id + '_dropArea').style.display = 'none';
|
|
3136
3424
|
if (!parent.disabled) {
|
|
3425
|
+
var filesData = void 0;
|
|
3137
3426
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
3138
|
-
var
|
|
3139
|
-
|
|
3140
|
-
|
|
3427
|
+
var fileData = void 0;
|
|
3428
|
+
if (args.target) {
|
|
3429
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
3430
|
+
filesData = args.target.files[0];
|
|
3431
|
+
fileData = filesData;
|
|
3432
|
+
}
|
|
3433
|
+
else {
|
|
3434
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
3435
|
+
filesData = fileData = args.filesData[0].rawFile;
|
|
3436
|
+
}
|
|
3141
3437
|
var fileExtension = fileData.name && fileData.name.split('.')[1].toLowerCase();
|
|
3142
3438
|
if (fileExtension && ['jpg', 'jpeg', 'png', 'svg'].indexOf(fileExtension) === -1) {
|
|
3143
3439
|
this.errorLoading();
|
|
@@ -3169,7 +3465,7 @@ var Draw = /** @class */ (function () {
|
|
|
3169
3465
|
this.showDialogPopup();
|
|
3170
3466
|
}
|
|
3171
3467
|
else {
|
|
3172
|
-
parent.dotNetRef.invokeMethodAsync('UpdateDialog');
|
|
3468
|
+
parent.dotNetRef.invokeMethodAsync('UpdateDialog', true);
|
|
3173
3469
|
}
|
|
3174
3470
|
}
|
|
3175
3471
|
else {
|
|
@@ -3199,6 +3495,9 @@ var Draw = /** @class */ (function () {
|
|
|
3199
3495
|
}
|
|
3200
3496
|
}
|
|
3201
3497
|
if (isRotated) {
|
|
3498
|
+
if (parent.transform.degree === 0) {
|
|
3499
|
+
return;
|
|
3500
|
+
}
|
|
3202
3501
|
var zoomFactor = parent.transform.zoomFactor;
|
|
3203
3502
|
parent.objColl.push(parent.activeObj);
|
|
3204
3503
|
parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
|
|
@@ -3211,13 +3510,13 @@ var Draw = /** @class */ (function () {
|
|
|
3211
3510
|
this.isSelectionOutsideCanvas(parent.objColl[parent.objColl.length - 1])) {
|
|
3212
3511
|
if (!isNullOrUndefined(zoomFactor)) {
|
|
3213
3512
|
parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
3214
|
-
value: { zoomFactor: -0.1, zoomPoint: null } });
|
|
3513
|
+
value: { zoomFactor: -0.1, zoomPoint: null }, isResize: null });
|
|
3215
3514
|
}
|
|
3216
3515
|
break;
|
|
3217
3516
|
}
|
|
3218
3517
|
zoomFactor += 0.1;
|
|
3219
3518
|
parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
3220
|
-
value: { zoomFactor: zoomFactor, zoomPoint: null } });
|
|
3519
|
+
value: { zoomFactor: zoomFactor, zoomPoint: null }, isResize: null });
|
|
3221
3520
|
}
|
|
3222
3521
|
}
|
|
3223
3522
|
else {
|
|
@@ -3227,13 +3526,13 @@ var Draw = /** @class */ (function () {
|
|
|
3227
3526
|
this.isSelectionOutsideCanvas(parent.objColl[parent.objColl.length - 1])) {
|
|
3228
3527
|
if (!isNullOrUndefined(zoomFactor)) {
|
|
3229
3528
|
parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
3230
|
-
value: { zoomFactor: 0.1, zoomPoint: null } });
|
|
3529
|
+
value: { zoomFactor: 0.1, zoomPoint: null, isResize: null } });
|
|
3231
3530
|
}
|
|
3232
3531
|
break;
|
|
3233
3532
|
}
|
|
3234
3533
|
zoomFactor -= .1;
|
|
3235
3534
|
parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
3236
|
-
value: { zoomFactor: zoomFactor, zoomPoint: null } });
|
|
3535
|
+
value: { zoomFactor: zoomFactor, zoomPoint: null }, isResize: null });
|
|
3237
3536
|
}
|
|
3238
3537
|
}
|
|
3239
3538
|
}
|
|
@@ -3245,13 +3544,13 @@ var Draw = /** @class */ (function () {
|
|
|
3245
3544
|
this.isSelectionOutsideCanvas(parent.objColl[parent.objColl.length - 1])) {
|
|
3246
3545
|
if (!isNullOrUndefined(zoomFactor)) {
|
|
3247
3546
|
parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
3248
|
-
value: { zoomFactor: -0.1, zoomPoint: null } });
|
|
3547
|
+
value: { zoomFactor: -0.1, zoomPoint: null }, isResize: null });
|
|
3249
3548
|
}
|
|
3250
3549
|
break;
|
|
3251
3550
|
}
|
|
3252
3551
|
zoomFactor += 0.1;
|
|
3253
3552
|
parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
3254
|
-
value: { zoomFactor: zoomFactor, zoomPoint: null } });
|
|
3553
|
+
value: { zoomFactor: zoomFactor, zoomPoint: null }, isResize: null });
|
|
3255
3554
|
}
|
|
3256
3555
|
}
|
|
3257
3556
|
else {
|
|
@@ -3261,13 +3560,13 @@ var Draw = /** @class */ (function () {
|
|
|
3261
3560
|
this.isSelectionOutsideCanvas(parent.objColl[parent.objColl.length - 1])) {
|
|
3262
3561
|
if (!isNullOrUndefined(zoomFactor)) {
|
|
3263
3562
|
parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
3264
|
-
value: { zoomFactor: 0.1, zoomPoint: null } });
|
|
3563
|
+
value: { zoomFactor: 0.1, zoomPoint: null }, isResize: null });
|
|
3265
3564
|
}
|
|
3266
3565
|
break;
|
|
3267
3566
|
}
|
|
3268
3567
|
zoomFactor -= .1;
|
|
3269
3568
|
parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
3270
|
-
value: { zoomFactor: zoomFactor, zoomPoint: null } });
|
|
3569
|
+
value: { zoomFactor: zoomFactor, zoomPoint: null }, isResize: null });
|
|
3271
3570
|
}
|
|
3272
3571
|
}
|
|
3273
3572
|
}
|
|
@@ -3312,6 +3611,453 @@ var Draw = /** @class */ (function () {
|
|
|
3312
3611
|
}
|
|
3313
3612
|
return isOutside;
|
|
3314
3613
|
};
|
|
3614
|
+
Draw.prototype.downScaleImgCanvas = function (ctx, isImgAnnotation, isHFlip, isVFlip) {
|
|
3615
|
+
var parent = this.parent;
|
|
3616
|
+
var canvas = isImgAnnotation ? parent.activeObj.imageCanvas : parent.baseImgCanvas;
|
|
3617
|
+
var img = isImgAnnotation ? parent.activeObj.imageElement : parent.baseImg;
|
|
3618
|
+
var width = isImgAnnotation ? parent.activeObj.activePoint.width : parent.img.destWidth;
|
|
3619
|
+
var height = isImgAnnotation ? parent.activeObj.activePoint.height : parent.img.destHeight;
|
|
3620
|
+
var obj = { width: 0, height: 0 };
|
|
3621
|
+
if (parent.transform.degree % 90 === 0 && parent.transform.degree % 180 !== 0) {
|
|
3622
|
+
parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
|
|
3623
|
+
value: { width: img.height, height: img.width, obj: obj, isImgShape: isImgAnnotation } });
|
|
3624
|
+
}
|
|
3625
|
+
else {
|
|
3626
|
+
parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
|
|
3627
|
+
value: { width: img.width, height: img.height, obj: obj, isImgShape: isImgAnnotation } });
|
|
3628
|
+
}
|
|
3629
|
+
if (isImgAnnotation || (parent.allowDownScale && !parent.isCropTab && !parent.isCropToolbar && img.width !== 0 && img.height !== 0
|
|
3630
|
+
&& obj['width'] * 0.75 > width && obj['height'] * 0.75 > height)) {
|
|
3631
|
+
var tempCanvas = parent.createElement('canvas', {
|
|
3632
|
+
id: parent.element.id + '_downScaleCanvas', attrs: { name: 'canvasImage' }
|
|
3633
|
+
});
|
|
3634
|
+
tempCanvas.width = isImgAnnotation ? img.width : this.parent.img.srcWidth;
|
|
3635
|
+
tempCanvas.height = isImgAnnotation ? img.height : this.parent.img.srcHeight;
|
|
3636
|
+
if (isImgAnnotation) {
|
|
3637
|
+
tempCanvas.getContext('2d').drawImage(img, 0, 0, tempCanvas.width, tempCanvas.height);
|
|
3638
|
+
}
|
|
3639
|
+
else {
|
|
3640
|
+
tempCanvas.getContext('2d').drawImage(canvas, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, 0, 0, tempCanvas.width, tempCanvas.height);
|
|
3641
|
+
}
|
|
3642
|
+
this.downScale(tempCanvas, width, height, isImgAnnotation);
|
|
3643
|
+
if (isImgAnnotation) {
|
|
3644
|
+
ctx.canvas.width = tempCanvas.width;
|
|
3645
|
+
ctx.canvas.height = tempCanvas.height;
|
|
3646
|
+
if (isHFlip && isVFlip) {
|
|
3647
|
+
ctx.translate(parent.activeObj.imageCanvas.width, 0);
|
|
3648
|
+
ctx.scale(-1, 1);
|
|
3649
|
+
ctx.translate(0, parent.activeObj.imageCanvas.height);
|
|
3650
|
+
ctx.scale(1, -1);
|
|
3651
|
+
}
|
|
3652
|
+
else {
|
|
3653
|
+
if (isHFlip) {
|
|
3654
|
+
if (isNullOrUndefined(parent.activeObj.isHorImageFlip) || !parent.activeObj.isHorImageFlip) {
|
|
3655
|
+
parent.activeObj.isHorImageFlip = true;
|
|
3656
|
+
ctx.translate(parent.activeObj.imageCanvas.width, 0);
|
|
3657
|
+
ctx.scale(-1, 1);
|
|
3658
|
+
}
|
|
3659
|
+
else if (parent.activeObj.isHorImageFlip) {
|
|
3660
|
+
parent.activeObj.isHorImageFlip = false;
|
|
3661
|
+
}
|
|
3662
|
+
if (parent.activeObj.isVerImageFlip) {
|
|
3663
|
+
ctx.translate(0, parent.activeObj.imageCanvas.height);
|
|
3664
|
+
ctx.scale(1, -1);
|
|
3665
|
+
}
|
|
3666
|
+
}
|
|
3667
|
+
else if (isVFlip) {
|
|
3668
|
+
if (isNullOrUndefined(parent.activeObj.isVerImageFlip) || !parent.activeObj.isVerImageFlip) {
|
|
3669
|
+
parent.activeObj.isVerImageFlip = true;
|
|
3670
|
+
ctx.translate(0, parent.activeObj.imageCanvas.height);
|
|
3671
|
+
ctx.scale(1, -1);
|
|
3672
|
+
}
|
|
3673
|
+
else if (parent.activeObj.isVerImageFlip) {
|
|
3674
|
+
parent.activeObj.isVerImageFlip = false;
|
|
3675
|
+
}
|
|
3676
|
+
if (parent.activeObj.isHorImageFlip) {
|
|
3677
|
+
ctx.translate(parent.activeObj.imageCanvas.width, 0);
|
|
3678
|
+
ctx.scale(-1, 1);
|
|
3679
|
+
}
|
|
3680
|
+
}
|
|
3681
|
+
}
|
|
3682
|
+
ctx.drawImage(tempCanvas, 0, 0);
|
|
3683
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
3684
|
+
}
|
|
3685
|
+
else {
|
|
3686
|
+
ctx.drawImage(tempCanvas, 0, 0, tempCanvas.width, tempCanvas.height, parent.img.destLeft, parent.img.destTop, tempCanvas.width, tempCanvas.height);
|
|
3687
|
+
}
|
|
3688
|
+
}
|
|
3689
|
+
else {
|
|
3690
|
+
if (isNullOrUndefined(isImgAnnotation) || !isImgAnnotation) {
|
|
3691
|
+
ctx.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);
|
|
3692
|
+
}
|
|
3693
|
+
}
|
|
3694
|
+
};
|
|
3695
|
+
Draw.prototype.downScale = function (canvas, width, height, isImgAnnotation) {
|
|
3696
|
+
var widthSource = canvas.width;
|
|
3697
|
+
var heightSource = canvas.height;
|
|
3698
|
+
width = Math.round(width);
|
|
3699
|
+
height = Math.round(height);
|
|
3700
|
+
var widthRatio = widthSource / width;
|
|
3701
|
+
var heightRatio = heightSource / height;
|
|
3702
|
+
var halfWidthRatio = Math.ceil(widthRatio / 2);
|
|
3703
|
+
var halfHeightRatio = Math.ceil(heightRatio / 2);
|
|
3704
|
+
var ctx = canvas.getContext('2d');
|
|
3705
|
+
var img = ctx.getImageData(0, 0, widthSource, heightSource);
|
|
3706
|
+
var img2 = ctx.createImageData(width, height);
|
|
3707
|
+
var data = img.data;
|
|
3708
|
+
var data2 = img2.data;
|
|
3709
|
+
for (var j = 0; j < height; j++) {
|
|
3710
|
+
for (var i = 0; i < width; i++) {
|
|
3711
|
+
var x2 = (i + j * width) * 4;
|
|
3712
|
+
var weight = 0;
|
|
3713
|
+
var weights = 0;
|
|
3714
|
+
var alphaWeights = 0;
|
|
3715
|
+
var r = 0;
|
|
3716
|
+
var g = 0;
|
|
3717
|
+
var b = 0;
|
|
3718
|
+
var a = 0;
|
|
3719
|
+
var centerY = (j + 0.5) * heightRatio;
|
|
3720
|
+
var startY = Math.floor(j * heightRatio);
|
|
3721
|
+
var stopY = Math.ceil((j + 1) * heightRatio);
|
|
3722
|
+
for (var y = startY; y < stopY; y++) {
|
|
3723
|
+
var dy = Math.abs(centerY - (y + 0.5)) / halfHeightRatio;
|
|
3724
|
+
var centerX = (i + 0.5) * widthRatio;
|
|
3725
|
+
var w0 = dy * dy; //pre-calc part of w
|
|
3726
|
+
var startX = Math.floor(i * widthRatio);
|
|
3727
|
+
var stopX = Math.ceil((i + 1) * widthRatio);
|
|
3728
|
+
for (var x = startX; x < stopX; x++) {
|
|
3729
|
+
var dx = Math.abs(centerX - (x + 0.5)) / halfWidthRatio;
|
|
3730
|
+
var w = Math.sqrt(w0 + dx * dx);
|
|
3731
|
+
if (w >= 1) {
|
|
3732
|
+
continue;
|
|
3733
|
+
}
|
|
3734
|
+
weight = 2 * w * w * w - 3 * w * w + 1;
|
|
3735
|
+
var xPos = 4 * (x + y * widthSource);
|
|
3736
|
+
a += weight * data[xPos + 3];
|
|
3737
|
+
alphaWeights += weight;
|
|
3738
|
+
weight = weight * data[xPos + 3] / 250;
|
|
3739
|
+
r += weight * data[xPos];
|
|
3740
|
+
g += weight * data[xPos + 1];
|
|
3741
|
+
b += weight * data[xPos + 2];
|
|
3742
|
+
weights += weight;
|
|
3743
|
+
}
|
|
3744
|
+
}
|
|
3745
|
+
data2[x2] = r / weights;
|
|
3746
|
+
data2[x2 + 1] = g / weights;
|
|
3747
|
+
data2[x2 + 2] = b / weights;
|
|
3748
|
+
data2[x2 + 3] = a / alphaWeights;
|
|
3749
|
+
}
|
|
3750
|
+
}
|
|
3751
|
+
canvas.width = isImgAnnotation ? this.parent.activeObj.activePoint.width : this.parent.lowerCanvas.width;
|
|
3752
|
+
canvas.height = isImgAnnotation ? this.parent.activeObj.activePoint.height : this.parent.lowerCanvas.height;
|
|
3753
|
+
ctx.putImageData(img2, 0, 0);
|
|
3754
|
+
};
|
|
3755
|
+
Draw.prototype.drawImgToCtx = function (ctx, preventImg) {
|
|
3756
|
+
var parent = this.parent;
|
|
3757
|
+
if (ctx.canvas.id !== parent.element.id + '_tempCanvas' && isNullOrUndefined(preventImg)) {
|
|
3758
|
+
this.downScaleImgCanvas(ctx, null, null, null);
|
|
3759
|
+
}
|
|
3760
|
+
};
|
|
3761
|
+
Draw.prototype.getFrameColor = function (frameObj, ctx, points) {
|
|
3762
|
+
var parent = this.parent;
|
|
3763
|
+
var color = parent.frameObj.color;
|
|
3764
|
+
if (frameObj.gradientColor) {
|
|
3765
|
+
var gradient = ctx.createLinearGradient(points.startX, points.startY, points.startX + points.width, points.startY + points.height);
|
|
3766
|
+
gradient.addColorStop(0, frameObj.color);
|
|
3767
|
+
gradient.addColorStop(1, frameObj.gradientColor);
|
|
3768
|
+
color = gradient;
|
|
3769
|
+
}
|
|
3770
|
+
else {
|
|
3771
|
+
color = frameObj.color;
|
|
3772
|
+
}
|
|
3773
|
+
return color;
|
|
3774
|
+
};
|
|
3775
|
+
Draw.prototype.applyFrame = function (ctx, frame, preventImg) {
|
|
3776
|
+
var parent = this.parent;
|
|
3777
|
+
parent.frameObj.type = frame;
|
|
3778
|
+
var tempLineWidth;
|
|
3779
|
+
var ratio = { width: 1, height: 1 };
|
|
3780
|
+
var points = { startX: parent.img.destLeft - ctx.lineWidth, startY: parent.img.destTop - ctx.lineWidth,
|
|
3781
|
+
width: parent.img.destWidth + (2 * ctx.lineWidth), height: parent.img.destHeight + (2 * ctx.lineWidth) };
|
|
3782
|
+
var frameObj = { type: parent.frameObj.type, color: parent.frameObj.color, size: parent.frameObj.size,
|
|
3783
|
+
inset: parent.frameObj.inset, offset: parent.frameObj.offset / 2, radius: parent.frameObj.radius,
|
|
3784
|
+
amount: parent.frameObj.amount, border: parent.frameObj.border, gradientColor: parent.frameObj.gradientColor };
|
|
3785
|
+
if (ctx.canvas.id === parent.element.id + '_tempCanvas') {
|
|
3786
|
+
var newWidth = void 0;
|
|
3787
|
+
var newHeight = void 0;
|
|
3788
|
+
newWidth = ctx.canvas.width;
|
|
3789
|
+
newHeight = ctx.canvas.height;
|
|
3790
|
+
var obj = { width: 0, height: 0 };
|
|
3791
|
+
parent.notify('crop', { prop: 'calcRatio', onPropertyChange: false,
|
|
3792
|
+
value: { obj: obj, dimension: { width: newWidth, height: newHeight } } });
|
|
3793
|
+
ratio = obj;
|
|
3794
|
+
frameObj.size *= ((ratio.width + ratio.height) / 2);
|
|
3795
|
+
frameObj.inset *= ((ratio.width + ratio.height) / 2);
|
|
3796
|
+
frameObj.offset *= ((ratio.width + ratio.height) / 2);
|
|
3797
|
+
frameObj.radius *= ((ratio.width + ratio.height) / 2);
|
|
3798
|
+
points = { startX: 0, startY: 0, width: ctx.canvas.width, height: ctx.canvas.height };
|
|
3799
|
+
}
|
|
3800
|
+
else if (isNullOrUndefined(preventImg)) {
|
|
3801
|
+
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
|
|
3802
|
+
}
|
|
3803
|
+
var valueForty = (40 * ((ratio.width + ratio.height) / 2));
|
|
3804
|
+
var valueFifty = (50 * ((ratio.width + ratio.height) / 2));
|
|
3805
|
+
frameObj.size += (frameObj.size * parent.transform.zoomFactor);
|
|
3806
|
+
frameObj.inset += (frameObj.inset * parent.transform.zoomFactor);
|
|
3807
|
+
frameObj.offset += (frameObj.offset * parent.transform.zoomFactor);
|
|
3808
|
+
frameObj.radius += (frameObj.radius * parent.transform.zoomFactor);
|
|
3809
|
+
valueForty += (valueForty * parent.transform.zoomFactor);
|
|
3810
|
+
valueFifty += (valueFifty * parent.transform.zoomFactor);
|
|
3811
|
+
var filter = ctx.filter;
|
|
3812
|
+
if ((parent.currSelectionPoint && parent.currSelectionPoint.shape === 'crop-circle') || parent.isCircleCrop) {
|
|
3813
|
+
this.drawImgToCtx(ctx, preventImg);
|
|
3814
|
+
}
|
|
3815
|
+
else {
|
|
3816
|
+
switch (frame) {
|
|
3817
|
+
case 'none':
|
|
3818
|
+
this.drawImgToCtx(ctx, preventImg);
|
|
3819
|
+
break;
|
|
3820
|
+
case 'mat':
|
|
3821
|
+
this.drawImgToCtx(ctx, preventImg);
|
|
3822
|
+
ctx.filter = 'none';
|
|
3823
|
+
ctx.fillStyle = this.getFrameColor(frameObj, ctx, points);
|
|
3824
|
+
ctx.beginPath();
|
|
3825
|
+
ctx.rect(points.startX, points.startY, points.width, points.height);
|
|
3826
|
+
ctx.rect(points.startX + frameObj.size, points.startY + frameObj.size, points.width -
|
|
3827
|
+
(2 * frameObj.size), points.height - (2 * frameObj.size));
|
|
3828
|
+
ctx.fill('evenodd');
|
|
3829
|
+
ctx.closePath();
|
|
3830
|
+
break;
|
|
3831
|
+
case 'bevel':
|
|
3832
|
+
ctx.filter = 'none';
|
|
3833
|
+
ctx.fillStyle = this.getFrameColor(frameObj, ctx, points);
|
|
3834
|
+
ctx.beginPath();
|
|
3835
|
+
ctx.fillRect(points.startX, points.startY, points.width, points.height);
|
|
3836
|
+
ctx.closePath();
|
|
3837
|
+
points.startX += frameObj.size;
|
|
3838
|
+
points.startY += frameObj.size;
|
|
3839
|
+
points.width -= (2 * frameObj.size);
|
|
3840
|
+
points.height -= (2 * frameObj.size);
|
|
3841
|
+
ctx.fillStyle = this.getFrameColor(frameObj, ctx, points);
|
|
3842
|
+
ctx.save();
|
|
3843
|
+
ctx.beginPath();
|
|
3844
|
+
ctx.moveTo(points.startX + valueForty, points.startY);
|
|
3845
|
+
ctx.lineTo(points.startX + points.width - valueForty, points.startY);
|
|
3846
|
+
ctx.quadraticCurveTo(points.startX + points.width, points.startY, points.startX + points.width, points.startY + valueForty);
|
|
3847
|
+
ctx.lineTo(points.startX + points.width, points.startY + points.height - valueForty);
|
|
3848
|
+
ctx.quadraticCurveTo(points.startX + points.width, points.startY + points.height, points.startX + points.width - valueForty, points.startY + points.height);
|
|
3849
|
+
ctx.lineTo(points.startX + valueForty, points.startY + points.height);
|
|
3850
|
+
ctx.quadraticCurveTo(points.startX, points.startY + points.height, points.startX, points.startY + points.height - valueForty);
|
|
3851
|
+
ctx.lineTo(points.startX, points.startY + valueForty);
|
|
3852
|
+
ctx.quadraticCurveTo(points.startX, points.startY, points.startX + valueForty, points.startY);
|
|
3853
|
+
ctx.closePath();
|
|
3854
|
+
ctx.clip();
|
|
3855
|
+
ctx.filter = filter === 'none' ? parent.canvasFilter : filter;
|
|
3856
|
+
if (ctx.canvas.id === parent.element.id + '_tempCanvas') {
|
|
3857
|
+
if (preventImg) {
|
|
3858
|
+
preventImg = null;
|
|
3859
|
+
ctx.drawImage(parent.baseImg, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, 0, 0, ctx.canvas.width, ctx.canvas.height);
|
|
3860
|
+
parent.frameObj.type = 'none';
|
|
3861
|
+
ctx.filter = 'none';
|
|
3862
|
+
parent.notify('export', { prop: 'drawAnnotation', onPropertyChange: false,
|
|
3863
|
+
value: { context: ctx, ratio: ratio } });
|
|
3864
|
+
parent.frameObj.type = 'bevel';
|
|
3865
|
+
ctx.filter = filter === 'none' ? parent.canvasFilter : filter;
|
|
3866
|
+
}
|
|
3867
|
+
else {
|
|
3868
|
+
ctx.drawImage(parent.baseImg, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, 0, 0, ctx.canvas.width, ctx.canvas.height);
|
|
3869
|
+
}
|
|
3870
|
+
}
|
|
3871
|
+
else {
|
|
3872
|
+
if (preventImg) {
|
|
3873
|
+
preventImg = null;
|
|
3874
|
+
if (parent.transform.zoomFactor !== 0) {
|
|
3875
|
+
this.isRotateZoom = true;
|
|
3876
|
+
}
|
|
3877
|
+
this.updateCurrTransState('initial');
|
|
3878
|
+
this.drawImgToCtx(ctx, preventImg);
|
|
3879
|
+
this.updateCurrTransState('reverse');
|
|
3880
|
+
this.isRotateZoom = false;
|
|
3881
|
+
parent.frameObj.type = 'none';
|
|
3882
|
+
ctx.filter = 'none';
|
|
3883
|
+
parent.notify('shape', { prop: 'iterateObjColl', onPropertyChange: false });
|
|
3884
|
+
parent.notify('freehand-draw', { prop: 'freehandRedraw', onPropertyChange: false,
|
|
3885
|
+
value: { context: ctx, points: null } });
|
|
3886
|
+
parent.frameObj.type = 'bevel';
|
|
3887
|
+
ctx.filter = filter === 'none' ? parent.canvasFilter : filter;
|
|
3888
|
+
}
|
|
3889
|
+
else {
|
|
3890
|
+
this.drawImgToCtx(ctx, preventImg);
|
|
3891
|
+
}
|
|
3892
|
+
}
|
|
3893
|
+
ctx.restore();
|
|
3894
|
+
break;
|
|
3895
|
+
case 'line':
|
|
3896
|
+
this.drawImgToCtx(ctx, preventImg);
|
|
3897
|
+
tempLineWidth = ctx.lineWidth;
|
|
3898
|
+
ctx.lineWidth = frameObj.size / 10;
|
|
3899
|
+
for (var i = 0; i < parent.frameObj.amount; i++) {
|
|
3900
|
+
if (i > 0) {
|
|
3901
|
+
points.startX += frameObj.offset;
|
|
3902
|
+
points.startY += frameObj.offset;
|
|
3903
|
+
points.width -= (2 * frameObj.offset);
|
|
3904
|
+
points.height -= (2 * frameObj.offset);
|
|
3905
|
+
}
|
|
3906
|
+
var arcY2 = points.startY + points.height - frameObj.inset - frameObj.radius;
|
|
3907
|
+
var lineY = points.startY + frameObj.inset + frameObj.radius;
|
|
3908
|
+
var arcX2 = points.startX + points.width - frameObj.inset - frameObj.radius;
|
|
3909
|
+
var lineX = points.startX + frameObj.inset + frameObj.radius;
|
|
3910
|
+
var arcX1 = points.startX + frameObj.inset + frameObj.radius;
|
|
3911
|
+
var lineX2 = points.startX + points.width - frameObj.inset - frameObj.radius;
|
|
3912
|
+
var arcY1 = points.startY + frameObj.inset + frameObj.radius;
|
|
3913
|
+
var lineY2 = points.startY + points.height - frameObj.inset - frameObj.radius;
|
|
3914
|
+
if (arcY2 >= lineY && arcX2 >= lineX && arcX1 <= lineX2 && arcY1 <= lineY2) {
|
|
3915
|
+
ctx.filter = 'none';
|
|
3916
|
+
ctx.strokeStyle = this.getFrameColor(frameObj, ctx, points);
|
|
3917
|
+
if (frameObj.border === 'dashed') {
|
|
3918
|
+
ctx.setLineDash([ctx.lineWidth * 2.5, ctx.lineWidth * 1.5]);
|
|
3919
|
+
}
|
|
3920
|
+
else if (frameObj.border === 'dotted') {
|
|
3921
|
+
ctx.setLineDash([ctx.lineWidth, ctx.lineWidth]);
|
|
3922
|
+
}
|
|
3923
|
+
ctx.beginPath();
|
|
3924
|
+
ctx.moveTo(points.startX + frameObj.inset + frameObj.radius, points.startY + frameObj.inset);
|
|
3925
|
+
ctx.lineTo(points.startX + points.width - frameObj.inset - frameObj.radius, points.startY + frameObj.inset);
|
|
3926
|
+
ctx.arcTo(points.startX + points.width - frameObj.inset, points.startY + frameObj.inset, points.startX + points.width - frameObj.inset, points.startY + frameObj.inset + frameObj.radius, frameObj.radius);
|
|
3927
|
+
ctx.lineTo(points.startX + points.width - frameObj.inset, points.startY + points.height - frameObj.inset -
|
|
3928
|
+
frameObj.radius);
|
|
3929
|
+
ctx.arcTo(points.startX + points.width - frameObj.inset, points.startY + points.height - frameObj.inset, points.startX + points.width - frameObj.inset - frameObj.radius, points.startY + points.height
|
|
3930
|
+
- frameObj.inset, frameObj.radius);
|
|
3931
|
+
ctx.lineTo(points.startX + frameObj.inset + frameObj.radius, points.startY + points.height - frameObj.inset);
|
|
3932
|
+
ctx.arcTo(points.startX + frameObj.inset, points.startY + points.height - frameObj.inset, points.startX + frameObj.inset, points.startY + points.height - frameObj.inset - frameObj.radius, frameObj.radius);
|
|
3933
|
+
ctx.lineTo(points.startX + frameObj.inset, points.startY + frameObj.inset + frameObj.radius);
|
|
3934
|
+
ctx.arcTo(points.startX + frameObj.inset, points.startY + frameObj.inset, points.startX + frameObj.inset + frameObj.radius, points.startY + frameObj.inset, frameObj.radius);
|
|
3935
|
+
ctx.closePath();
|
|
3936
|
+
ctx.stroke();
|
|
3937
|
+
ctx.setLineDash([]);
|
|
3938
|
+
}
|
|
3939
|
+
}
|
|
3940
|
+
ctx.lineWidth = tempLineWidth;
|
|
3941
|
+
break;
|
|
3942
|
+
case 'inset':
|
|
3943
|
+
this.drawImgToCtx(ctx, preventImg);
|
|
3944
|
+
ctx.filter = 'none';
|
|
3945
|
+
ctx.strokeStyle = this.getFrameColor(frameObj, ctx, points);
|
|
3946
|
+
tempLineWidth = ctx.lineWidth;
|
|
3947
|
+
ctx.lineWidth = frameObj.size / 10;
|
|
3948
|
+
ctx.beginPath();
|
|
3949
|
+
ctx.moveTo(points.startX + frameObj.offset, points.startY + frameObj.inset);
|
|
3950
|
+
ctx.lineTo(points.startX + points.width - frameObj.offset, points.startY + frameObj.inset);
|
|
3951
|
+
ctx.moveTo(points.startX + points.width - frameObj.inset, points.startY + frameObj.offset);
|
|
3952
|
+
ctx.lineTo(points.startX + points.width - frameObj.inset, points.startY + points.height - frameObj.offset);
|
|
3953
|
+
ctx.moveTo(points.startX + points.width - frameObj.offset, points.startY + points.height - frameObj.inset);
|
|
3954
|
+
ctx.lineTo(points.startX + frameObj.offset, points.startY + points.height - frameObj.inset);
|
|
3955
|
+
ctx.moveTo(points.startX + frameObj.inset, points.startY + points.height - frameObj.offset);
|
|
3956
|
+
ctx.lineTo(points.startX + frameObj.inset, points.startY + frameObj.offset);
|
|
3957
|
+
ctx.stroke();
|
|
3958
|
+
ctx.closePath();
|
|
3959
|
+
ctx.lineWidth = tempLineWidth;
|
|
3960
|
+
break;
|
|
3961
|
+
case 'hook':
|
|
3962
|
+
this.drawImgToCtx(ctx, preventImg);
|
|
3963
|
+
ctx.filter = 'none';
|
|
3964
|
+
ctx.strokeStyle = this.getFrameColor(frameObj, ctx, points);
|
|
3965
|
+
tempLineWidth = ctx.lineWidth;
|
|
3966
|
+
ctx.lineWidth = frameObj.size / 10;
|
|
3967
|
+
ctx.beginPath();
|
|
3968
|
+
ctx.moveTo(points.startX + frameObj.inset + valueFifty, points.startY + frameObj.inset);
|
|
3969
|
+
ctx.lineTo(points.startX + frameObj.inset, points.startY + frameObj.inset);
|
|
3970
|
+
ctx.lineTo(points.startX + frameObj.inset, points.startY + frameObj.inset + valueFifty);
|
|
3971
|
+
ctx.moveTo(points.startX + points.width - frameObj.inset - valueFifty, points.startY + frameObj.inset);
|
|
3972
|
+
ctx.lineTo(points.startX + points.width - frameObj.inset, points.startY + frameObj.inset);
|
|
3973
|
+
ctx.lineTo(points.startX + points.width - frameObj.inset, points.startY + frameObj.inset + valueFifty);
|
|
3974
|
+
ctx.moveTo(points.startX + points.width - frameObj.inset - valueFifty, points.startY + points.height - frameObj.inset);
|
|
3975
|
+
ctx.lineTo(points.startX + points.width - frameObj.inset, points.startY + points.height - frameObj.inset);
|
|
3976
|
+
ctx.lineTo(points.startX + points.width - frameObj.inset, points.startY + points.height - frameObj.inset - valueFifty);
|
|
3977
|
+
ctx.moveTo(points.startX + frameObj.inset + valueFifty, points.startY + points.height - frameObj.inset);
|
|
3978
|
+
ctx.lineTo(points.startX + frameObj.inset, points.startY + points.height - frameObj.inset);
|
|
3979
|
+
ctx.lineTo(points.startX + frameObj.inset, points.startY + points.height - frameObj.inset - valueFifty);
|
|
3980
|
+
ctx.stroke();
|
|
3981
|
+
ctx.lineWidth = tempLineWidth;
|
|
3982
|
+
break;
|
|
3983
|
+
}
|
|
3984
|
+
if (parent.isCircleCrop || (parent.currSelectionPoint && parent.currSelectionPoint.shape === 'crop-circle')) {
|
|
3985
|
+
parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
|
|
3986
|
+
value: { context: ctx, isSave: ctx.canvas.id === parent.element.id + '_tempCanvas' ? true : null, isFlip: null } });
|
|
3987
|
+
}
|
|
3988
|
+
ctx.filter = filter;
|
|
3989
|
+
}
|
|
3990
|
+
};
|
|
3991
|
+
Draw.prototype.triggerFrameChange = function (prevFrameSettings) {
|
|
3992
|
+
var _this = this;
|
|
3993
|
+
var parent = this.parent;
|
|
3994
|
+
var currFrameSettings = { type: parent.toPascalCase(parent.frameObj.type), color: parent.frameObj.color,
|
|
3995
|
+
gradientColor: parent.frameObj.gradientColor, size: parent.frameObj.size, inset: parent.frameObj.inset,
|
|
3996
|
+
offset: parent.frameObj.offset, borderRadius: parent.frameObj.radius, frameLineStyle: parent.toPascalCase(parent.frameObj.border),
|
|
3997
|
+
lineCount: parent.frameObj.amount };
|
|
3998
|
+
var frameChange = { cancel: false, previousFrameSetting: prevFrameSettings, currentFrameSetting: currFrameSettings };
|
|
3999
|
+
if (isBlazor()) {
|
|
4000
|
+
if (parent.events && parent.events.frameChanging.hasDelegate === true) {
|
|
4001
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
4002
|
+
parent.dotNetRef.invokeMethodAsync('OnFrameChangingAsync', frameChange).then(function (args) {
|
|
4003
|
+
if (!args.cancel) {
|
|
4004
|
+
_this.setFrameObj(args.currentFrameSetting);
|
|
4005
|
+
var obj = { currObj: {} };
|
|
4006
|
+
parent.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: obj } });
|
|
4007
|
+
parent.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false, value: {
|
|
4008
|
+
operation: 'frame', previousObj: obj['currObj'], previousObjColl: obj['currObj']['objColl'],
|
|
4009
|
+
previousPointColl: obj['currObj']['pointColl'], previousSelPointColl: obj['currObj']['selPointColl'],
|
|
4010
|
+
previousCropObj: extend({}, parent.cropObj, {}, true), previousText: null, currentText: null,
|
|
4011
|
+
previousFilter: null, isCircleCrop: null
|
|
4012
|
+
} });
|
|
4013
|
+
var fillColorDiv = parent.element.querySelector('.e-ie-toolbar-e-frame-color');
|
|
4014
|
+
if (fillColorDiv) {
|
|
4015
|
+
parent.element.querySelector('.e-ie-toolbar-e-frame-color' + parent.DDBPREVIEW).style.background = parent.frameObj.color;
|
|
4016
|
+
}
|
|
4017
|
+
var graColorDiv = parent.element.querySelector('.e-ie-toolbar-e-frame-gradient');
|
|
4018
|
+
if (graColorDiv) {
|
|
4019
|
+
var noColorDiv = document.querySelector('.e-dropdown-popup.e-frame-gradient-dd-btn');
|
|
4020
|
+
if (noColorDiv) {
|
|
4021
|
+
noColorDiv.querySelector('.e-nocolor-item').classList.remove('e-selected');
|
|
4022
|
+
}
|
|
4023
|
+
parent.element.querySelector('.e-ie-toolbar-e-frame-gradient' + parent.DDBPREVIEW).classList.remove('e-nocolor-item');
|
|
4024
|
+
if (parent.frameObj.gradientColor == '') {
|
|
4025
|
+
parent.element.querySelector('.e-ie-toolbar-e-frame-gradient' + parent.DDBPREVIEW).classList.add('e-nocolor-item');
|
|
4026
|
+
}
|
|
4027
|
+
else {
|
|
4028
|
+
parent.element.querySelector('.e-ie-toolbar-e-frame-gradient' + parent.DDBPREVIEW).style.background = parent.frameObj.gradientColor;
|
|
4029
|
+
}
|
|
4030
|
+
}
|
|
4031
|
+
parent.notify('draw', { prop: 'render-image', value: { isMouseWheel: null } });
|
|
4032
|
+
}
|
|
4033
|
+
});
|
|
4034
|
+
}
|
|
4035
|
+
else {
|
|
4036
|
+
if (!frameChange.cancel) {
|
|
4037
|
+
this.setFrameObj(frameChange.currentFrameSetting);
|
|
4038
|
+
}
|
|
4039
|
+
}
|
|
4040
|
+
}
|
|
4041
|
+
else {
|
|
4042
|
+
parent.trigger('frameChange', frameChange);
|
|
4043
|
+
if (!frameChange.cancel) {
|
|
4044
|
+
this.setFrameObj(frameChange.currentFrameSetting);
|
|
4045
|
+
}
|
|
4046
|
+
}
|
|
4047
|
+
return frameChange;
|
|
4048
|
+
};
|
|
4049
|
+
Draw.prototype.setFrameObj = function (currFrameSettings) {
|
|
4050
|
+
var parent = this.parent;
|
|
4051
|
+
parent.frameObj.type = currFrameSettings.type.toLowerCase();
|
|
4052
|
+
parent.frameObj.color = currFrameSettings.color;
|
|
4053
|
+
parent.frameObj.gradientColor = currFrameSettings.gradientColor;
|
|
4054
|
+
parent.frameObj.size = currFrameSettings.size;
|
|
4055
|
+
parent.frameObj.inset = currFrameSettings.inset;
|
|
4056
|
+
parent.frameObj.offset = currFrameSettings.offset;
|
|
4057
|
+
parent.frameObj.radius = currFrameSettings.borderRadius;
|
|
4058
|
+
parent.frameObj.border = currFrameSettings.frameLineStyle.toLowerCase();
|
|
4059
|
+
parent.frameObj.amount = currFrameSettings.lineCount;
|
|
4060
|
+
};
|
|
3315
4061
|
return Draw;
|
|
3316
4062
|
}());
|
|
3317
4063
|
export { Draw };
|