@syncfusion/ej2-image-editor 26.2.10 → 27.1.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/ej2-image-editor.umd.min.js +2 -2
- package/dist/ej2-image-editor.umd.min.js.map +1 -1
- package/dist/es6/ej2-image-editor.es2015.js +3207 -732
- package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
- package/dist/es6/ej2-image-editor.es5.js +3286 -797
- 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 +14 -13
- package/src/image-editor/action/crop.d.ts +0 -1
- package/src/image-editor/action/crop.js +8 -19
- package/src/image-editor/action/draw.d.ts +4 -0
- package/src/image-editor/action/draw.js +377 -45
- package/src/image-editor/action/export.js +21 -13
- package/src/image-editor/action/filter.d.ts +13 -0
- package/src/image-editor/action/filter.js +272 -1
- package/src/image-editor/action/freehand-draw.d.ts +1 -0
- package/src/image-editor/action/freehand-draw.js +44 -23
- package/src/image-editor/action/selection.d.ts +6 -0
- package/src/image-editor/action/selection.js +382 -97
- package/src/image-editor/action/shape.d.ts +5 -0
- package/src/image-editor/action/shape.js +287 -141
- package/src/image-editor/action/transform.js +56 -82
- package/src/image-editor/action/undo-redo.d.ts +2 -0
- package/src/image-editor/action/undo-redo.js +100 -1
- package/src/image-editor/base/enum.d.ts +11 -0
- package/src/image-editor/base/enum.js +12 -0
- package/src/image-editor/base/image-editor-model.d.ts +13 -1
- package/src/image-editor/base/image-editor.d.ts +142 -20
- package/src/image-editor/base/image-editor.js +816 -149
- package/src/image-editor/base/interface.d.ts +140 -1
- package/src/image-editor/renderer/toolbar.d.ts +8 -0
- package/src/image-editor/renderer/toolbar.js +873 -191
- package/styles/bootstrap-dark-lite.css +746 -0
- package/styles/bootstrap-dark-lite.scss +13 -0
- package/styles/bootstrap-dark.css +150 -105
- package/styles/bootstrap-dark.scss +1 -0
- package/styles/bootstrap-lite.css +747 -0
- package/styles/bootstrap-lite.scss +13 -0
- package/styles/bootstrap.css +151 -106
- package/styles/bootstrap.scss +1 -0
- package/styles/bootstrap4-lite.css +747 -0
- package/styles/bootstrap4-lite.scss +13 -0
- package/styles/bootstrap4.css +150 -105
- package/styles/bootstrap4.scss +1 -0
- package/styles/bootstrap5-dark-lite.css +757 -0
- package/styles/bootstrap5-dark-lite.scss +13 -0
- package/styles/bootstrap5-dark.css +152 -113
- package/styles/bootstrap5-dark.scss +1 -0
- package/styles/bootstrap5-lite.css +757 -0
- package/styles/bootstrap5-lite.scss +13 -0
- package/styles/bootstrap5.3-lite.css +760 -0
- package/styles/bootstrap5.3-lite.scss +13 -0
- package/styles/bootstrap5.3.css +867 -0
- package/styles/bootstrap5.3.scss +14 -0
- package/styles/bootstrap5.css +152 -113
- package/styles/bootstrap5.scss +1 -0
- package/styles/fabric-dark-lite.css +749 -0
- package/styles/fabric-dark-lite.scss +13 -0
- package/styles/fabric-dark.css +150 -105
- package/styles/fabric-dark.scss +1 -0
- package/styles/fabric-lite.css +751 -0
- package/styles/fabric-lite.scss +13 -0
- package/styles/fabric.css +151 -106
- package/styles/fabric.scss +1 -0
- package/styles/fluent-dark-lite.css +758 -0
- package/styles/fluent-dark-lite.scss +13 -0
- package/styles/fluent-dark.css +150 -111
- package/styles/fluent-dark.scss +1 -0
- package/styles/fluent-lite.css +758 -0
- package/styles/fluent-lite.scss +13 -0
- package/styles/fluent.css +150 -111
- package/styles/fluent.scss +1 -0
- package/styles/fluent2-lite.css +791 -0
- package/styles/fluent2-lite.scss +13 -0
- package/styles/fluent2.css +173 -117
- package/styles/fluent2.scss +1 -0
- package/styles/highcontrast-light-lite.css +748 -0
- package/styles/highcontrast-light-lite.scss +13 -0
- package/styles/highcontrast-light.css +149 -104
- package/styles/highcontrast-light.scss +1 -0
- package/styles/highcontrast-lite.css +753 -0
- package/styles/highcontrast-lite.scss +13 -0
- package/styles/highcontrast.css +150 -104
- package/styles/highcontrast.scss +1 -0
- package/styles/image-editor/_bds-definition.scss +3 -1
- package/styles/image-editor/_bigger.scss +216 -0
- package/styles/image-editor/_bootstrap-dark-definition.scss +3 -1
- package/styles/image-editor/_bootstrap-definition.scss +3 -1
- package/styles/image-editor/_bootstrap4-definition.scss +3 -1
- package/styles/image-editor/_bootstrap5-definition.scss +3 -1
- package/styles/image-editor/_bootstrap5.3-definition.scss +3 -1
- package/styles/image-editor/_fabric-dark-definition.scss +3 -1
- package/styles/image-editor/_fabric-definition.scss +3 -1
- package/styles/image-editor/_fluent-definition.scss +3 -1
- package/styles/image-editor/_fluent2-definition.scss +4 -2
- package/styles/image-editor/_fusionnew-definition.scss +3 -1
- package/styles/image-editor/_highcontrast-definition.scss +3 -1
- package/styles/image-editor/_highcontrast-light-definition.scss +3 -1
- package/styles/image-editor/_layout.scss +75 -212
- package/styles/image-editor/_material-dark-definition.scss +3 -1
- package/styles/image-editor/_material-definition.scss +3 -1
- package/styles/image-editor/_material3-definition.scss +5 -3
- package/styles/image-editor/_tailwind-definition.scss +5 -3
- package/styles/image-editor/_theme.scss +48 -11
- package/styles/image-editor/bootstrap-dark.css +150 -105
- package/styles/image-editor/bootstrap-dark.scss +1 -0
- package/styles/image-editor/bootstrap.css +151 -106
- package/styles/image-editor/bootstrap.scss +1 -0
- package/styles/image-editor/bootstrap4.css +150 -105
- package/styles/image-editor/bootstrap4.scss +1 -0
- package/styles/image-editor/bootstrap5-dark.css +152 -113
- package/styles/image-editor/bootstrap5-dark.scss +1 -0
- package/styles/image-editor/bootstrap5.3.css +867 -0
- package/styles/image-editor/bootstrap5.3.scss +14 -0
- package/styles/image-editor/bootstrap5.css +152 -113
- package/styles/image-editor/bootstrap5.scss +1 -0
- package/styles/image-editor/fabric-dark.css +150 -105
- package/styles/image-editor/fabric-dark.scss +1 -0
- package/styles/image-editor/fabric.css +151 -106
- package/styles/image-editor/fabric.scss +1 -0
- package/styles/image-editor/fluent-dark.css +150 -111
- package/styles/image-editor/fluent-dark.scss +1 -0
- package/styles/image-editor/fluent.css +150 -111
- package/styles/image-editor/fluent.scss +1 -0
- package/styles/image-editor/fluent2.css +173 -117
- package/styles/image-editor/fluent2.scss +1 -0
- package/styles/image-editor/highcontrast-light.css +149 -104
- package/styles/image-editor/highcontrast-light.scss +1 -0
- package/styles/image-editor/highcontrast.css +150 -104
- package/styles/image-editor/highcontrast.scss +1 -0
- package/styles/image-editor/icons/_bds.scss +10 -1
- package/styles/image-editor/icons/_bootstrap-dark.scss +10 -1
- package/styles/image-editor/icons/_bootstrap.scss +10 -1
- package/styles/image-editor/icons/_bootstrap4.scss +10 -1
- package/styles/image-editor/icons/_bootstrap5.3.scss +10 -1
- package/styles/image-editor/icons/_bootstrap5.scss +10 -1
- package/styles/image-editor/icons/_fabric-dark.scss +10 -1
- package/styles/image-editor/icons/_fabric.scss +10 -1
- package/styles/image-editor/icons/_fluent.scss +10 -1
- package/styles/image-editor/icons/_fluent2.scss +10 -1
- package/styles/image-editor/icons/_fusionnew.scss +10 -1
- package/styles/image-editor/icons/_highcontrast-light.scss +10 -1
- package/styles/image-editor/icons/_highcontrast.scss +10 -1
- package/styles/image-editor/icons/_material-dark.scss +10 -1
- package/styles/image-editor/icons/_material.scss +10 -1
- package/styles/image-editor/icons/_material3.scss +10 -1
- package/styles/image-editor/icons/_tailwind.scss +10 -1
- package/styles/image-editor/material-dark.css +153 -108
- package/styles/image-editor/material-dark.scss +1 -0
- package/styles/image-editor/material.css +159 -114
- package/styles/image-editor/material.scss +1 -0
- package/styles/image-editor/material3-dark.css +171 -123
- package/styles/image-editor/material3-dark.scss +1 -0
- package/styles/image-editor/material3.css +171 -123
- package/styles/image-editor/material3.scss +1 -0
- package/styles/image-editor/tailwind-dark.css +154 -116
- package/styles/image-editor/tailwind-dark.scss +1 -0
- package/styles/image-editor/tailwind.css +154 -116
- package/styles/image-editor/tailwind.scss +1 -0
- package/styles/material-dark-lite.css +767 -0
- package/styles/material-dark-lite.scss +13 -0
- package/styles/material-dark.css +153 -108
- package/styles/material-dark.scss +1 -0
- package/styles/material-lite.css +769 -0
- package/styles/material-lite.scss +13 -0
- package/styles/material.css +159 -114
- package/styles/material.scss +1 -0
- package/styles/material3-dark-lite.css +799 -0
- package/styles/material3-dark-lite.scss +13 -0
- package/styles/material3-dark.css +171 -123
- package/styles/material3-dark.scss +1 -0
- package/styles/material3-lite.css +801 -0
- package/styles/material3-lite.scss +13 -0
- package/styles/material3.css +171 -123
- package/styles/material3.scss +1 -0
- package/styles/tailwind-dark-lite.css +751 -0
- package/styles/tailwind-dark-lite.scss +13 -0
- package/styles/tailwind-dark.css +154 -116
- package/styles/tailwind-dark.scss +1 -0
- package/styles/tailwind-lite.css +751 -0
- package/styles/tailwind-lite.scss +13 -0
- package/styles/tailwind.css +154 -116
- package/styles/tailwind.scss +1 -0
- package/hotfix/26.1.35_Vol2.txt +0 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
1
2
|
import { extend, isNullOrUndefined } from '@syncfusion/ej2-base';
|
|
2
3
|
import { hideSpinner, showSpinner } from '@syncfusion/ej2-popups';
|
|
3
4
|
var Export = /** @class */ (function () {
|
|
@@ -34,6 +35,10 @@ var Export = /** @class */ (function () {
|
|
|
34
35
|
break;
|
|
35
36
|
case 'setImageQuality':
|
|
36
37
|
this.imageQuality = args.value['value'];
|
|
38
|
+
break;
|
|
39
|
+
case 'drawAnnotation':
|
|
40
|
+
this.drawAnnotation(args.value['context'], args.value['ratio']);
|
|
41
|
+
break;
|
|
37
42
|
}
|
|
38
43
|
};
|
|
39
44
|
Export.prototype.getModuleName = function () {
|
|
@@ -51,19 +56,6 @@ var Export = /** @class */ (function () {
|
|
|
51
56
|
parent.notify('draw', { prop: 'getFileName', onPropertyChange: false, value: { obj: obj } });
|
|
52
57
|
var imageName = obj['fileName'];
|
|
53
58
|
if (!parent.disabled && parent.isImageLoaded) {
|
|
54
|
-
var dummyObj = { bool: false };
|
|
55
|
-
parent.notify('selection', { prop: 'getFreehandDrawEditing', onPropertyChange: false, value: { obj: dummyObj } });
|
|
56
|
-
if (dummyObj['bool']) {
|
|
57
|
-
parent.notify('freehand-draw', { prop: 'applyFhd', onPropertyChange: false });
|
|
58
|
-
}
|
|
59
|
-
if (parent.togglePen) {
|
|
60
|
-
parent.currObjType.isZoomed = true;
|
|
61
|
-
parent.notify('shape', { prop: 'apply', onPropertyChange: false, value: { shape: null, obj: null, canvas: null } });
|
|
62
|
-
}
|
|
63
|
-
if (parent.textArea.style.display === 'block' || parent.textArea.style.display === 'inline-block') {
|
|
64
|
-
parent.notify('shape', { prop: 'redrawActObj', onPropertyChange: false,
|
|
65
|
-
value: { x: null, y: null, isMouseDown: null } });
|
|
66
|
-
}
|
|
67
59
|
parent.notify('shape', { prop: 'applyActObj', onPropertyChange: false, value: { isMouseDown: null } });
|
|
68
60
|
var obj_1 = { canvasFilter: this.parent.canvasFilter };
|
|
69
61
|
this.lowerContext.filter = obj_1['canvasFilter'];
|
|
@@ -91,6 +83,8 @@ var Export = /** @class */ (function () {
|
|
|
91
83
|
}
|
|
92
84
|
var saved = { fileName: fileName ? fileName : imageName, fileType: type };
|
|
93
85
|
parent.trigger('saved', saved);
|
|
86
|
+
var actionArgs = { action: 'save', actionEventArgs: saved };
|
|
87
|
+
parent.triggerEditCompleteEvent(actionArgs);
|
|
94
88
|
parent.notify('toolbar', { prop: 'refresh-main-toolbar', onPropertyChange: false });
|
|
95
89
|
parent.lowerCanvas.style.left = parent.upperCanvas.style.left = '';
|
|
96
90
|
parent.lowerCanvas.style.top = parent.upperCanvas.style.top = '';
|
|
@@ -219,6 +213,9 @@ var Export = /** @class */ (function () {
|
|
|
219
213
|
this.updateSaveContext(tempContext);
|
|
220
214
|
this.exportTransformedImage(tempContext);
|
|
221
215
|
}
|
|
216
|
+
if (parent.isSafari) {
|
|
217
|
+
parent.notify('filter', { prop: 'apply-filter', onPropertyChange: false, value: { context: tempContext } });
|
|
218
|
+
}
|
|
222
219
|
this.drawAnnotation(tempContext, ratio);
|
|
223
220
|
if (parent.isCircleCrop) {
|
|
224
221
|
parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
|
|
@@ -262,6 +259,11 @@ var Export = /** @class */ (function () {
|
|
|
262
259
|
var tempObjColl = extend([], parent.objColl, [], true);
|
|
263
260
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
264
261
|
var tempPointColl = extend([], parent.pointColl, [], true);
|
|
262
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
263
|
+
var nonRedact = parent.shapeColl.filter(function (item) { return item.shape !== 'redact'; });
|
|
264
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
265
|
+
var redact = parent.shapeColl.filter(function (item) { return item.shape === 'redact'; });
|
|
266
|
+
parent.shapeColl = redact.concat(nonRedact);
|
|
265
267
|
for (var i = 0; i < parent.shapeColl.length; i++) {
|
|
266
268
|
if (parent.shapeColl[i].order) {
|
|
267
269
|
if (parent.shapeColl[i].currIndex && parent.shapeColl[i].currIndex.indexOf('shape') > -1) {
|
|
@@ -391,6 +393,12 @@ var Export = /** @class */ (function () {
|
|
|
391
393
|
var obj = { width: 0, height: 0 };
|
|
392
394
|
parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
|
|
393
395
|
value: { width: img.width, height: img.height, obj: obj, isImgShape: null } });
|
|
396
|
+
var bgObj = { color: null };
|
|
397
|
+
parent.notify('draw', { prop: 'getImageBackgroundColor', value: { obj: bgObj } });
|
|
398
|
+
if (bgObj['color'] !== '') {
|
|
399
|
+
ctx.fillStyle = bgObj['color'];
|
|
400
|
+
ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
|
|
401
|
+
}
|
|
394
402
|
if (obj['width'] > width && obj['height'] > height) {
|
|
395
403
|
var tempCanvas = parent.createElement('canvas', {
|
|
396
404
|
id: parent.element.id + '_downScaleCanvas', attrs: { name: 'canvasImage' }
|
|
@@ -32,4 +32,17 @@ export declare class Filter {
|
|
|
32
32
|
private finetuneImage;
|
|
33
33
|
private setCurrAdjValue;
|
|
34
34
|
private getCurrentObj;
|
|
35
|
+
private getValFromPercentage;
|
|
36
|
+
private getValFromLength;
|
|
37
|
+
private parseFilterString;
|
|
38
|
+
private applyFilter;
|
|
39
|
+
private blur;
|
|
40
|
+
private brightness;
|
|
41
|
+
private contrast;
|
|
42
|
+
private grayscale;
|
|
43
|
+
private hueRotate;
|
|
44
|
+
private invert;
|
|
45
|
+
private opacity;
|
|
46
|
+
private saturate;
|
|
47
|
+
private sepia;
|
|
35
48
|
}
|
|
@@ -100,6 +100,9 @@ var Filter = /** @class */ (function () {
|
|
|
100
100
|
case 'reset':
|
|
101
101
|
this.reset();
|
|
102
102
|
break;
|
|
103
|
+
case 'apply-filter':
|
|
104
|
+
this.applyFilter(args.value['context']);
|
|
105
|
+
break;
|
|
103
106
|
}
|
|
104
107
|
};
|
|
105
108
|
Filter.prototype.updatePrivateVariables = function () {
|
|
@@ -599,13 +602,15 @@ var Filter = /** @class */ (function () {
|
|
|
599
602
|
parent.notify('transform', { prop: 'getPreviousZoomValue', value: { obj: zoomObj } });
|
|
600
603
|
var straightenObj = { zoomFactor: null };
|
|
601
604
|
parent.notify('draw', { prop: 'getStraightenInitZoom', value: { obj: straightenObj } });
|
|
605
|
+
var bgObj = { color: null };
|
|
606
|
+
parent.notify('draw', { prop: 'getImageBackgroundColor', value: { obj: bgObj } });
|
|
602
607
|
var obj = { cropZoom: 0, defaultZoom: 0, totalPannedPoint: { x: 0, y: 0 }, totalPannedClientPoint: { x: 0, y: 0 },
|
|
603
608
|
totalPannedInternalPoint: { x: 0, y: 0 }, tempFlipPanPoint: { x: 0, y: 0 }, activeObj: {},
|
|
604
609
|
rotateFlipColl: [], degree: 0, currFlipState: '', zoomFactor: 0, previousZoomValue: 0, straighten: 0,
|
|
605
610
|
destPoints: { startX: 0, startY: 0, width: 0, height: 0 }, frame: 'none',
|
|
606
611
|
srcPoints: { startX: 0, startY: 0, width: 0, height: 0 }, filter: '', isBrightAdjust: this.isBrightnessAdjusted,
|
|
607
612
|
aspectWidth: null, aspectHeight: null, straightenZoom: 0, adjustmentLevel: extend({}, this.tempAdjVal, {}, true),
|
|
608
|
-
currentFilter: this.tempFilVal };
|
|
613
|
+
currentFilter: this.tempFilVal, imageSource: '', bgColor: '' };
|
|
609
614
|
obj.cropZoom = parent.transform.cropZoomFactor;
|
|
610
615
|
obj.defaultZoom = parent.transform.defaultZoomFactor;
|
|
611
616
|
obj.zoomFactor = parent.zoomSettings.zoomFactor;
|
|
@@ -629,11 +634,277 @@ var Filter = /** @class */ (function () {
|
|
|
629
634
|
obj.aspectHeight = parent.aspectHeight;
|
|
630
635
|
obj.frame = parent.frameObj.type;
|
|
631
636
|
obj.frameObj = extend({}, parent.frameObj);
|
|
637
|
+
obj.imageSource = parent.baseImg.src;
|
|
638
|
+
obj.bgColor = bgObj['color'];
|
|
632
639
|
if (dummyObj) {
|
|
633
640
|
dummyObj['currObj'] = obj;
|
|
634
641
|
}
|
|
635
642
|
return obj;
|
|
636
643
|
};
|
|
644
|
+
/* Filter safari related codes */
|
|
645
|
+
Filter.prototype.getValFromPercentage = function (percentage) {
|
|
646
|
+
var val = parseFloat(percentage);
|
|
647
|
+
// check for percentages and divide by a hundred
|
|
648
|
+
if (/%\s*?$/i.test(percentage)) {
|
|
649
|
+
val /= 100;
|
|
650
|
+
}
|
|
651
|
+
return val;
|
|
652
|
+
};
|
|
653
|
+
Filter.prototype.getValFromLength = function (length) {
|
|
654
|
+
return parseFloat(length);
|
|
655
|
+
};
|
|
656
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
657
|
+
Filter.prototype.parseFilterString = function (filterString) {
|
|
658
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
659
|
+
var filterArray = [];
|
|
660
|
+
if (filterString !== 'none') {
|
|
661
|
+
filterArray = filterString.split(' ').map(function (filter) {
|
|
662
|
+
var _a = filter.match(/([a-z-]+)\(([^)]+)\)/).slice(1, 3), name = _a[0], value = _a[1];
|
|
663
|
+
return { filter: name, value: value };
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
return filterArray;
|
|
667
|
+
};
|
|
668
|
+
Filter.prototype.applyFilter = function (context) {
|
|
669
|
+
var _a = context.canvas, height = _a.height, width = _a.width;
|
|
670
|
+
var imageData = context.getImageData(0, 0, width, height);
|
|
671
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
672
|
+
var filterArray = this.parseFilterString(context.filter);
|
|
673
|
+
for (var i = 0, len = filterArray.length; i < len; i++) {
|
|
674
|
+
switch (filterArray[i].filter) {
|
|
675
|
+
case 'blur':
|
|
676
|
+
imageData = this.blur(context, imageData, filterArray[i].value);
|
|
677
|
+
break;
|
|
678
|
+
case 'brightness':
|
|
679
|
+
imageData = this.brightness(imageData, filterArray[i].value);
|
|
680
|
+
break;
|
|
681
|
+
case 'contrast':
|
|
682
|
+
imageData = this.contrast(imageData, filterArray[i].value);
|
|
683
|
+
break;
|
|
684
|
+
case 'grayscale':
|
|
685
|
+
imageData = this.grayscale(imageData, filterArray[i].value);
|
|
686
|
+
break;
|
|
687
|
+
case 'hue-rotate':
|
|
688
|
+
imageData = this.hueRotate(imageData, filterArray[i].value);
|
|
689
|
+
break;
|
|
690
|
+
case 'invert':
|
|
691
|
+
imageData = this.invert(imageData, filterArray[i].value);
|
|
692
|
+
break;
|
|
693
|
+
case 'opacity':
|
|
694
|
+
imageData = this.opacity(imageData, filterArray[i].value);
|
|
695
|
+
break;
|
|
696
|
+
case 'saturate':
|
|
697
|
+
imageData = this.saturate(context, imageData, filterArray[i].value);
|
|
698
|
+
break;
|
|
699
|
+
case 'sepia':
|
|
700
|
+
imageData = this.sepia(imageData, filterArray[i].value);
|
|
701
|
+
break;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
context.putImageData(imageData, 0, 0);
|
|
705
|
+
};
|
|
706
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
707
|
+
Filter.prototype.blur = function (context, imageData, radius) {
|
|
708
|
+
if (radius === void 0) { radius = '0'; }
|
|
709
|
+
var blurRadius = this.getValFromLength(radius);
|
|
710
|
+
blurRadius = Math.floor(blurRadius);
|
|
711
|
+
if (blurRadius <= 0) {
|
|
712
|
+
return imageData;
|
|
713
|
+
}
|
|
714
|
+
var _a = context.canvas, height = _a.height, width = _a.width;
|
|
715
|
+
var data = imageData.data;
|
|
716
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
717
|
+
var blurredData = new Uint8ClampedArray(data.length);
|
|
718
|
+
for (var y = 0; y < height; y++) {
|
|
719
|
+
for (var x = 0; x < width; x++) {
|
|
720
|
+
var r = 0;
|
|
721
|
+
var g = 0;
|
|
722
|
+
var b = 0;
|
|
723
|
+
var a = 0;
|
|
724
|
+
var count = 0;
|
|
725
|
+
for (var dy = -blurRadius; dy <= blurRadius; dy++) {
|
|
726
|
+
for (var dx = -blurRadius; dx <= blurRadius; dx++) {
|
|
727
|
+
var nx = x + dx;
|
|
728
|
+
var ny = y + dy;
|
|
729
|
+
if (nx >= 0 && nx < width && ny >= 0 && ny < height) {
|
|
730
|
+
var offset = (ny * width + nx) * 4;
|
|
731
|
+
r += data[offset];
|
|
732
|
+
g += data[offset + 1];
|
|
733
|
+
b += data[offset + 2];
|
|
734
|
+
a += data[offset + 3];
|
|
735
|
+
count++;
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
var i = (y * width + x) * 4;
|
|
740
|
+
blurredData[i] = r / count;
|
|
741
|
+
blurredData[i + 1] = g / count;
|
|
742
|
+
blurredData[i + 2] = b / count;
|
|
743
|
+
blurredData[i + 3] = a / count;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
for (var i = 0; i < data.length; i++) {
|
|
747
|
+
data[i] = blurredData[i];
|
|
748
|
+
}
|
|
749
|
+
return imageData;
|
|
750
|
+
};
|
|
751
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
752
|
+
Filter.prototype.brightness = function (imageData, percentage) {
|
|
753
|
+
if (percentage === void 0) { percentage = '1'; }
|
|
754
|
+
var factor = this.getValFromPercentage(percentage);
|
|
755
|
+
if (factor !== 1) {
|
|
756
|
+
var data = imageData.data;
|
|
757
|
+
var length_1 = data.length;
|
|
758
|
+
for (var i = 0; i < length_1; i += 4) {
|
|
759
|
+
data[i + 0] *= factor;
|
|
760
|
+
data[i + 1] *= factor;
|
|
761
|
+
data[i + 2] *= factor;
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
return imageData;
|
|
765
|
+
};
|
|
766
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
767
|
+
Filter.prototype.contrast = function (imageData, percentage) {
|
|
768
|
+
if (percentage === void 0) { percentage = '1'; }
|
|
769
|
+
var factor = this.getValFromPercentage(percentage);
|
|
770
|
+
if (factor !== 1) {
|
|
771
|
+
var data = imageData.data;
|
|
772
|
+
var length_2 = data.length;
|
|
773
|
+
for (var i = 0; i < length_2; i += 4) {
|
|
774
|
+
data[i + 0] = ((data[i + 0] / 255 - 0.5) * factor + 0.5) * 255;
|
|
775
|
+
data[i + 1] = ((data[i + 1] / 255 - 0.5) * factor + 0.5) * 255;
|
|
776
|
+
data[i + 2] = ((data[i + 2] / 255 - 0.5) * factor + 0.5) * 255;
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
return imageData;
|
|
780
|
+
};
|
|
781
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
782
|
+
Filter.prototype.grayscale = function (imageData, percentage) {
|
|
783
|
+
if (percentage === void 0) { percentage = '0'; }
|
|
784
|
+
var factor = this.getValFromPercentage(percentage);
|
|
785
|
+
if (factor > 0) {
|
|
786
|
+
var data = imageData.data;
|
|
787
|
+
var length_3 = data.length;
|
|
788
|
+
for (var i = 0; i < length_3; i += 4) {
|
|
789
|
+
var r = data[i];
|
|
790
|
+
var g = data[i + 1];
|
|
791
|
+
var b = data[i + 2];
|
|
792
|
+
// Calculate the grayscale value using the luminosity method
|
|
793
|
+
var gray = 0.299 * r + 0.587 * g + 0.114 * b;
|
|
794
|
+
// Blend the original color with the grayscale value based on the percentage
|
|
795
|
+
data[i] = r * (1 - factor) + gray * factor;
|
|
796
|
+
data[i + 1] = g * (1 - factor) + gray * factor;
|
|
797
|
+
data[i + 2] = b * (1 - factor) + gray * factor;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
return imageData;
|
|
801
|
+
};
|
|
802
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
803
|
+
Filter.prototype.hueRotate = function (imageData, rotation) {
|
|
804
|
+
if (rotation === void 0) { rotation = '0deg'; }
|
|
805
|
+
var data = imageData.data;
|
|
806
|
+
var angle = parseFloat(rotation) * (Math.PI / 180);
|
|
807
|
+
if (angle > 0) {
|
|
808
|
+
var cosA = Math.cos(angle);
|
|
809
|
+
var sinA = Math.sin(angle);
|
|
810
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
811
|
+
var matrix = [
|
|
812
|
+
0.213 + cosA * 0.787 - sinA * 0.213, 0.715 - cosA * 0.715 - sinA * 0.715, 0.072 - cosA * 0.072 + sinA * 0.928,
|
|
813
|
+
0.213 - cosA * 0.213 + sinA * 0.143, 0.715 + cosA * 0.285 + sinA * 0.140, 0.072 - cosA * 0.072 - sinA * 0.283,
|
|
814
|
+
0.213 - cosA * 0.213 - sinA * 0.787, 0.715 - cosA * 0.715 + sinA * 0.715, 0.072 + cosA * 0.928 + sinA * 0.072
|
|
815
|
+
];
|
|
816
|
+
for (var i = 0; i < data.length; i += 4) {
|
|
817
|
+
var r = data[i];
|
|
818
|
+
var g = data[i + 1];
|
|
819
|
+
var b = data[i + 2];
|
|
820
|
+
// Apply the hue rotation matrix
|
|
821
|
+
data[i] = matrix[0] * r + matrix[1] * g + matrix[2] * b;
|
|
822
|
+
data[i + 1] = matrix[3] * r + matrix[4] * g + matrix[5] * b;
|
|
823
|
+
data[i + 2] = matrix[6] * r + matrix[7] * g + matrix[8] * b;
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
return imageData;
|
|
827
|
+
};
|
|
828
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
829
|
+
Filter.prototype.invert = function (imageData, percentage) {
|
|
830
|
+
if (percentage === void 0) { percentage = '0'; }
|
|
831
|
+
var factor = this.getValFromPercentage(percentage);
|
|
832
|
+
if (factor > 0) {
|
|
833
|
+
var data = imageData.data;
|
|
834
|
+
var length_4 = data.length;
|
|
835
|
+
for (var i = 0; i < length_4; i += 4) {
|
|
836
|
+
data[i + 0] = Math.abs(data[i + 0] - 255 * factor);
|
|
837
|
+
data[i + 1] = Math.abs(data[i + 1] - 255 * factor);
|
|
838
|
+
data[i + 2] = Math.abs(data[i + 2] - 255 * factor);
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
return imageData;
|
|
842
|
+
};
|
|
843
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
844
|
+
Filter.prototype.opacity = function (imageData, percentage) {
|
|
845
|
+
if (percentage === void 0) { percentage = '0'; }
|
|
846
|
+
var factor = this.getValFromPercentage(percentage);
|
|
847
|
+
if (factor >= 0) {
|
|
848
|
+
var data = imageData.data;
|
|
849
|
+
var length_5 = data.length;
|
|
850
|
+
for (var i = 3; i < length_5; i += 4) {
|
|
851
|
+
data[i] *= factor;
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
return imageData;
|
|
855
|
+
};
|
|
856
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
857
|
+
Filter.prototype.saturate = function (context, imageData, percentage) {
|
|
858
|
+
if (percentage === void 0) { percentage = '0'; }
|
|
859
|
+
var factor = this.getValFromPercentage(percentage);
|
|
860
|
+
if (factor !== 1) {
|
|
861
|
+
var _a = context.canvas, width = _a.width, height = _a.height;
|
|
862
|
+
var data = imageData.data;
|
|
863
|
+
var lumR = (1 - factor) * 0.3086;
|
|
864
|
+
var lumG = (1 - factor) * 0.6094;
|
|
865
|
+
var lumB = (1 - factor) * 0.082;
|
|
866
|
+
// tslint:disable-next-line no-bitwise
|
|
867
|
+
var shiftW = width << 2;
|
|
868
|
+
for (var j = 0; j < height; j++) {
|
|
869
|
+
var offset = j * shiftW;
|
|
870
|
+
for (var i = 0; i < width; i++) {
|
|
871
|
+
// tslint:disable-next-line no-bitwise
|
|
872
|
+
var pos = offset + (i << 2);
|
|
873
|
+
var r = data[pos + 0];
|
|
874
|
+
var g = data[pos + 1];
|
|
875
|
+
var b = data[pos + 2];
|
|
876
|
+
data[pos + 0] = (lumR + factor) * r + lumG * g + lumB * b;
|
|
877
|
+
data[pos + 1] = lumR * r + (lumG + factor) * g + lumB * b;
|
|
878
|
+
data[pos + 2] = lumR * r + lumG * g + (lumB + factor) * b;
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
return imageData;
|
|
883
|
+
};
|
|
884
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
885
|
+
Filter.prototype.sepia = function (imageData, percentage) {
|
|
886
|
+
if (percentage === void 0) { percentage = '0'; }
|
|
887
|
+
var factor = this.getValFromPercentage(percentage);
|
|
888
|
+
if (factor > 1) {
|
|
889
|
+
factor = 1;
|
|
890
|
+
}
|
|
891
|
+
if (factor > 0) {
|
|
892
|
+
var data = imageData.data;
|
|
893
|
+
var length_6 = data.length;
|
|
894
|
+
for (var i = 0; i < length_6; i += 4) {
|
|
895
|
+
var r = data[i + 0];
|
|
896
|
+
var g = data[i + 1];
|
|
897
|
+
var b = data[i + 2];
|
|
898
|
+
data[i + 0] =
|
|
899
|
+
(0.393 * r + 0.769 * g + 0.189 * b) * factor + r * (1 - factor);
|
|
900
|
+
data[i + 1] =
|
|
901
|
+
(0.349 * r + 0.686 * g + 0.168 * b) * factor + g * (1 - factor);
|
|
902
|
+
data[i + 2] =
|
|
903
|
+
(0.272 * r + 0.534 * g + 0.131 * b) * factor + b * (1 - factor);
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
return imageData;
|
|
907
|
+
};
|
|
637
908
|
return Filter;
|
|
638
909
|
}());
|
|
639
910
|
export { Filter };
|
|
@@ -15,6 +15,7 @@ var FreehandDrawing = /** @class */ (function () {
|
|
|
15
15
|
this.tempFHDStyles = { strokeColor: null, fillColor: null, strokeWidth: null };
|
|
16
16
|
this.straightenPoint = { x: null, y: null, ratioX: null, ratioY: null };
|
|
17
17
|
this.straightenPointAngle = 0;
|
|
18
|
+
this.isMasking = false;
|
|
18
19
|
this.parent = parent;
|
|
19
20
|
this.addEventListener();
|
|
20
21
|
}
|
|
@@ -115,6 +116,9 @@ var FreehandDrawing = /** @class */ (function () {
|
|
|
115
116
|
case 'setSelPointColl':
|
|
116
117
|
this.selPointColl = extend([], args.value['obj']['selPointColl']);
|
|
117
118
|
break;
|
|
119
|
+
case 'pushSelPointColl':
|
|
120
|
+
this.selPointColl.push(extend([], args.value['obj']['selPointColl']));
|
|
121
|
+
break;
|
|
118
122
|
case 'setFreehandDrawHoveredIndex':
|
|
119
123
|
this.fhdHovIdx = args.value['index'];
|
|
120
124
|
break;
|
|
@@ -182,6 +186,12 @@ var FreehandDrawing = /** @class */ (function () {
|
|
|
182
186
|
case 'triggerShapeChanging':
|
|
183
187
|
this.triggerShapeChanging(args.value['shapeChangingArgs']);
|
|
184
188
|
break;
|
|
189
|
+
case 'setMasking':
|
|
190
|
+
this.isMasking = args.value['value'];
|
|
191
|
+
break;
|
|
192
|
+
case 'resetSelPoints':
|
|
193
|
+
this.selPoints = [];
|
|
194
|
+
break;
|
|
185
195
|
}
|
|
186
196
|
};
|
|
187
197
|
FreehandDrawing.prototype.updateFhdPvtVar = function () {
|
|
@@ -204,6 +214,7 @@ var FreehandDrawing = /** @class */ (function () {
|
|
|
204
214
|
this.fhdHovIdx = null;
|
|
205
215
|
this.pointCounter = 0;
|
|
206
216
|
this.fhdSelID = null;
|
|
217
|
+
this.isMasking = false;
|
|
207
218
|
this.penStrokeWidth = undefined;
|
|
208
219
|
this.currFHDIdx = 0;
|
|
209
220
|
this.fhdSelIdx = null;
|
|
@@ -331,11 +342,13 @@ var FreehandDrawing = /** @class */ (function () {
|
|
|
331
342
|
this.pointCounter = 0;
|
|
332
343
|
parent.freehandCounter++;
|
|
333
344
|
this.isFreehandDrawing = false;
|
|
334
|
-
parent.
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
345
|
+
if (!parent.isMaskImage) {
|
|
346
|
+
parent.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
|
|
347
|
+
value: { operation: 'freehand-draw', previousObj: prevObj, previousObjColl: prevObj.objColl,
|
|
348
|
+
previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
|
|
349
|
+
previousCropObj: prevCropObj, previousText: null,
|
|
350
|
+
currentText: null, previousFilter: null, isCircleCrop: null } });
|
|
351
|
+
}
|
|
339
352
|
var shapeSettings = { id: 'pen_' + (this.currFHDIdx + 1), type: ShapeType.FreehandDraw,
|
|
340
353
|
startX: this.freehandDownPoint.x, startY: this.freehandDownPoint.y,
|
|
341
354
|
strokeColor: parent.activeObj.strokeSettings.strokeColor, strokeWidth: this.penStrokeWidth,
|
|
@@ -360,6 +373,9 @@ var FreehandDrawing = /** @class */ (function () {
|
|
|
360
373
|
}
|
|
361
374
|
if (this.isFreehandDrawing) {
|
|
362
375
|
this.upperContext.fillStyle = this.parent.activeObj.strokeSettings.strokeColor;
|
|
376
|
+
if (this.parent.isMaskImage) {
|
|
377
|
+
this.upperContext.globalCompositeOperation = 'xor';
|
|
378
|
+
}
|
|
363
379
|
this.processPoint(x, y, false, this.upperContext);
|
|
364
380
|
}
|
|
365
381
|
};
|
|
@@ -709,6 +725,7 @@ var FreehandDrawing = /** @class */ (function () {
|
|
|
709
725
|
this.tempFHDStyles = tempFHDStyles;
|
|
710
726
|
}
|
|
711
727
|
};
|
|
728
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
712
729
|
FreehandDrawing.prototype.deleteFhd = function (index, isId) {
|
|
713
730
|
var parent = this.parent;
|
|
714
731
|
if (this.isFHDIdx(index)) {
|
|
@@ -720,22 +737,11 @@ var FreehandDrawing = /** @class */ (function () {
|
|
|
720
737
|
parent.pointColl = {};
|
|
721
738
|
this.selPointColl = {};
|
|
722
739
|
var count = 0;
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
count++;
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
else {
|
|
733
|
-
for (var i = 0; i < parent.freehandCounter; i++) {
|
|
734
|
-
if (parseInt(tempPointColl[i].id.split('_')[1], 10) - 1 !== index) {
|
|
735
|
-
parent.pointColl[count] = tempPointColl[i];
|
|
736
|
-
this.selPointColl[count] = tempSelPointColl[i];
|
|
737
|
-
count++;
|
|
738
|
-
}
|
|
740
|
+
for (var i = 0; i < parent.freehandCounter; i++) {
|
|
741
|
+
if (parseInt(tempPointColl[i].id.split('_')[1], 10) - 1 !== index) {
|
|
742
|
+
parent.pointColl[count] = tempPointColl[i];
|
|
743
|
+
this.selPointColl[count] = tempSelPointColl[i];
|
|
744
|
+
count++;
|
|
739
745
|
}
|
|
740
746
|
}
|
|
741
747
|
parent.freehandCounter -= 1;
|
|
@@ -1082,8 +1088,13 @@ var FreehandDrawing = /** @class */ (function () {
|
|
|
1082
1088
|
if (isNullOrUndefined(parent.activeObj.strokeSettings.strokeWidth)) {
|
|
1083
1089
|
parent.activeObj.strokeSettings.strokeWidth = 2;
|
|
1084
1090
|
}
|
|
1085
|
-
parent.
|
|
1086
|
-
|
|
1091
|
+
if (parent.isMaskImage) {
|
|
1092
|
+
parent.notify('toolbar', { prop: 'refresh-main-toolbar', onPropertyChange: false });
|
|
1093
|
+
}
|
|
1094
|
+
else {
|
|
1095
|
+
parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'pen',
|
|
1096
|
+
isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
|
|
1097
|
+
}
|
|
1087
1098
|
}
|
|
1088
1099
|
else {
|
|
1089
1100
|
parent.upperCanvas.style.cursor = parent.cursor = 'default';
|
|
@@ -1131,6 +1142,16 @@ var FreehandDrawing = /** @class */ (function () {
|
|
|
1131
1142
|
var parent = this.parent;
|
|
1132
1143
|
var point = parent.pointColl[this.fhdSelIdx];
|
|
1133
1144
|
parent.trigger('shapeChanging', shapeChangingArgs);
|
|
1145
|
+
if (parent.element.getAttribute('data-value') === 'mask-drawing' && !this.isMasking) {
|
|
1146
|
+
this.isMasking = true;
|
|
1147
|
+
parent.upperCanvas.style.cursor = 'crosshair';
|
|
1148
|
+
parent.notify('draw', { prop: 'updateTempObjColl' });
|
|
1149
|
+
parent.notify('draw', { prop: 'updateTempPointColl' });
|
|
1150
|
+
parent.discard();
|
|
1151
|
+
parent.selectMaskImage();
|
|
1152
|
+
return;
|
|
1153
|
+
}
|
|
1154
|
+
parent.editCompleteArgs = shapeChangingArgs;
|
|
1134
1155
|
if (shapeChangingArgs.currentShapeSettings.id.indexOf('pen_') === -1 &&
|
|
1135
1156
|
(shapeChangingArgs.action === 'draw-end' || shapeChangingArgs.action === 'select')) {
|
|
1136
1157
|
var id = 'pen_' + shapeChangingArgs.currentShapeSettings.id;
|
|
@@ -48,6 +48,7 @@ export declare class Selection {
|
|
|
48
48
|
private arrowShape;
|
|
49
49
|
private isPreventShaping;
|
|
50
50
|
private isGrabbing;
|
|
51
|
+
private isTouchDblClick;
|
|
51
52
|
constructor(parent: ImageEditor);
|
|
52
53
|
destroy(): void;
|
|
53
54
|
private addEventListener;
|
|
@@ -61,6 +62,7 @@ export declare class Selection {
|
|
|
61
62
|
private getMouseCursor;
|
|
62
63
|
private setCursor;
|
|
63
64
|
private getHighestOrder;
|
|
65
|
+
drawMaskCircle(x: number, y: number): void;
|
|
64
66
|
private setCursorForActObj;
|
|
65
67
|
private setCursorForPath;
|
|
66
68
|
private setCursorForLineArrow;
|
|
@@ -70,7 +72,10 @@ export declare class Selection {
|
|
|
70
72
|
private setCursorForFreehandDrawing;
|
|
71
73
|
private setCursorFromObj;
|
|
72
74
|
private isInside;
|
|
75
|
+
private preventResizing;
|
|
73
76
|
private updateActivePoint;
|
|
77
|
+
private isShapeDragOut;
|
|
78
|
+
private isObjOutsideImg;
|
|
74
79
|
private triggerShapeChange;
|
|
75
80
|
private setDragWidth;
|
|
76
81
|
private setDragHeight;
|
|
@@ -163,4 +168,5 @@ export declare class Selection {
|
|
|
163
168
|
private getTransRotationPoint;
|
|
164
169
|
private getNumTextValue;
|
|
165
170
|
private isValueUpdated;
|
|
171
|
+
private allowOutofBound;
|
|
166
172
|
}
|