@syncfusion/ej2-image-editor 20.3.56 → 20.4.38
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/.eslintrc.json +16 -1
- package/CHANGELOG.md +2 -10
- package/README.md +65 -2
- 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 +6129 -4137
- package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
- package/dist/es6/ej2-image-editor.es5.js +2468 -468
- 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 +21 -23
- package/src/image-editor/image-editor-model.d.ts +102 -19
- package/src/image-editor/image-editor.d.ts +221 -31
- package/src/image-editor/image-editor.js +2468 -467
- package/styles/bootstrap-dark.css +36 -0
- package/styles/bootstrap.css +36 -0
- package/styles/bootstrap4.css +36 -0
- package/styles/bootstrap5-dark.css +36 -0
- package/styles/bootstrap5.css +36 -0
- package/styles/fabric-dark.css +36 -0
- package/styles/fabric.css +36 -0
- package/styles/fluent-dark.css +36 -0
- package/styles/fluent.css +36 -0
- package/styles/highcontrast-light.css +36 -0
- package/styles/highcontrast.css +36 -0
- 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 +1 -0
- package/styles/image-editor/_highcontrast-light-definition.scss +1 -0
- package/styles/image-editor/_layout.scss +38 -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 +1 -0
- package/styles/image-editor/_tailwind-definition.scss +1 -0
- package/styles/image-editor/_theme.scss +11 -0
- package/styles/image-editor/bootstrap-dark.css +36 -0
- package/styles/image-editor/bootstrap.css +36 -0
- package/styles/image-editor/bootstrap4.css +36 -0
- package/styles/image-editor/bootstrap5-dark.css +36 -0
- package/styles/image-editor/bootstrap5.css +36 -0
- package/styles/image-editor/fabric-dark.css +36 -0
- package/styles/image-editor/fabric.css +36 -0
- package/styles/image-editor/fluent-dark.css +36 -0
- package/styles/image-editor/fluent.css +36 -0
- package/styles/image-editor/highcontrast-light.css +36 -0
- package/styles/image-editor/highcontrast.css +36 -0
- package/styles/image-editor/material-dark.css +36 -0
- package/styles/image-editor/material.css +36 -0
- package/styles/image-editor/tailwind-dark.css +36 -0
- package/styles/image-editor/tailwind.css +36 -0
- package/styles/material-dark.css +36 -0
- package/styles/material.css +36 -0
- package/styles/tailwind-dark.css +36 -0
- package/styles/tailwind.css +36 -0
|
@@ -22,9 +22,41 @@ import { Event, EventHandler, getComponent, getInstance, isNullOrUndefined, L10n
|
|
|
22
22
|
import { SignatureBase } from '@syncfusion/ej2-inputs';
|
|
23
23
|
import { Toolbar } from '@syncfusion/ej2-navigations';
|
|
24
24
|
import { DropDownButton } from '@syncfusion/ej2-splitbuttons';
|
|
25
|
-
import { ColorPicker, Uploader } from '@syncfusion/ej2-inputs';
|
|
25
|
+
import { ColorPicker, Uploader, Slider } from '@syncfusion/ej2-inputs';
|
|
26
26
|
import { createSpinner, showSpinner, hideSpinner } from '@syncfusion/ej2-popups';
|
|
27
|
-
import { compile, compile as templateCompiler, Browser, detach, select } from '@syncfusion/ej2-base';
|
|
27
|
+
import { Complex, compile, compile as templateCompiler, Browser, detach, select, ChildProperty } from '@syncfusion/ej2-base';
|
|
28
|
+
/**
|
|
29
|
+
* Interface for image finetune values.
|
|
30
|
+
*/
|
|
31
|
+
var FinetuneSettings = /** @class */ (function (_super) {
|
|
32
|
+
__extends(FinetuneSettings, _super);
|
|
33
|
+
function FinetuneSettings() {
|
|
34
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
35
|
+
}
|
|
36
|
+
__decorate([
|
|
37
|
+
Property(null)
|
|
38
|
+
], FinetuneSettings.prototype, "brightness", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
Property(null)
|
|
41
|
+
], FinetuneSettings.prototype, "contrast", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
Property(null)
|
|
44
|
+
], FinetuneSettings.prototype, "hue", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
Property(null)
|
|
47
|
+
], FinetuneSettings.prototype, "saturation", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
Property(null)
|
|
50
|
+
], FinetuneSettings.prototype, "exposure", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
Property(null)
|
|
53
|
+
], FinetuneSettings.prototype, "opacity", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
Property(null)
|
|
56
|
+
], FinetuneSettings.prototype, "blur", void 0);
|
|
57
|
+
return FinetuneSettings;
|
|
58
|
+
}(ChildProperty));
|
|
59
|
+
export { FinetuneSettings };
|
|
28
60
|
/**
|
|
29
61
|
* Image Editor is a graphical user interface that helps to edit an image by performing actions like selection,
|
|
30
62
|
* cropping, rotating, inserting text and shapes (rectangles, ellipses, lines), and drawing free hand on top of an image.
|
|
@@ -51,7 +83,6 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
51
83
|
function ImageEditor(options, element) {
|
|
52
84
|
var _this = _super.call(this, options, element) || this;
|
|
53
85
|
_this.degree = 0; // current rotated state
|
|
54
|
-
_this.isUndoRedo = false;
|
|
55
86
|
_this.dragCanvas = false;
|
|
56
87
|
_this.dragElement = '';
|
|
57
88
|
_this.keyHistory = ''; // text history
|
|
@@ -72,24 +103,18 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
72
103
|
_this.pannStart = {};
|
|
73
104
|
_this.pannEnd = {};
|
|
74
105
|
_this.togglePan = false;
|
|
106
|
+
_this.disablePan = false;
|
|
75
107
|
_this.lastX = 0;
|
|
76
108
|
_this.lastY = 0;
|
|
77
109
|
_this.dragStart = { x: 0, y: 0 };
|
|
78
|
-
_this.dragged = false;
|
|
79
110
|
_this.factor = 1; // current zoomed state
|
|
80
111
|
_this.currFlipState = '';
|
|
81
112
|
_this.touchEndPoint = {};
|
|
82
|
-
_this.flipMethod = false;
|
|
83
|
-
_this.flipDirection = '';
|
|
84
113
|
_this.prevX = 0;
|
|
85
114
|
_this.currX = 0;
|
|
86
115
|
_this.prevY = 0;
|
|
87
116
|
_this.currY = 0;
|
|
88
117
|
_this.togglePen = false;
|
|
89
|
-
_this.rotateMethod = false;
|
|
90
|
-
_this.isBoldbtn = false;
|
|
91
|
-
_this.isItalicbtn = false;
|
|
92
|
-
_this.lastAction = '';
|
|
93
118
|
_this.currentToolbar = 'main';
|
|
94
119
|
_this.textStartPoints = { x: 0, y: 0 };
|
|
95
120
|
_this.fontSizeColl = [];
|
|
@@ -100,11 +125,29 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
100
125
|
_this.activeObj = { activePoint: { startX: 0, startY: 0, endX: 0, endY: 0, width: 0, height: 0 },
|
|
101
126
|
flipObjColl: [] };
|
|
102
127
|
_this.currObjType = { shape: '', isDragging: false, isActiveObj: false, isText: false, isInitialText: false, isLine: false,
|
|
103
|
-
isInitialLine: false, isCustomCrop: false, isZoomed: false };
|
|
128
|
+
isInitialLine: false, isCustomCrop: false, isZoomed: false, isFiltered: false, isSave: false };
|
|
104
129
|
_this.defToolbarItems = [];
|
|
105
|
-
_this.baseImgSrc =
|
|
130
|
+
_this.baseImgSrc = {};
|
|
106
131
|
_this.isTimer = false;
|
|
107
132
|
_this.isScreenOriented = false;
|
|
133
|
+
_this.isFirstMove = false;
|
|
134
|
+
_this.startTouches = [];
|
|
135
|
+
_this.tempTouches = [];
|
|
136
|
+
_this.adjustmentLevel = { brightness: 0, contrast: 0, hue: 0, opacity: 100, saturation: 0, blur: 0,
|
|
137
|
+
exposure: 0, sharpen: false, bw: false };
|
|
138
|
+
_this.tempAdjustmentLevel = { brightness: 0, contrast: 0, hue: 0, opacity: 100, saturation: 0, blur: 0,
|
|
139
|
+
exposure: 0, sharpen: false, bw: false };
|
|
140
|
+
_this.adjustmentValue = '';
|
|
141
|
+
_this.initialAdjustmentValue = '';
|
|
142
|
+
_this.tempAdjustmentValue = '';
|
|
143
|
+
_this.currentFilter = '';
|
|
144
|
+
_this.tempFilter = '';
|
|
145
|
+
_this.canvasFilter = '';
|
|
146
|
+
_this.sharpenedImgData = false;
|
|
147
|
+
_this.tempSharpenFilter = false;
|
|
148
|
+
_this.tempBWFilter = false;
|
|
149
|
+
_this.isBrightnessAdjusted = false;
|
|
150
|
+
_this.isInitialLoading = false;
|
|
108
151
|
return _this;
|
|
109
152
|
}
|
|
110
153
|
ImageEditor_1 = ImageEditor;
|
|
@@ -134,8 +177,28 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
134
177
|
Crop: 'Crop',
|
|
135
178
|
ZoomIn: 'Zoom In',
|
|
136
179
|
ZoomOut: 'Zoom Out',
|
|
180
|
+
Undo: 'Undo',
|
|
181
|
+
Redo: 'Redo',
|
|
137
182
|
Transform: 'Transform',
|
|
138
183
|
Annotation: 'Annotation',
|
|
184
|
+
Finetune: 'Finetune',
|
|
185
|
+
Brightness: 'Brightness',
|
|
186
|
+
Contrast: 'Contrast',
|
|
187
|
+
Hue: 'Hue',
|
|
188
|
+
Saturation: 'Saturation',
|
|
189
|
+
Opacity: 'Opacity',
|
|
190
|
+
Blur: 'Blur',
|
|
191
|
+
Sharpen: 'Sharpen',
|
|
192
|
+
Exposure: 'Exposure',
|
|
193
|
+
Filter: 'Filter',
|
|
194
|
+
Default: 'Default',
|
|
195
|
+
Chrome: 'Chrome',
|
|
196
|
+
Cold: 'Cold',
|
|
197
|
+
Warm: 'Warm',
|
|
198
|
+
Grayscale: 'Grayscale',
|
|
199
|
+
BlackAndWhite: 'Black and White',
|
|
200
|
+
Sepia: 'Sepia',
|
|
201
|
+
Invert: 'Invert',
|
|
139
202
|
Text: 'Add Text',
|
|
140
203
|
Pen: 'Pen',
|
|
141
204
|
Reset: 'Reset',
|
|
@@ -163,7 +226,6 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
163
226
|
Ellipse: 'Ellipse',
|
|
164
227
|
Rectangle: 'Rectangle',
|
|
165
228
|
Line: 'Line',
|
|
166
|
-
Default: 'Default',
|
|
167
229
|
Bold: 'Bold',
|
|
168
230
|
Italic: 'Italic',
|
|
169
231
|
BoldItalic: 'Bold Italic',
|
|
@@ -172,7 +234,8 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
172
234
|
Medium: 'Medium',
|
|
173
235
|
Large: 'Large',
|
|
174
236
|
XLarge: 'X-Large',
|
|
175
|
-
ABC: 'ABC'
|
|
237
|
+
ABC: 'ABC',
|
|
238
|
+
Browse: 'Browse'
|
|
176
239
|
};
|
|
177
240
|
this.l10n = new L10n('image-editor', this.defaultLocale, this.locale);
|
|
178
241
|
};
|
|
@@ -249,6 +312,12 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
249
312
|
this.upperContext.fillStyle = this.themeColl[this.theme]['secondaryColor'];
|
|
250
313
|
}
|
|
251
314
|
break;
|
|
315
|
+
case 'finetuneSettings':
|
|
316
|
+
if (newProperties.finetuneSettings) {
|
|
317
|
+
this.finetuneSettings = newProperties.finetuneSettings;
|
|
318
|
+
this.updateFinetunes();
|
|
319
|
+
}
|
|
320
|
+
break;
|
|
252
321
|
}
|
|
253
322
|
}
|
|
254
323
|
};
|
|
@@ -269,13 +338,17 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
269
338
|
this.trigger('destroyed');
|
|
270
339
|
};
|
|
271
340
|
ImageEditor.prototype.initialize = function () {
|
|
341
|
+
this.updateFinetunes();
|
|
272
342
|
this.createToolbar();
|
|
343
|
+
this.createContextualToolbar();
|
|
273
344
|
this.createCanvas();
|
|
274
345
|
this.wireEvent();
|
|
275
346
|
this.updateContext(this.lowerContext);
|
|
276
347
|
this.updateContext(this.upperContext);
|
|
277
348
|
this.pannStart = { startX: 0, startY: 0, width: 0, height: 0 };
|
|
278
349
|
this.pannEnd = { startX: 0, startY: 0, width: 0, height: 0 };
|
|
350
|
+
this.lowerContext.filter = this.canvasFilter = this.initialAdjustmentValue = this.adjustmentValue = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
351
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
279
352
|
if (this.cssClass) {
|
|
280
353
|
addClass([this.element], this.cssClass.split(' '));
|
|
281
354
|
}
|
|
@@ -285,6 +358,39 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
285
358
|
});
|
|
286
359
|
}
|
|
287
360
|
};
|
|
361
|
+
ImageEditor.prototype.updateFinetunes = function () {
|
|
362
|
+
if (this.finetuneSettings) {
|
|
363
|
+
if (this.finetuneSettings.brightness) {
|
|
364
|
+
this.adjustmentLevel.brightness = this.finetuneSettings.brightness.defaultValue;
|
|
365
|
+
this.tempAdjustmentLevel.brightness = this.finetuneSettings.brightness.defaultValue;
|
|
366
|
+
}
|
|
367
|
+
if (this.finetuneSettings.contrast) {
|
|
368
|
+
this.adjustmentLevel.contrast = this.finetuneSettings.contrast.defaultValue;
|
|
369
|
+
this.tempAdjustmentLevel.contrast = this.finetuneSettings.contrast.defaultValue;
|
|
370
|
+
}
|
|
371
|
+
if (this.finetuneSettings.hue) {
|
|
372
|
+
this.adjustmentLevel.hue = this.finetuneSettings.hue.defaultValue;
|
|
373
|
+
this.tempAdjustmentLevel.hue = this.finetuneSettings.hue.defaultValue;
|
|
374
|
+
}
|
|
375
|
+
if (this.finetuneSettings.saturation) {
|
|
376
|
+
this.adjustmentLevel.saturation = this.finetuneSettings.saturation.defaultValue;
|
|
377
|
+
this.tempAdjustmentLevel.saturation = this.finetuneSettings.saturation.defaultValue;
|
|
378
|
+
}
|
|
379
|
+
if (this.finetuneSettings.exposure) {
|
|
380
|
+
this.adjustmentLevel.exposure = this.finetuneSettings.exposure.defaultValue;
|
|
381
|
+
this.tempAdjustmentLevel.exposure = this.finetuneSettings.exposure.defaultValue;
|
|
382
|
+
}
|
|
383
|
+
if (this.finetuneSettings.opacity) {
|
|
384
|
+
this.adjustmentLevel.opacity = this.finetuneSettings.opacity.defaultValue;
|
|
385
|
+
this.tempAdjustmentLevel.opacity = this.finetuneSettings.opacity.defaultValue;
|
|
386
|
+
}
|
|
387
|
+
if (this.finetuneSettings.blur) {
|
|
388
|
+
this.adjustmentLevel.blur = this.finetuneSettings.blur.defaultValue;
|
|
389
|
+
this.tempAdjustmentLevel.blur = this.finetuneSettings.blur.defaultValue;
|
|
390
|
+
}
|
|
391
|
+
this.isInitialLoading = true;
|
|
392
|
+
}
|
|
393
|
+
};
|
|
288
394
|
/**
|
|
289
395
|
*
|
|
290
396
|
* This Method will add events to component (element, event, method, current reference)
|
|
@@ -307,7 +413,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
307
413
|
EventHandler.add(this.upperCanvas, 'dblclick', this.findTextPoint, this);
|
|
308
414
|
EventHandler.add(this.textBox, 'mousedown', this.findTextPoint, this);
|
|
309
415
|
window.addEventListener('resize', this.windowResizeHandler.bind(this));
|
|
310
|
-
if (
|
|
416
|
+
if (!Browser.isIos && Browser.info.name !== 'safari' && screen && screen.orientation) {
|
|
311
417
|
screen.orientation.addEventListener('change', this.screenOrientation.bind(this));
|
|
312
418
|
}
|
|
313
419
|
};
|
|
@@ -329,9 +435,17 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
329
435
|
EventHandler.remove(this.lowerCanvas, 'mouseup', this.canvasMouseUpHandler);
|
|
330
436
|
EventHandler.remove(document, 'mouseup', this.canvasMouseUpHandler);
|
|
331
437
|
};
|
|
438
|
+
ImageEditor.prototype.initializeFilter = function () {
|
|
439
|
+
this.setBrightness(this.adjustmentLevel.brightness);
|
|
440
|
+
this.setContrast(this.adjustmentLevel.contrast);
|
|
441
|
+
this.setHue(this.adjustmentLevel.hue);
|
|
442
|
+
this.setSaturation(this.adjustmentLevel.saturation);
|
|
443
|
+
this.setExposure(this.adjustmentLevel.exposure);
|
|
444
|
+
this.setOpacity(this.adjustmentLevel.opacity);
|
|
445
|
+
this.setBlur(this.adjustmentLevel.blur);
|
|
446
|
+
};
|
|
332
447
|
ImageEditor.prototype.destroySubComponents = function () {
|
|
333
448
|
var inputElement = this.element.querySelectorAll('input.e-control');
|
|
334
|
-
var divElement = this.element.querySelectorAll('div.e-control:not(.e-handle)');
|
|
335
449
|
var btnElement = this.element.querySelectorAll('button.e-control');
|
|
336
450
|
for (var i = 0, len = inputElement.length; i < len; i++) {
|
|
337
451
|
if (inputElement[i].classList.contains('e-color-picker')) {
|
|
@@ -462,6 +576,58 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
462
576
|
this.toolbarHeight = 0;
|
|
463
577
|
}
|
|
464
578
|
};
|
|
579
|
+
ImageEditor.prototype.createContextualToolbar = function () {
|
|
580
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.length > 0)) {
|
|
581
|
+
this.element.appendChild(this.createElement('div', { id: this.element.id + '_contextualToolbarArea',
|
|
582
|
+
className: 'e-contextual-toolbar-wrapper e-hide', attrs: { style: 'position: absolute;' }
|
|
583
|
+
}));
|
|
584
|
+
var toolbarArea = document.getElementById(this.element.id + '_contextualToolbarArea');
|
|
585
|
+
var toolbar_2 = this.createElement('div', { id: this.element.id + '_contextualToolbar' });
|
|
586
|
+
toolbarArea.appendChild(toolbar_2);
|
|
587
|
+
}
|
|
588
|
+
};
|
|
589
|
+
ImageEditor.prototype.updateContextualToolbar = function (type, cType) {
|
|
590
|
+
if (this.toolbarTemplate) {
|
|
591
|
+
this.toolbarTemplateFn();
|
|
592
|
+
}
|
|
593
|
+
else {
|
|
594
|
+
var toolbarArea = this.element.querySelector('#' + this.element.id + '_toolbarArea');
|
|
595
|
+
var contextualToolbarArea = this.element.querySelector('#' + this.element.id + '_contextualToolbarArea');
|
|
596
|
+
if (!isNullOrUndefined(toolbarArea) && !isNullOrUndefined(contextualToolbarArea)) {
|
|
597
|
+
contextualToolbarArea.classList.remove('e-hide');
|
|
598
|
+
contextualToolbarArea.style.left = toolbarArea.offsetLeft + 'px';
|
|
599
|
+
}
|
|
600
|
+
if (type === 'filter') {
|
|
601
|
+
if (!isNullOrUndefined(document.getElementById(this.element.id + '_toolbar')) && this.defToolbarItems.length > 0) {
|
|
602
|
+
getComponent(document.getElementById(this.element.id + '_toolbar'), 'toolbar').destroy();
|
|
603
|
+
}
|
|
604
|
+
if (Browser.isDevice) {
|
|
605
|
+
this.initToolbarItem(false, true, true);
|
|
606
|
+
}
|
|
607
|
+
else {
|
|
608
|
+
this.initToolbarItem(true);
|
|
609
|
+
}
|
|
610
|
+
this.refreshSlider();
|
|
611
|
+
this.initFilterToolbarItem();
|
|
612
|
+
}
|
|
613
|
+
else {
|
|
614
|
+
if (!isNullOrUndefined(document.querySelector('#' + this.element.id + '_contextualToolbar'))
|
|
615
|
+
&& document.querySelector('#' + this.element.id + '_contextualToolbar').classList.contains('e-control')) {
|
|
616
|
+
getComponent(document.getElementById(this.element.id + '_contextualToolbar'), 'toolbar').destroy();
|
|
617
|
+
}
|
|
618
|
+
this.refreshSlider();
|
|
619
|
+
this.renderSlider(cType);
|
|
620
|
+
}
|
|
621
|
+
if (Browser.isDevice) {
|
|
622
|
+
var cHt = contextualToolbarArea.offsetHeight;
|
|
623
|
+
var ht = this.element.querySelector('#' + this.element.id + '_canvasWrapper').offsetHeight;
|
|
624
|
+
contextualToolbarArea.style.top = this.toolbarHeight + ht - cHt + 'px';
|
|
625
|
+
}
|
|
626
|
+
else {
|
|
627
|
+
contextualToolbarArea.style.top = this.toolbarHeight + 1 + 'px';
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
};
|
|
465
631
|
ImageEditor.prototype.createBottomToolbar = function () {
|
|
466
632
|
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.length > 0)) {
|
|
467
633
|
this.element.appendChild(this.createElement('div', {
|
|
@@ -498,8 +664,8 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
498
664
|
}, '#' + this.element.id + '_bottomToolbar');
|
|
499
665
|
if (this.defToolbarItems.length > 0 && (!isNullOrUndefined(document.getElementById(this.element.id + '_bottomToolbar')))) {
|
|
500
666
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
501
|
-
var
|
|
502
|
-
|
|
667
|
+
var toolbar_3 = getComponent(this.element.id + '_bottomToolbar', 'toolbar');
|
|
668
|
+
toolbar_3.refreshOverflow();
|
|
503
669
|
}
|
|
504
670
|
}
|
|
505
671
|
}
|
|
@@ -602,6 +768,14 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
602
768
|
template: '<button id="' + this.element.id + '_transformBtn"></button>'
|
|
603
769
|
});
|
|
604
770
|
}
|
|
771
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Finetune') > -1)) {
|
|
772
|
+
toolbarItems.push({ id: this.element.id + '_adjustment', prefixIcon: 'e-icons e-adjustment', cssClass: 'top-icon e-adjustment',
|
|
773
|
+
tooltipText: this.l10n.getConstant('Finetune'), align: 'Center' });
|
|
774
|
+
}
|
|
775
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Filter') > -1)) {
|
|
776
|
+
toolbarItems.push({ id: this.element.id + '_filter', prefixIcon: 'e-icons e-filters', cssClass: 'top-icon e-filters',
|
|
777
|
+
tooltipText: this.l10n.getConstant('Filter'), align: 'Center' });
|
|
778
|
+
}
|
|
605
779
|
var tempToolbarItems = this.processToolbar('center');
|
|
606
780
|
for (var i = 0, len = tempToolbarItems.length; i < len; i++) {
|
|
607
781
|
toolbarItems.push(tempToolbarItems[i]);
|
|
@@ -709,8 +883,8 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
709
883
|
}
|
|
710
884
|
if (this.isToolbar() && (!isNullOrUndefined(document.getElementById(this.element.id + '_toolbar')))) {
|
|
711
885
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
712
|
-
var
|
|
713
|
-
|
|
886
|
+
var toolbar_4 = getComponent(this.element.id + '_toolbar', 'toolbar');
|
|
887
|
+
toolbar_4.refreshOverflow();
|
|
714
888
|
}
|
|
715
889
|
}
|
|
716
890
|
};
|
|
@@ -807,7 +981,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
807
981
|
items.push({ text: this.l10n.getConstant('Custom'), id: 'custom', iconCss: 'e-icons e-custom' });
|
|
808
982
|
}
|
|
809
983
|
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('CircleSelection') > -1)) {
|
|
810
|
-
items.push({ text: this.l10n.getConstant('Circle'), id: '
|
|
984
|
+
items.push({ text: this.l10n.getConstant('Circle'), id: 'circle', iconCss: 'e-icons e-circle' });
|
|
811
985
|
}
|
|
812
986
|
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('SquareSelection') > -1)) {
|
|
813
987
|
items.push({ text: this.l10n.getConstant('Square'), id: 'square', iconCss: 'e-icons e-square' });
|
|
@@ -890,7 +1064,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
890
1064
|
}
|
|
891
1065
|
};
|
|
892
1066
|
ImageEditor.prototype.cropSelect = function (args) {
|
|
893
|
-
var text = args.item.
|
|
1067
|
+
var text = args.item.id;
|
|
894
1068
|
this.select(text);
|
|
895
1069
|
this.refreshToolbar('main', true, true);
|
|
896
1070
|
};
|
|
@@ -996,9 +1170,16 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
996
1170
|
modeSwitcher: false, noColor: true, value: '',
|
|
997
1171
|
showButtons: false, mode: 'Palette', cssClass: 'e-shape-fill-color',
|
|
998
1172
|
change: function (args) {
|
|
1173
|
+
_this.pushActItemIntoObj();
|
|
1174
|
+
var objColl = extend([], _this.objColl, [], true);
|
|
1175
|
+
_this.objColl.pop();
|
|
999
1176
|
proxy.activeObj.strokeSettings.fillColor = args.currentValue.hex;
|
|
1000
1177
|
proxy.strokeSettings.fillColor = proxy.activeObj.strokeSettings.fillColor;
|
|
1001
|
-
|
|
1178
|
+
_this.objColl.push(_this.activeObj);
|
|
1179
|
+
proxy.undoRedoColl.push({ operation: 'shapeTransform', value: null,
|
|
1180
|
+
currentObj: extend([], proxy.objColl, [], true), previousObj: objColl, factor: proxy.factor,
|
|
1181
|
+
sharpen: proxy.adjustmentLevel.sharpen, bw: proxy.adjustmentLevel.bw });
|
|
1182
|
+
proxy.redrawShape(proxy.objColl[proxy.objColl.length - 1]);
|
|
1002
1183
|
if (args.currentValue.rgba === '') {
|
|
1003
1184
|
fillDDB_1.element.children[0].classList.add('e-nocolor-item');
|
|
1004
1185
|
}
|
|
@@ -1031,10 +1212,17 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1031
1212
|
modeSwitcher: false, noColor: false, value: '#fff',
|
|
1032
1213
|
showButtons: false, mode: 'Palette', cssClass: 'e-shape-stroke-color',
|
|
1033
1214
|
change: function (args) {
|
|
1215
|
+
_this.pushActItemIntoObj();
|
|
1216
|
+
var objColl = extend([], _this.objColl, [], true);
|
|
1217
|
+
_this.objColl.pop();
|
|
1034
1218
|
proxy.activeObj.strokeSettings.strokeColor = args.currentValue.hex;
|
|
1035
1219
|
proxy.strokeSettings.strokeColor = proxy.activeObj.strokeSettings.strokeColor;
|
|
1036
1220
|
if (!proxy.togglePen) {
|
|
1037
|
-
|
|
1221
|
+
_this.objColl.push(_this.activeObj);
|
|
1222
|
+
proxy.undoRedoColl.push({ operation: 'shapeTransform', value: null,
|
|
1223
|
+
currentObj: extend([], proxy.objColl, [], true), previousObj: objColl, factor: proxy.factor,
|
|
1224
|
+
sharpen: proxy.adjustmentLevel.sharpen, bw: proxy.adjustmentLevel.bw });
|
|
1225
|
+
proxy.redrawShape(proxy.objColl[proxy.objColl.length - 1]);
|
|
1038
1226
|
}
|
|
1039
1227
|
strokeDDB_1.element.children[0].style.backgroundColor = args.currentValue.rgba;
|
|
1040
1228
|
strokeDDB_1.toggle();
|
|
@@ -1084,6 +1272,9 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1084
1272
|
}
|
|
1085
1273
|
},
|
|
1086
1274
|
select: function (args) {
|
|
1275
|
+
_this.pushActItemIntoObj();
|
|
1276
|
+
var objColl = extend([], _this.objColl, [], true);
|
|
1277
|
+
_this.objColl.pop();
|
|
1087
1278
|
spanElem_1.textContent = args.item.text;
|
|
1088
1279
|
_this.activeObj.strokeSettings.strokeWidth = parseInt(args.item.id, 10);
|
|
1089
1280
|
if (_this.lowerCanvas.width > _this.lowerCanvas.height) {
|
|
@@ -1093,19 +1284,23 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1093
1284
|
_this.activeObj.strokeSettings.strokeWidth *= ((ratio.height + ratio.width) / _this.factor);
|
|
1094
1285
|
}
|
|
1095
1286
|
_this.strokeSettings.strokeWidth = _this.activeObj.strokeSettings.strokeWidth;
|
|
1096
|
-
_this.
|
|
1287
|
+
_this.objColl.push(_this.activeObj);
|
|
1288
|
+
_this.undoRedoColl.push({ operation: 'shapeTransform', value: null,
|
|
1289
|
+
currentObj: extend([], _this.objColl, [], true), previousObj: objColl, factor: _this.factor,
|
|
1290
|
+
sharpen: _this.adjustmentLevel.sharpen, bw: _this.adjustmentLevel.bw });
|
|
1291
|
+
_this.redrawShape(_this.objColl[_this.objColl.length - 1]);
|
|
1097
1292
|
if (Browser.isDevice) {
|
|
1098
1293
|
if (!isNullOrUndefined(document.getElementById(_this.element.id + '_bottomToolbar'))) {
|
|
1099
1294
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
1100
|
-
var
|
|
1101
|
-
|
|
1295
|
+
var toolbar_5 = getComponent(_this.element.id + '_bottomToolbar', 'toolbar');
|
|
1296
|
+
toolbar_5.refreshOverflow();
|
|
1102
1297
|
}
|
|
1103
1298
|
}
|
|
1104
1299
|
else {
|
|
1105
1300
|
if (!isNullOrUndefined(document.getElementById(_this.element.id + '_toolbar'))) {
|
|
1106
1301
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
1107
|
-
var
|
|
1108
|
-
|
|
1302
|
+
var toolbar_6 = getComponent(_this.element.id + '_toolbar', 'toolbar');
|
|
1303
|
+
toolbar_6.refreshOverflow();
|
|
1109
1304
|
}
|
|
1110
1305
|
}
|
|
1111
1306
|
}
|
|
@@ -1221,17 +1416,26 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1221
1416
|
modeSwitcher: false, value: '#fff',
|
|
1222
1417
|
showButtons: false, mode: 'Palette', cssClass: 'e-text-fontt-color',
|
|
1223
1418
|
change: function (args) {
|
|
1419
|
+
_this.pushActItemIntoObj();
|
|
1420
|
+
_this.objColl.pop();
|
|
1224
1421
|
if (proxy.textBox.style.display === 'none') {
|
|
1225
1422
|
proxy.strokeSettings.strokeColor = proxy.activeObj.strokeSettings.strokeColor = args.currentValue.hex;
|
|
1226
1423
|
if (!proxy.togglePen) {
|
|
1227
|
-
|
|
1424
|
+
_this.objColl.push(_this.activeObj);
|
|
1425
|
+
proxy.redrawShape(proxy.objColl[proxy.objColl.length - 1]);
|
|
1228
1426
|
}
|
|
1229
1427
|
}
|
|
1230
1428
|
else if (proxy.textBox.style.display === 'block') {
|
|
1231
1429
|
proxy.textBox.style.color = args.currentValue.hex;
|
|
1430
|
+
var temp = proxy.activeObj.strokeSettings.strokeColor;
|
|
1431
|
+
proxy.activeObj.strokeSettings.strokeColor = args.currentValue.hex;
|
|
1432
|
+
_this.objColl.push(_this.activeObj);
|
|
1433
|
+
_this.objColl.pop();
|
|
1434
|
+
proxy.activeObj.strokeSettings.strokeColor = temp;
|
|
1232
1435
|
}
|
|
1233
1436
|
else if (!proxy.togglePen) {
|
|
1234
|
-
|
|
1437
|
+
_this.objColl.push(_this.activeObj);
|
|
1438
|
+
proxy.redrawShape(proxy.objColl[proxy.objColl.length - 1]);
|
|
1235
1439
|
}
|
|
1236
1440
|
strokeDDB_2.element.children[0].style.backgroundColor = args.currentValue.rgba;
|
|
1237
1441
|
strokeDDB_2.toggle();
|
|
@@ -1253,6 +1457,17 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1253
1457
|
= '#fff';
|
|
1254
1458
|
}
|
|
1255
1459
|
};
|
|
1460
|
+
ImageEditor.prototype.pushActItemIntoObj = function () {
|
|
1461
|
+
if (this.textBox.style.display === 'none') {
|
|
1462
|
+
this.objColl.push(this.activeObj);
|
|
1463
|
+
}
|
|
1464
|
+
else {
|
|
1465
|
+
var temp = extend({}, this.activeObj, {}, true);
|
|
1466
|
+
this.setTextBoxStylesToActObj();
|
|
1467
|
+
this.objColl.push(this.activeObj);
|
|
1468
|
+
this.activeObj = temp;
|
|
1469
|
+
}
|
|
1470
|
+
};
|
|
1256
1471
|
ImageEditor.prototype.createTextBtn = function (items) {
|
|
1257
1472
|
var _this = this;
|
|
1258
1473
|
var ratio = this.calcRatio();
|
|
@@ -1290,6 +1505,8 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1290
1505
|
+ '"' + ']').classList.add('e-selected-btn');
|
|
1291
1506
|
},
|
|
1292
1507
|
select: function (args) {
|
|
1508
|
+
_this.pushActItemIntoObj();
|
|
1509
|
+
_this.objColl.pop();
|
|
1293
1510
|
spanElem_2.textContent = args.item.text;
|
|
1294
1511
|
if (Browser.isDevice) {
|
|
1295
1512
|
spanElem_2.setAttribute('style', 'font-family:' + args.item.id);
|
|
@@ -1297,10 +1514,13 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1297
1514
|
if (_this.textBox.style.display === 'block') {
|
|
1298
1515
|
var temp = _this.activeObj.textSettings.fontFamily;
|
|
1299
1516
|
_this.activeObj.textSettings.fontFamily = _this.toPascalCase(args.item.id);
|
|
1300
|
-
_this.
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
_this.
|
|
1517
|
+
_this.redrawText(ratio);
|
|
1518
|
+
_this.objColl.push(_this.activeObj);
|
|
1519
|
+
_this.objColl.pop();
|
|
1520
|
+
_this.upperContext.clearRect(0, 0, _this.upperCanvas.width, _this.upperCanvas.height);
|
|
1521
|
+
var width = _this.activeObj.activePoint.width +
|
|
1522
|
+
_this.activeObj.textSettings.fontSize * 0.25;
|
|
1523
|
+
_this.textBox.style.width = width / ratio.width + 'px';
|
|
1304
1524
|
_this.textBox.style.fontFamily = _this.toPascalCase(args.item.id);
|
|
1305
1525
|
_this.activeObj.textSettings.fontFamily = temp;
|
|
1306
1526
|
_this.updateFontStyles();
|
|
@@ -1308,7 +1528,8 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1308
1528
|
else {
|
|
1309
1529
|
_this.textSettings.fontFamily = _this.activeObj.textSettings.fontFamily = _this.toPascalCase(args.item.id);
|
|
1310
1530
|
_this.redrawText(ratio);
|
|
1311
|
-
_this.
|
|
1531
|
+
_this.objColl.push(_this.activeObj);
|
|
1532
|
+
_this.redrawShape(_this.objColl[_this.objColl.length - 1]);
|
|
1312
1533
|
}
|
|
1313
1534
|
}
|
|
1314
1535
|
});
|
|
@@ -1407,10 +1628,14 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1407
1628
|
args.element.querySelector('[aria-label *= ' + '"' + activeBtn + '"' + ']').classList.add('e-selected-btn');
|
|
1408
1629
|
},
|
|
1409
1630
|
select: function (args) {
|
|
1631
|
+
_this.pushActItemIntoObj();
|
|
1632
|
+
_this.objColl.pop();
|
|
1410
1633
|
fontSizeSpanElem_1.textContent = args.item.text;
|
|
1411
1634
|
if (_this.textBox.style.display === 'block') {
|
|
1412
1635
|
var temp = _this.activeObj.textSettings.fontSize;
|
|
1413
1636
|
_this.activeObj.textSettings.fontSize = parseInt(_this.fontSizeColl[(parseInt(args.item.text, 10) - 1)].text, 10);
|
|
1637
|
+
_this.objColl.push(_this.activeObj);
|
|
1638
|
+
_this.objColl.pop();
|
|
1414
1639
|
var textStyle = '';
|
|
1415
1640
|
if (_this.textBox.style.fontWeight === 'bold') {
|
|
1416
1641
|
textStyle = 'bold ';
|
|
@@ -1442,11 +1667,13 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1442
1667
|
var text = _this.getMaxText();
|
|
1443
1668
|
var width = _this.upperContext.measureText(text).width +
|
|
1444
1669
|
_this.activeObj.textSettings.fontSize * 0.5;
|
|
1445
|
-
var height = rows.length * (_this.activeObj.textSettings.fontSize +
|
|
1670
|
+
var height = rows.length * (_this.activeObj.textSettings.fontSize +
|
|
1671
|
+
_this.activeObj.textSettings.fontSize * 0.25);
|
|
1446
1672
|
_this.setTextSelection(width, height);
|
|
1447
1673
|
_this.updateActiveObject(ratio, _this.activeObj.activePoint, _this.activeObj);
|
|
1448
|
-
_this.redrawShape(_this.activeObj);
|
|
1449
1674
|
_this.redrawText(ratio);
|
|
1675
|
+
_this.objColl.push(_this.activeObj);
|
|
1676
|
+
_this.redrawShape(_this.objColl[_this.objColl.length - 1]);
|
|
1450
1677
|
}
|
|
1451
1678
|
}
|
|
1452
1679
|
});
|
|
@@ -1497,14 +1724,43 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1497
1724
|
this.activeObj.textSettings.italic = tempItalic;
|
|
1498
1725
|
return width;
|
|
1499
1726
|
};
|
|
1727
|
+
ImageEditor.prototype.updateObjColl = function (item) {
|
|
1728
|
+
var tempBold = this.activeObj.textSettings.bold;
|
|
1729
|
+
var tempItalic = this.activeObj.textSettings.italic;
|
|
1730
|
+
switch (item) {
|
|
1731
|
+
case 'default':
|
|
1732
|
+
this.activeObj.textSettings.bold = false;
|
|
1733
|
+
this.activeObj.textSettings.italic = false;
|
|
1734
|
+
break;
|
|
1735
|
+
case 'bold':
|
|
1736
|
+
this.activeObj.textSettings.bold = true;
|
|
1737
|
+
this.activeObj.textSettings.italic = false;
|
|
1738
|
+
break;
|
|
1739
|
+
case 'italic':
|
|
1740
|
+
this.activeObj.textSettings.bold = false;
|
|
1741
|
+
this.activeObj.textSettings.italic = true;
|
|
1742
|
+
break;
|
|
1743
|
+
case 'bolditalic':
|
|
1744
|
+
this.activeObj.textSettings.bold = true;
|
|
1745
|
+
this.activeObj.textSettings.italic = true;
|
|
1746
|
+
break;
|
|
1747
|
+
}
|
|
1748
|
+
this.objColl.push(this.activeObj);
|
|
1749
|
+
this.objColl.pop();
|
|
1750
|
+
this.activeObj.textSettings.bold = tempBold;
|
|
1751
|
+
this.activeObj.textSettings.italic = tempItalic;
|
|
1752
|
+
};
|
|
1500
1753
|
ImageEditor.prototype.applyFontStyle = function (item, ratio) {
|
|
1754
|
+
this.pushActItemIntoObj();
|
|
1755
|
+
this.objColl.pop();
|
|
1501
1756
|
switch (item) {
|
|
1502
1757
|
case 'default':
|
|
1503
1758
|
if (this.textBox.style.display === 'block') {
|
|
1504
|
-
var width = this.getTextAreaWidth(item);
|
|
1505
|
-
this.textBox.style.width =
|
|
1759
|
+
var width = this.getTextAreaWidth(item) / ratio.width;
|
|
1760
|
+
this.textBox.style.width = width + 'px';
|
|
1506
1761
|
this.textBox.style.fontWeight = 'normal';
|
|
1507
1762
|
this.textBox.style.fontStyle = 'normal';
|
|
1763
|
+
this.updateObjColl(item);
|
|
1508
1764
|
}
|
|
1509
1765
|
else {
|
|
1510
1766
|
this.textSettings.bold = this.activeObj.textSettings.bold = false;
|
|
@@ -1514,10 +1770,11 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1514
1770
|
break;
|
|
1515
1771
|
case 'bold':
|
|
1516
1772
|
if (this.textBox.style.display === 'block') {
|
|
1517
|
-
var width = this.getTextAreaWidth(item);
|
|
1518
|
-
this.textBox.style.width =
|
|
1773
|
+
var width = this.getTextAreaWidth(item) / ratio.width;
|
|
1774
|
+
this.textBox.style.width = width + 'px';
|
|
1519
1775
|
this.textBox.style.fontWeight = 'bold';
|
|
1520
1776
|
this.textBox.style.fontStyle = 'normal';
|
|
1777
|
+
this.updateObjColl(item);
|
|
1521
1778
|
}
|
|
1522
1779
|
else {
|
|
1523
1780
|
this.textSettings.bold = this.activeObj.textSettings.bold = true;
|
|
@@ -1527,10 +1784,11 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1527
1784
|
break;
|
|
1528
1785
|
case 'italic':
|
|
1529
1786
|
if (this.textBox.style.display === 'block') {
|
|
1530
|
-
var width = this.getTextAreaWidth(item);
|
|
1531
|
-
this.textBox.style.width =
|
|
1787
|
+
var width = this.getTextAreaWidth(item) / ratio.width;
|
|
1788
|
+
this.textBox.style.width = width + 'px';
|
|
1532
1789
|
this.textBox.style.fontWeight = 'normal';
|
|
1533
1790
|
this.textBox.style.fontStyle = 'italic';
|
|
1791
|
+
this.updateObjColl(item);
|
|
1534
1792
|
}
|
|
1535
1793
|
else {
|
|
1536
1794
|
this.textSettings.bold = this.activeObj.textSettings.bold = false;
|
|
@@ -1540,10 +1798,11 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1540
1798
|
break;
|
|
1541
1799
|
case 'bolditalic':
|
|
1542
1800
|
if (this.textBox.style.display === 'block') {
|
|
1543
|
-
var width = this.getTextAreaWidth(item);
|
|
1544
|
-
this.textBox.style.width =
|
|
1801
|
+
var width = this.getTextAreaWidth(item) / ratio.width;
|
|
1802
|
+
this.textBox.style.width = width + 'px';
|
|
1545
1803
|
this.textBox.style.fontWeight = 'bold';
|
|
1546
1804
|
this.textBox.style.fontStyle = 'italic';
|
|
1805
|
+
this.updateObjColl(item);
|
|
1547
1806
|
}
|
|
1548
1807
|
else {
|
|
1549
1808
|
this.textSettings.bold = this.activeObj.textSettings.bold = true;
|
|
@@ -1571,12 +1830,25 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1571
1830
|
this.createLeftToolbarControls();
|
|
1572
1831
|
if (this.defToolbarItems.length > 0 && (!isNullOrUndefined(document.getElementById(this.element.id + '_toolbar')))) {
|
|
1573
1832
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
1574
|
-
var
|
|
1575
|
-
|
|
1833
|
+
var toolbar_7 = getComponent(this.element.id + '_toolbar', 'toolbar');
|
|
1834
|
+
toolbar_7.refreshOverflow();
|
|
1835
|
+
}
|
|
1836
|
+
};
|
|
1837
|
+
ImageEditor.prototype.contextualToolbarClicked = function (args) {
|
|
1838
|
+
var selEle = this.element.querySelector('.e-contextual-toolbar-wrapper .e-toolbar-item.e-selected');
|
|
1839
|
+
if (selEle) {
|
|
1840
|
+
selEle.classList.remove('e-selected');
|
|
1576
1841
|
}
|
|
1842
|
+
document.getElementById(args.item.id + 'Canvas').parentElement.parentElement.classList.add('e-selected');
|
|
1843
|
+
this.currObjType.isFiltered = true;
|
|
1844
|
+
var type = args.item.id.replace(this.element.id, '').split('_')[1];
|
|
1845
|
+
var imageFiltering = { filter: this.toPascalCase(type) };
|
|
1846
|
+
this.trigger('imageFiltering', imageFiltering);
|
|
1847
|
+
this.setFilter(type.toLowerCase());
|
|
1848
|
+
this.currentFilter = args.item.id;
|
|
1577
1849
|
};
|
|
1578
1850
|
ImageEditor.prototype.defToolbarClicked = function (args) {
|
|
1579
|
-
|
|
1851
|
+
this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
|
|
1580
1852
|
var zoomIn;
|
|
1581
1853
|
var type = args.item.id.replace(this.element.id + '_', '').toLowerCase();
|
|
1582
1854
|
var imageEditorObj = getInstance(document.getElementById(this.element.id), ImageEditor_1);
|
|
@@ -1595,61 +1867,23 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1595
1867
|
if (!this.disabled) {
|
|
1596
1868
|
switch (type) {
|
|
1597
1869
|
case 'zoomin':
|
|
1870
|
+
this.currObjType.isFiltered = false;
|
|
1598
1871
|
if (this.togglePen) {
|
|
1599
1872
|
this.currObjType.isZoomed = true;
|
|
1600
1873
|
this.freeHandDraw(false);
|
|
1601
1874
|
}
|
|
1602
1875
|
imageEditorObj.zoom(.1);
|
|
1603
|
-
if (!this.togglePan) {
|
|
1604
|
-
this.callMainToolbar(false, true);
|
|
1605
|
-
}
|
|
1606
|
-
if (this.factor > 0.95 && this.factor < 1.05) {
|
|
1607
|
-
this.dragCanvas = this.togglePan = false;
|
|
1608
|
-
this.callMainToolbar(false, true);
|
|
1609
|
-
}
|
|
1610
|
-
if (isNullOrUndefined(this.activeObj.activePoint) || this.activeObj.activePoint.width === 0) {
|
|
1611
|
-
this.refreshToolbar('main');
|
|
1612
|
-
}
|
|
1613
|
-
else {
|
|
1614
|
-
this.refreshToolbar('main', true, true);
|
|
1615
|
-
}
|
|
1616
|
-
panBtn = this.element.querySelector('.e-img-pan .e-btn');
|
|
1617
|
-
if (!isNullOrUndefined(panBtn) && this.togglePan) {
|
|
1618
|
-
panBtn.classList.add('e-selected-btn');
|
|
1619
|
-
}
|
|
1620
|
-
else if (!isNullOrUndefined(panBtn)) {
|
|
1621
|
-
panBtn.classList.remove('e-selected-btn');
|
|
1622
|
-
}
|
|
1623
1876
|
break;
|
|
1624
1877
|
case 'zoomout':
|
|
1878
|
+
this.currObjType.isFiltered = false;
|
|
1625
1879
|
if (this.togglePen) {
|
|
1626
1880
|
this.currObjType.isZoomed = true;
|
|
1627
1881
|
this.freeHandDraw(false);
|
|
1628
1882
|
}
|
|
1629
1883
|
imageEditorObj.zoom(-.1);
|
|
1630
|
-
if (!this.togglePan) {
|
|
1631
|
-
this.callMainToolbar(false, true);
|
|
1632
|
-
}
|
|
1633
|
-
if (this.factor > 0.95 && this.factor < 1.05) {
|
|
1634
|
-
this.dragCanvas = this.togglePan = false;
|
|
1635
|
-
this.callMainToolbar(false, true);
|
|
1636
|
-
}
|
|
1637
|
-
if (isNullOrUndefined(this.activeObj.activePoint) || this.activeObj.activePoint.width === 0) {
|
|
1638
|
-
this.refreshToolbar('main');
|
|
1639
|
-
}
|
|
1640
|
-
else {
|
|
1641
|
-
this.refreshToolbar('main', true, true);
|
|
1642
|
-
}
|
|
1643
|
-
panBtn = this.element.querySelector('.e-img-pan .e-btn');
|
|
1644
|
-
if (!isNullOrUndefined(panBtn) && this.togglePan) {
|
|
1645
|
-
panBtn.classList.add('e-selected-btn');
|
|
1646
|
-
}
|
|
1647
|
-
else if (!isNullOrUndefined(panBtn)) {
|
|
1648
|
-
panBtn.classList.remove('e-selected-btn');
|
|
1649
|
-
}
|
|
1650
1884
|
break;
|
|
1651
1885
|
case 'pan':
|
|
1652
|
-
this.currObjType.isCustomCrop = false;
|
|
1886
|
+
this.currObjType.isCustomCrop = this.currObjType.isFiltered = false;
|
|
1653
1887
|
if (isCropSelection) {
|
|
1654
1888
|
this.currObjType.isCustomCrop = false;
|
|
1655
1889
|
this.refreshActiveObj();
|
|
@@ -1658,11 +1892,13 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1658
1892
|
}
|
|
1659
1893
|
if (this.togglePan) {
|
|
1660
1894
|
this.cancelPan();
|
|
1895
|
+
this.disablePan = true;
|
|
1661
1896
|
}
|
|
1662
1897
|
else {
|
|
1663
1898
|
panBtn = this.element.querySelector('.e-img-pan .e-btn');
|
|
1664
1899
|
panBtn.classList.add('e-selected-btn');
|
|
1665
1900
|
imageEditorObj.pan(true);
|
|
1901
|
+
this.disablePan = false;
|
|
1666
1902
|
}
|
|
1667
1903
|
zoomIn = document.querySelector('#' + this.element.id + '_zoomIn');
|
|
1668
1904
|
if (!isNullOrUndefined(zoomIn) && this.factor >= 8) {
|
|
@@ -1680,46 +1916,113 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1680
1916
|
this.activeObj.strokeSettings = this.tempStrokeSettings;
|
|
1681
1917
|
this.activeObj.textSettings = this.tempTextSettings;
|
|
1682
1918
|
}
|
|
1919
|
+
else if (!isNullOrUndefined(document.querySelector('#' + this.element.id + '_sliderWrapper')) ||
|
|
1920
|
+
this.currObjType.isFiltered) {
|
|
1921
|
+
this.lowerContext.filter = this.adjustmentValue = this.initialAdjustmentValue = this.tempAdjustmentValue;
|
|
1922
|
+
this.currentFilter = this.tempFilter;
|
|
1923
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
1924
|
+
this.redrawImgWithObj();
|
|
1925
|
+
this.currObjType.isFiltered = false;
|
|
1926
|
+
if (this.adjustmentLevel.sharpen || this.adjustmentLevel.bw) {
|
|
1927
|
+
if (this.adjustmentLevel.sharpen) {
|
|
1928
|
+
this.setSharpness(false);
|
|
1929
|
+
}
|
|
1930
|
+
else if (this.adjustmentLevel.bw) {
|
|
1931
|
+
this.setBlackAndWhiteFilter(false);
|
|
1932
|
+
}
|
|
1933
|
+
var tempFilter = this.lowerContext.filter;
|
|
1934
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
1935
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
1936
|
+
for (var j = 0; j < this.objColl.length; j++) {
|
|
1937
|
+
this.apply(this.objColl[j].shape, this.objColl[j]);
|
|
1938
|
+
this.refreshActiveObj();
|
|
1939
|
+
}
|
|
1940
|
+
this.lowerContext.filter = tempFilter;
|
|
1941
|
+
}
|
|
1942
|
+
this.adjustmentLevel = extend({}, this.tempAdjustmentLevel, {}, true);
|
|
1943
|
+
if (this.currentFilter === this.element.id + '_sharpen' || this.currentFilter === this.element.id + '_blackandwhite'
|
|
1944
|
+
|| this.tempSharpenFilter || this.tempBWFilter) {
|
|
1945
|
+
if (this.currentFilter === this.element.id + '_sharpen' || this.tempSharpenFilter) {
|
|
1946
|
+
this.setSharpness(true);
|
|
1947
|
+
}
|
|
1948
|
+
else if (this.currentFilter === this.element.id + '_blackandwhite' || this.tempBWFilter) {
|
|
1949
|
+
this.setBlackAndWhiteFilter(true);
|
|
1950
|
+
}
|
|
1951
|
+
var tempFilter = this.lowerContext.filter;
|
|
1952
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
1953
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
1954
|
+
for (var j = 0; j < this.objColl.length; j++) {
|
|
1955
|
+
this.apply(this.objColl[j].shape, this.objColl[j]);
|
|
1956
|
+
this.refreshActiveObj();
|
|
1957
|
+
}
|
|
1958
|
+
this.lowerContext.filter = tempFilter;
|
|
1959
|
+
this.tempSharpenFilter = this.tempBWFilter = false;
|
|
1960
|
+
}
|
|
1961
|
+
this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
|
|
1962
|
+
}
|
|
1683
1963
|
this.cancelItems();
|
|
1684
1964
|
break;
|
|
1685
1965
|
case 'ok':
|
|
1686
|
-
|
|
1687
|
-
this.crop();
|
|
1688
|
-
}
|
|
1689
|
-
else if (this.togglePen) {
|
|
1690
|
-
this.freeHandDraw(false);
|
|
1691
|
-
}
|
|
1692
|
-
else if (this.textBox.style.display === 'block') {
|
|
1693
|
-
this.redrawActObj();
|
|
1694
|
-
}
|
|
1695
|
-
else {
|
|
1696
|
-
this.applyActObj();
|
|
1697
|
-
}
|
|
1698
|
-
this.callMainToolbar(false);
|
|
1966
|
+
this.okBtn();
|
|
1699
1967
|
break;
|
|
1700
1968
|
case 'reset':
|
|
1701
1969
|
imageEditorObj.reset();
|
|
1702
1970
|
break;
|
|
1971
|
+
case 'adjustment':
|
|
1972
|
+
this.upperCanvas.style.display = 'block';
|
|
1973
|
+
this.refreshToolbar('adjustment');
|
|
1974
|
+
this.lowerContext.filter = this.initialAdjustmentValue;
|
|
1975
|
+
this.tempAdjustmentValue = this.lowerContext.filter;
|
|
1976
|
+
this.tempAdjustmentLevel = extend({}, this.adjustmentLevel, {}, true);
|
|
1977
|
+
this.tempFilter = this.currentFilter;
|
|
1978
|
+
this.tempSharpenFilter = this.adjustmentLevel.sharpen;
|
|
1979
|
+
this.tempBWFilter = this.adjustmentLevel.bw;
|
|
1980
|
+
break;
|
|
1981
|
+
case 'brightness':
|
|
1982
|
+
case 'contrast':
|
|
1983
|
+
case 'hue':
|
|
1984
|
+
case 'saturation':
|
|
1985
|
+
case 'opacity':
|
|
1986
|
+
case 'blur':
|
|
1987
|
+
case 'exposure':
|
|
1988
|
+
this.unselectBtn();
|
|
1989
|
+
this.currObjType.isFiltered = true;
|
|
1990
|
+
this.refreshToolbar('color', null, null, null, type);
|
|
1991
|
+
document.getElementById(this.element.id + '_' + type).classList.add('e-selected-btn');
|
|
1992
|
+
break;
|
|
1993
|
+
case 'filter':
|
|
1994
|
+
this.upperCanvas.style.display = 'block';
|
|
1995
|
+
this.refreshToolbar('filter');
|
|
1996
|
+
this.lowerContext.filter = this.initialAdjustmentValue;
|
|
1997
|
+
this.tempAdjustmentValue = this.lowerContext.filter;
|
|
1998
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
1999
|
+
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
2000
|
+
for (var j = 0; j < this.objColl.length; j++) {
|
|
2001
|
+
this.apply(this.objColl[j].shape, this.objColl[j]);
|
|
2002
|
+
this.refreshActiveObj();
|
|
2003
|
+
}
|
|
2004
|
+
this.tempAdjustmentLevel = extend({}, this.adjustmentLevel, {}, true);
|
|
2005
|
+
this.tempFilter = this.currentFilter;
|
|
2006
|
+
this.tempSharpenFilter = this.adjustmentLevel.sharpen;
|
|
2007
|
+
this.tempBWFilter = this.adjustmentLevel.bw;
|
|
2008
|
+
break;
|
|
2009
|
+
case 'default':
|
|
2010
|
+
case 'chrome':
|
|
2011
|
+
case 'cold':
|
|
2012
|
+
case 'warm':
|
|
2013
|
+
case 'grayscale':
|
|
2014
|
+
case 'blackandwhite':
|
|
2015
|
+
case 'sepia':
|
|
2016
|
+
case 'invert':
|
|
2017
|
+
case 'sharpen':
|
|
2018
|
+
this.currObjType.isFiltered = true;
|
|
2019
|
+
this.setFilter(type);
|
|
2020
|
+
break;
|
|
1703
2021
|
}
|
|
1704
2022
|
}
|
|
1705
2023
|
this.trigger('toolbarItemClicked', args);
|
|
1706
2024
|
};
|
|
1707
|
-
ImageEditor.prototype.
|
|
1708
|
-
this.applyActObj();
|
|
1709
|
-
var panBtn = this.element.querySelector('.e-img-pan .e-btn');
|
|
1710
|
-
panBtn.classList.remove('e-selected-btn');
|
|
1711
|
-
this.pan(false);
|
|
1712
|
-
};
|
|
1713
|
-
ImageEditor.prototype.callMainToolbar = function (isApplyBtn, isZooming) {
|
|
1714
|
-
if (this.factor === 1) {
|
|
1715
|
-
this.refreshToolbar('main', isApplyBtn, false, isZooming);
|
|
1716
|
-
}
|
|
1717
|
-
else {
|
|
1718
|
-
this.refreshToolbar('main', isApplyBtn, false, isZooming);
|
|
1719
|
-
}
|
|
1720
|
-
};
|
|
1721
|
-
ImageEditor.prototype.cancelItems = function () {
|
|
1722
|
-
var ratio = this.calcRatio();
|
|
2025
|
+
ImageEditor.prototype.okBtn = function () {
|
|
1723
2026
|
var isCropSelection = false;
|
|
1724
2027
|
var splitWords;
|
|
1725
2028
|
if (this.activeObj.shape !== undefined) {
|
|
@@ -1731,107 +2034,795 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1731
2034
|
else if (splitWords !== undefined && splitWords[0] === 'crop') {
|
|
1732
2035
|
isCropSelection = true;
|
|
1733
2036
|
}
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
this.
|
|
1737
|
-
this.upperCanvas.style.cursor = 'default';
|
|
1738
|
-
this.penDrawColl = [];
|
|
1739
|
-
this.imageEditorPointsColl = [];
|
|
2037
|
+
var selElem = this.element.querySelector('.e-contextual-toolbar-wrapper .e-toolbar-item.e-selected');
|
|
2038
|
+
if (selElem) {
|
|
2039
|
+
this.currentFilter = selElem.children[0].children[0].id.replace('Canvas', '');
|
|
1740
2040
|
}
|
|
1741
|
-
|
|
1742
|
-
this.
|
|
1743
|
-
this.activeObj.textSettings = this.tempTextSettings;
|
|
1744
|
-
if (this.activeObj.keyHistory === 'Enter Text' && this.activeObj.activePoint.startX === this.textStartPoints.x
|
|
1745
|
-
&& this.activeObj.activePoint.startY === this.textStartPoints.y) {
|
|
1746
|
-
this.refreshActiveObj();
|
|
1747
|
-
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
1748
|
-
this.drawShapeText();
|
|
1749
|
-
}
|
|
1750
|
-
else {
|
|
1751
|
-
this.redrawText(ratio);
|
|
1752
|
-
this.redrawShape(this.activeObj);
|
|
1753
|
-
if (!isCropSelection && this.activeObj.topLeftCircle !== undefined) {
|
|
1754
|
-
this.applyActObj();
|
|
1755
|
-
}
|
|
1756
|
-
this.clearSelection();
|
|
1757
|
-
}
|
|
1758
|
-
this.tempTextSettings = { text: 'Enter Text', fontFamily: 'Arial', fontSize: null, bold: false, italic: false, underline: false };
|
|
2041
|
+
if (isCropSelection) {
|
|
2042
|
+
this.crop();
|
|
1759
2043
|
}
|
|
1760
|
-
else if (this.
|
|
1761
|
-
this.
|
|
1762
|
-
|
|
1763
|
-
|
|
2044
|
+
else if (this.togglePen) {
|
|
2045
|
+
this.freeHandDraw(false);
|
|
2046
|
+
}
|
|
2047
|
+
else if (this.textBox.style.display === 'block') {
|
|
2048
|
+
this.redrawActObj();
|
|
2049
|
+
}
|
|
2050
|
+
else if (!isNullOrUndefined(document.querySelector('#' + this.element.id + '_sliderWrapper')) ||
|
|
2051
|
+
this.currObjType.isFiltered) {
|
|
2052
|
+
this.initialAdjustmentValue = this.canvasFilter = this.lowerContext.filter;
|
|
2053
|
+
this.currObjType.isFiltered = false;
|
|
1764
2054
|
}
|
|
1765
2055
|
else {
|
|
1766
|
-
this.
|
|
1767
|
-
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
2056
|
+
this.applyActObj();
|
|
1768
2057
|
}
|
|
1769
|
-
this.
|
|
1770
|
-
this.currObjType.isCustomCrop = false;
|
|
1771
|
-
this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null };
|
|
1772
|
-
this.callMainToolbar();
|
|
2058
|
+
this.callMainToolbar(false);
|
|
1773
2059
|
};
|
|
1774
|
-
ImageEditor.prototype.
|
|
1775
|
-
|
|
2060
|
+
ImageEditor.prototype.unselectBtn = function () {
|
|
2061
|
+
if (document.querySelector('#' + this.element.id + '_brightness').classList.contains('e-selected-btn')) {
|
|
2062
|
+
document.querySelector('#' + this.element.id + '_brightness').classList.remove('e-selected-btn');
|
|
2063
|
+
}
|
|
2064
|
+
else if (document.querySelector('#' + this.element.id + '_contrast').classList.contains('e-selected-btn')) {
|
|
2065
|
+
document.querySelector('#' + this.element.id + '_contrast').classList.remove('e-selected-btn');
|
|
2066
|
+
}
|
|
2067
|
+
else if (document.querySelector('#' + this.element.id + '_hue').classList.contains('e-selected-btn')) {
|
|
2068
|
+
document.querySelector('#' + this.element.id + '_hue').classList.remove('e-selected-btn');
|
|
2069
|
+
}
|
|
2070
|
+
else if (document.querySelector('#' + this.element.id + '_saturation').classList.contains('e-selected-btn')) {
|
|
2071
|
+
document.querySelector('#' + this.element.id + '_saturation').classList.remove('e-selected-btn');
|
|
2072
|
+
}
|
|
2073
|
+
else if (document.querySelector('#' + this.element.id + '_opacity').classList.contains('e-selected-btn')) {
|
|
2074
|
+
document.querySelector('#' + this.element.id + '_opacity').classList.remove('e-selected-btn');
|
|
2075
|
+
}
|
|
2076
|
+
else if (document.querySelector('#' + this.element.id + '_blur').classList.contains('e-selected-btn')) {
|
|
2077
|
+
document.querySelector('#' + this.element.id + '_blur').classList.remove('e-selected-btn');
|
|
2078
|
+
}
|
|
2079
|
+
else if (document.querySelector('#' + this.element.id + '_exposure').classList.contains('e-selected-btn')) {
|
|
2080
|
+
document.querySelector('#' + this.element.id + '_exposure').classList.remove('e-selected-btn');
|
|
2081
|
+
}
|
|
1776
2082
|
};
|
|
1777
|
-
ImageEditor.prototype.
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
2083
|
+
ImageEditor.prototype.refreshSlider = function () {
|
|
2084
|
+
var sliderWrapper = document.querySelector('#' + this.element.id + '_sliderWrapper');
|
|
2085
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
2086
|
+
var slider = document.querySelector('.e-slider');
|
|
2087
|
+
var hdrWrapper = document.querySelector('#' + this.element.id + '_headWrapper');
|
|
2088
|
+
if (hdrWrapper) {
|
|
2089
|
+
hdrWrapper.style.display = 'none';
|
|
1782
2090
|
}
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
dy2 = 0;
|
|
1818
|
-
}
|
|
1819
|
-
tempContext.bezierCurveTo(preP.x - dx1, preP.y - dy1, curP.x + dx2, curP.y + dy2, curP.x, curP.y);
|
|
1820
|
-
dx1 = dx2;
|
|
1821
|
-
dy1 = dy2;
|
|
1822
|
-
preP = curP;
|
|
1823
|
-
if (this.penDrawColl[i].points.length > 2) {
|
|
1824
|
-
this.penDrawColl[i].points.shift();
|
|
1825
|
-
}
|
|
1826
|
-
tempContext.stroke();
|
|
2091
|
+
if (!isNullOrUndefined(sliderWrapper) && !isNullOrUndefined(slider)) {
|
|
2092
|
+
slider.ej2_instances[0].destroy();
|
|
2093
|
+
sliderWrapper.remove();
|
|
2094
|
+
}
|
|
2095
|
+
};
|
|
2096
|
+
ImageEditor.prototype.updateAdjustment = function (type, value, isPreview) {
|
|
2097
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
2098
|
+
var splitWords = this.lowerContext.filter.split(' ');
|
|
2099
|
+
var values = [];
|
|
2100
|
+
var opacityValue;
|
|
2101
|
+
var brightnessValue;
|
|
2102
|
+
if (splitWords[4] !== undefined) {
|
|
2103
|
+
opacityValue = parseFloat(splitWords[4].split('(')[1]);
|
|
2104
|
+
}
|
|
2105
|
+
if (splitWords[0] !== undefined) {
|
|
2106
|
+
brightnessValue = parseFloat(splitWords[0].split('(')[1]);
|
|
2107
|
+
}
|
|
2108
|
+
var brightness = this.getFilterValue(this.adjustmentLevel.brightness);
|
|
2109
|
+
var saturation = this.getFilterValue(this.adjustmentLevel.saturation);
|
|
2110
|
+
if (type !== 'brightness' && type !== 'contrast' && type !== 'hue' && type !== 'saturation' && type !== 'exposure'
|
|
2111
|
+
&& type !== 'opacity' && type !== 'blur') {
|
|
2112
|
+
if (isNullOrUndefined(isPreview) && (this.adjustmentLevel.sharpen || this.adjustmentLevel.bw)) {
|
|
2113
|
+
if (this.adjustmentLevel.sharpen) {
|
|
2114
|
+
this.setSharpness(false);
|
|
2115
|
+
}
|
|
2116
|
+
else if (this.adjustmentLevel.bw) {
|
|
2117
|
+
this.setBlackAndWhiteFilter(false);
|
|
2118
|
+
}
|
|
2119
|
+
var temp_1 = this.lowerContext.filter;
|
|
2120
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
2121
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
2122
|
+
for (var i = 0; i < this.objColl.length; i++) {
|
|
2123
|
+
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
2124
|
+
this.refreshActiveObj();
|
|
1827
2125
|
}
|
|
2126
|
+
this.lowerContext.filter = temp_1;
|
|
1828
2127
|
}
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
2128
|
+
}
|
|
2129
|
+
if (brightness !== 1) {
|
|
2130
|
+
splitWords[4] = 'opacity(' + (opacityValue - 0.3) + ')';
|
|
2131
|
+
}
|
|
2132
|
+
var saturate;
|
|
2133
|
+
var bright;
|
|
2134
|
+
var contrast;
|
|
2135
|
+
var saturatePercentage;
|
|
2136
|
+
var saturatePercent;
|
|
2137
|
+
var tempFilter;
|
|
2138
|
+
var temp;
|
|
2139
|
+
switch (type) {
|
|
2140
|
+
case 'brightness':
|
|
2141
|
+
if (splitWords[3].split) {
|
|
2142
|
+
if (parseFloat(splitWords[3].split('(')[1]) !== 100) {
|
|
2143
|
+
value += 0.1;
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2146
|
+
splitWords[0] = 'brightness(' + value + ')';
|
|
2147
|
+
this.adjustmentValue = splitWords.join(' ');
|
|
2148
|
+
break;
|
|
2149
|
+
case 'contrast':
|
|
2150
|
+
splitWords[1] = 'contrast(' + value + '%)';
|
|
2151
|
+
this.adjustmentValue = splitWords.join(' ');
|
|
2152
|
+
break;
|
|
2153
|
+
case 'hue':
|
|
2154
|
+
splitWords[2] = 'hue-rotate(' + value + 'deg)';
|
|
2155
|
+
this.adjustmentValue = splitWords.join(' ');
|
|
2156
|
+
break;
|
|
2157
|
+
case 'saturation':
|
|
2158
|
+
splitWords[3] = 'saturate(' + value + '%)';
|
|
2159
|
+
if (saturation !== 1) {
|
|
2160
|
+
splitWords[0] = 'brightness(' + (brightnessValue + 0.1) + ')';
|
|
2161
|
+
}
|
|
2162
|
+
this.adjustmentValue = splitWords.join(' ');
|
|
2163
|
+
break;
|
|
2164
|
+
case 'opacity':
|
|
2165
|
+
if (parseFloat(splitWords[0].split('(')[1]) !== 1) {
|
|
2166
|
+
value -= 0.2;
|
|
2167
|
+
}
|
|
2168
|
+
splitWords[4] = 'opacity(' + value + ')';
|
|
2169
|
+
this.adjustmentValue = splitWords.join(' ');
|
|
2170
|
+
break;
|
|
2171
|
+
case 'blur':
|
|
2172
|
+
splitWords[5] = 'blur(' + value + 'px)';
|
|
2173
|
+
this.adjustmentValue = splitWords.join(' ');
|
|
2174
|
+
break;
|
|
2175
|
+
case 'exposure':
|
|
2176
|
+
if (brightness !== 1) {
|
|
2177
|
+
splitWords[4] = 'opacity(' + (opacityValue - 0.3) + ')';
|
|
2178
|
+
}
|
|
2179
|
+
if (value > 1) {
|
|
2180
|
+
value -= 1;
|
|
2181
|
+
value += brightness;
|
|
2182
|
+
}
|
|
2183
|
+
else if (value < 1) {
|
|
2184
|
+
value = 1 - value;
|
|
2185
|
+
value = brightness - value;
|
|
2186
|
+
}
|
|
2187
|
+
splitWords[0] = 'brightness(' + value + ')';
|
|
2188
|
+
this.adjustmentValue = splitWords.join(' ');
|
|
2189
|
+
break;
|
|
2190
|
+
case 'chrome':
|
|
2191
|
+
saturate = this.getSaturationFilterValue(this.adjustmentLevel.saturation);
|
|
2192
|
+
saturate *= 100;
|
|
2193
|
+
value = saturate + (saturate * 0.4);
|
|
2194
|
+
splitWords[3] = 'saturate(' + value + '%)';
|
|
2195
|
+
values = this.adjustmentValue.split(' ');
|
|
2196
|
+
splitWords[0] = values[0];
|
|
2197
|
+
splitWords[1] = values[1];
|
|
2198
|
+
splitWords[2] = values[2];
|
|
2199
|
+
splitWords[4] = values[4];
|
|
2200
|
+
splitWords[5] = values[5];
|
|
2201
|
+
splitWords[6] = 'sepia(0%)';
|
|
2202
|
+
splitWords[7] = 'grayscale(0%)';
|
|
2203
|
+
splitWords[8] = 'invert(0%)';
|
|
2204
|
+
break;
|
|
2205
|
+
case 'cold':
|
|
2206
|
+
// Adjusting Brightness
|
|
2207
|
+
bright = this.getFilterValue(this.adjustmentLevel.brightness);
|
|
2208
|
+
bright *= 100;
|
|
2209
|
+
value = bright * 0.9;
|
|
2210
|
+
splitWords[0] = 'brightness(' + value + '%)';
|
|
2211
|
+
// Adjusting Contrast
|
|
2212
|
+
contrast = this.getFilterValue(this.adjustmentLevel.contrast);
|
|
2213
|
+
contrast *= 100;
|
|
2214
|
+
value = contrast + (contrast * 0.5);
|
|
2215
|
+
splitWords[1] = 'contrast(' + value + '%)';
|
|
2216
|
+
// Adjusting Saturation
|
|
2217
|
+
saturatePercentage = this.getSaturationFilterValue(this.adjustmentLevel.saturation);
|
|
2218
|
+
saturatePercentage *= 100;
|
|
2219
|
+
value = saturatePercentage;
|
|
2220
|
+
splitWords[3] = 'saturate(' + value + '%)';
|
|
2221
|
+
values = this.adjustmentValue.split(' ');
|
|
2222
|
+
splitWords[2] = values[2];
|
|
2223
|
+
splitWords[4] = values[4];
|
|
2224
|
+
splitWords[5] = values[5];
|
|
2225
|
+
splitWords[6] = 'sepia(0%)';
|
|
2226
|
+
splitWords[7] = 'grayscale(0%)';
|
|
2227
|
+
splitWords[8] = 'invert(0%)';
|
|
2228
|
+
break;
|
|
2229
|
+
case 'warm':
|
|
2230
|
+
saturatePercent = this.getSaturationFilterValue(this.adjustmentLevel.saturation);
|
|
2231
|
+
saturatePercent *= 100;
|
|
2232
|
+
value = saturatePercent + (saturatePercent * 0.4);
|
|
2233
|
+
splitWords[3] = 'saturate(' + value + '%)';
|
|
2234
|
+
splitWords[6] = 'sepia(25%)';
|
|
2235
|
+
values = this.adjustmentValue.split(' ');
|
|
2236
|
+
splitWords[0] = values[0];
|
|
2237
|
+
splitWords[1] = values[1];
|
|
2238
|
+
splitWords[2] = values[2];
|
|
2239
|
+
splitWords[4] = values[4];
|
|
2240
|
+
splitWords[5] = values[5];
|
|
2241
|
+
splitWords[7] = 'grayscale(0%)';
|
|
2242
|
+
splitWords[8] = 'invert(0%)';
|
|
2243
|
+
break;
|
|
2244
|
+
case 'grayscale':
|
|
2245
|
+
splitWords[7] = 'grayscale(100%)';
|
|
2246
|
+
values = this.adjustmentValue.split(' ');
|
|
2247
|
+
splitWords[0] = values[0];
|
|
2248
|
+
splitWords[1] = values[1];
|
|
2249
|
+
splitWords[2] = values[2];
|
|
2250
|
+
splitWords[3] = values[3];
|
|
2251
|
+
splitWords[4] = values[4];
|
|
2252
|
+
splitWords[5] = values[5];
|
|
2253
|
+
splitWords[6] = 'sepia(0%)';
|
|
2254
|
+
splitWords[8] = 'invert(0%)';
|
|
2255
|
+
break;
|
|
2256
|
+
case 'blackandwhite':
|
|
2257
|
+
values = this.adjustmentValue.split(' ');
|
|
2258
|
+
if (isPreview) {
|
|
2259
|
+
tempFilter = this.lowerContext.filter;
|
|
2260
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
2261
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
2262
|
+
this.setBlackAndWhiteFilter(true);
|
|
2263
|
+
for (var i = 0; i < this.objColl.length; i++) {
|
|
2264
|
+
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
2265
|
+
this.refreshActiveObj();
|
|
2266
|
+
}
|
|
2267
|
+
splitWords[0] = values[0];
|
|
2268
|
+
splitWords[1] = values[1];
|
|
2269
|
+
splitWords[2] = values[2];
|
|
2270
|
+
splitWords[3] = values[3];
|
|
2271
|
+
splitWords[4] = values[4];
|
|
2272
|
+
splitWords[5] = values[5];
|
|
2273
|
+
splitWords[6] = 'sepia(0%)';
|
|
2274
|
+
splitWords[7] = 'grayscale(0%)';
|
|
2275
|
+
splitWords[8] = 'invert(0%)';
|
|
2276
|
+
}
|
|
2277
|
+
else {
|
|
2278
|
+
tempFilter = this.lowerContext.filter;
|
|
2279
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
2280
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
2281
|
+
this.setBlackAndWhiteFilter(true);
|
|
2282
|
+
splitWords[0] = values[0];
|
|
2283
|
+
splitWords[1] = values[1];
|
|
2284
|
+
splitWords[2] = values[2];
|
|
2285
|
+
splitWords[3] = values[3];
|
|
2286
|
+
splitWords[4] = values[4];
|
|
2287
|
+
splitWords[5] = values[5];
|
|
2288
|
+
splitWords[6] = 'sepia(0%)';
|
|
2289
|
+
splitWords[7] = 'grayscale(0%)';
|
|
2290
|
+
splitWords[8] = 'invert(0%)';
|
|
2291
|
+
this.lowerContext.filter = this.initialAdjustmentValue = splitWords.join(' ');
|
|
2292
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
2293
|
+
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
2294
|
+
tempFilter = this.lowerContext.filter;
|
|
2295
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
2296
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
2297
|
+
for (var i = 0; i < this.objColl.length; i++) {
|
|
2298
|
+
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
2299
|
+
this.refreshActiveObj();
|
|
2300
|
+
}
|
|
2301
|
+
this.lowerContext.filter = tempFilter;
|
|
2302
|
+
}
|
|
2303
|
+
break;
|
|
2304
|
+
case 'sepia':
|
|
2305
|
+
splitWords[6] = 'sepia(100%)';
|
|
2306
|
+
values = this.adjustmentValue.split(' ');
|
|
2307
|
+
splitWords[0] = values[0];
|
|
2308
|
+
splitWords[1] = values[1];
|
|
2309
|
+
splitWords[2] = values[2];
|
|
2310
|
+
splitWords[3] = values[3];
|
|
2311
|
+
splitWords[4] = values[4];
|
|
2312
|
+
splitWords[5] = values[5];
|
|
2313
|
+
splitWords[7] = 'grayscale(0%)';
|
|
2314
|
+
splitWords[8] = 'invert(0%)';
|
|
2315
|
+
break;
|
|
2316
|
+
case 'invert':
|
|
2317
|
+
splitWords[8] = 'invert(100%)';
|
|
2318
|
+
values = this.adjustmentValue.split(' ');
|
|
2319
|
+
splitWords[0] = values[0];
|
|
2320
|
+
splitWords[1] = values[1];
|
|
2321
|
+
splitWords[2] = values[2];
|
|
2322
|
+
splitWords[3] = values[3];
|
|
2323
|
+
splitWords[4] = values[4];
|
|
2324
|
+
splitWords[5] = values[5];
|
|
2325
|
+
splitWords[6] = 'sepia(0%)';
|
|
2326
|
+
splitWords[7] = 'grayscale(0%)';
|
|
2327
|
+
break;
|
|
2328
|
+
case 'sharpen':
|
|
2329
|
+
values = this.adjustmentValue.split(' ');
|
|
2330
|
+
if (isPreview) {
|
|
2331
|
+
temp = this.lowerContext.filter;
|
|
2332
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
2333
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
2334
|
+
for (var i = 0; i < this.objColl.length; i++) {
|
|
2335
|
+
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
2336
|
+
this.refreshActiveObj();
|
|
2337
|
+
}
|
|
2338
|
+
splitWords[0] = values[0];
|
|
2339
|
+
splitWords[1] = values[1];
|
|
2340
|
+
splitWords[2] = values[2];
|
|
2341
|
+
splitWords[3] = values[3];
|
|
2342
|
+
splitWords[4] = values[4];
|
|
2343
|
+
splitWords[5] = values[5];
|
|
2344
|
+
splitWords[6] = 'sepia(0%)';
|
|
2345
|
+
splitWords[7] = 'grayscale(0%)';
|
|
2346
|
+
splitWords[8] = 'invert(0%)';
|
|
2347
|
+
}
|
|
2348
|
+
else {
|
|
2349
|
+
temp = this.lowerContext.filter;
|
|
2350
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
2351
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
2352
|
+
this.setSharpness(true);
|
|
2353
|
+
splitWords[0] = values[0];
|
|
2354
|
+
splitWords[1] = values[1];
|
|
2355
|
+
splitWords[2] = values[2];
|
|
2356
|
+
splitWords[3] = values[3];
|
|
2357
|
+
splitWords[4] = values[4];
|
|
2358
|
+
splitWords[5] = values[5];
|
|
2359
|
+
splitWords[6] = 'sepia(0%)';
|
|
2360
|
+
splitWords[7] = 'grayscale(0%)';
|
|
2361
|
+
splitWords[8] = 'invert(0%)';
|
|
2362
|
+
this.lowerContext.filter = this.initialAdjustmentValue = splitWords.join(' ');
|
|
2363
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
2364
|
+
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
2365
|
+
temp = this.lowerContext.filter;
|
|
2366
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
2367
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
2368
|
+
for (var i = 0; i < this.objColl.length; i++) {
|
|
2369
|
+
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
2370
|
+
this.refreshActiveObj();
|
|
2371
|
+
}
|
|
2372
|
+
this.lowerContext.filter = temp;
|
|
2373
|
+
}
|
|
2374
|
+
break;
|
|
2375
|
+
}
|
|
2376
|
+
if (type !== 'sharpen' && type !== 'blackandwhite') {
|
|
2377
|
+
if (isNullOrUndefined(isPreview)) {
|
|
2378
|
+
if (type === 'default') {
|
|
2379
|
+
splitWords = this.getDefaultFilter(splitWords);
|
|
2380
|
+
}
|
|
2381
|
+
this.lowerContext.filter = splitWords.join(' ');
|
|
2382
|
+
}
|
|
2383
|
+
splitWords = this.setTempFilterValue(brightness, isPreview, splitWords, type);
|
|
2384
|
+
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
2385
|
+
if (brightness !== 1) {
|
|
2386
|
+
splitWords[4] = 'opacity(' + opacityValue + ')';
|
|
2387
|
+
}
|
|
2388
|
+
else if (saturation !== 1) {
|
|
2389
|
+
splitWords[0] = 'brightness(' + brightnessValue + ')';
|
|
2390
|
+
}
|
|
2391
|
+
if (type === 'exposure' && brightness !== 1) {
|
|
2392
|
+
splitWords[0] = 'brightness(' + brightnessValue + ')';
|
|
2393
|
+
}
|
|
2394
|
+
splitWords = this.setTempFilterValue(brightness, isPreview, splitWords, type);
|
|
2395
|
+
if (isNullOrUndefined(isPreview)) {
|
|
2396
|
+
this.lowerContext.filter = this.initialAdjustmentValue = splitWords.join(' ');
|
|
2397
|
+
}
|
|
2398
|
+
var tempFilter_1 = this.lowerContext.filter;
|
|
2399
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
2400
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
2401
|
+
for (var i = 0; i < this.objColl.length; i++) {
|
|
2402
|
+
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
2403
|
+
this.refreshActiveObj();
|
|
2404
|
+
}
|
|
2405
|
+
this.lowerContext.filter = tempFilter_1;
|
|
2406
|
+
if (brightness === 1) {
|
|
2407
|
+
this.isBrightnessAdjusted = false;
|
|
2408
|
+
}
|
|
2409
|
+
else {
|
|
2410
|
+
this.isBrightnessAdjusted = true;
|
|
2411
|
+
}
|
|
2412
|
+
}
|
|
2413
|
+
var filter = splitWords.join(' ');
|
|
2414
|
+
return filter;
|
|
2415
|
+
};
|
|
2416
|
+
ImageEditor.prototype.updateBrightnessFilter = function () {
|
|
2417
|
+
var splitWords = this.lowerContext.filter.split(' ');
|
|
2418
|
+
if (this.isBrightnessAdjusted && splitWords.length > 0 && !isNullOrUndefined(splitWords[4])) {
|
|
2419
|
+
var opacityValue = parseFloat(splitWords[4].split('(')[1]);
|
|
2420
|
+
splitWords[4] = 'opacity(' + (opacityValue - 0.3) + ')';
|
|
2421
|
+
this.lowerContext.filter = splitWords.join(' ');
|
|
2422
|
+
}
|
|
2423
|
+
};
|
|
2424
|
+
ImageEditor.prototype.autoEnablePan = function () {
|
|
2425
|
+
if (this.factor > 0.95 && this.factor < 1.05) {
|
|
2426
|
+
this.dragCanvas = this.togglePan = false;
|
|
2427
|
+
this.callMainToolbar(false, true);
|
|
2428
|
+
this.pan(false);
|
|
2429
|
+
this.disablePan = false;
|
|
2430
|
+
}
|
|
2431
|
+
else if (!this.disablePan) {
|
|
2432
|
+
this.pan(true);
|
|
2433
|
+
}
|
|
2434
|
+
else if (this.disablePan) {
|
|
2435
|
+
this.pan(false);
|
|
2436
|
+
}
|
|
2437
|
+
};
|
|
2438
|
+
ImageEditor.prototype.setTempFilterValue = function (brightness, isPreview, splitWords, type) {
|
|
2439
|
+
if (isPreview && brightness !== 1) {
|
|
2440
|
+
var tempSplitWords = this.lowerContext.filter.split(' ');
|
|
2441
|
+
tempSplitWords[4] = splitWords[4];
|
|
2442
|
+
this.lowerContext.filter = tempSplitWords.join(' ');
|
|
2443
|
+
}
|
|
2444
|
+
else if (isPreview && type === 'default') {
|
|
2445
|
+
splitWords = this.getDefaultFilter(splitWords);
|
|
2446
|
+
}
|
|
2447
|
+
return splitWords;
|
|
2448
|
+
};
|
|
2449
|
+
ImageEditor.prototype.getDefaultFilter = function (splitWords) {
|
|
2450
|
+
var values = this.adjustmentValue.split(' ');
|
|
2451
|
+
splitWords[0] = values[0];
|
|
2452
|
+
splitWords[1] = values[1];
|
|
2453
|
+
splitWords[2] = values[2];
|
|
2454
|
+
splitWords[3] = values[3];
|
|
2455
|
+
splitWords[4] = values[4];
|
|
2456
|
+
splitWords[5] = values[5];
|
|
2457
|
+
splitWords[6] = 'sepia(0%)';
|
|
2458
|
+
splitWords[7] = 'grayscale(0%)';
|
|
2459
|
+
splitWords[8] = 'invert(0%)';
|
|
2460
|
+
return splitWords;
|
|
2461
|
+
};
|
|
2462
|
+
ImageEditor.prototype.setAdjustment = function (type) {
|
|
2463
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
2464
|
+
var splitWords = this.lowerContext.filter.split(' ');
|
|
2465
|
+
var value;
|
|
2466
|
+
var valueArr;
|
|
2467
|
+
switch (type) {
|
|
2468
|
+
case 'brightness':
|
|
2469
|
+
valueArr = splitWords[0].split('(');
|
|
2470
|
+
value = parseFloat(valueArr[1].split(')')[0]);
|
|
2471
|
+
this.adjustmentLevel.brightness = this.setFilterValue(value);
|
|
2472
|
+
break;
|
|
2473
|
+
case 'contrast':
|
|
2474
|
+
valueArr = splitWords[1].split('(');
|
|
2475
|
+
value = parseFloat(valueArr[1].split(')')[0]);
|
|
2476
|
+
value /= 100;
|
|
2477
|
+
this.adjustmentLevel.contrast = this.setFilterValue(value);
|
|
2478
|
+
break;
|
|
2479
|
+
case 'hue':
|
|
2480
|
+
valueArr = splitWords[2].split('(');
|
|
2481
|
+
value = parseFloat(valueArr[1].split(')')[0]);
|
|
2482
|
+
value /= 3;
|
|
2483
|
+
this.adjustmentLevel.hue = value;
|
|
2484
|
+
break;
|
|
2485
|
+
case 'saturation':
|
|
2486
|
+
valueArr = splitWords[3].split('(');
|
|
2487
|
+
value = parseFloat(valueArr[1].split(')')[0]);
|
|
2488
|
+
value /= 100;
|
|
2489
|
+
this.adjustmentLevel.saturation = this.setSaturationFilterValue(value);
|
|
2490
|
+
break;
|
|
2491
|
+
case 'opacity':
|
|
2492
|
+
valueArr = splitWords[4].split('(');
|
|
2493
|
+
value = parseFloat(valueArr[1].split(')')[0]);
|
|
2494
|
+
if (value === 0.45) {
|
|
2495
|
+
value = 40;
|
|
2496
|
+
}
|
|
2497
|
+
else if (value === 0.40) {
|
|
2498
|
+
value = 30;
|
|
2499
|
+
}
|
|
2500
|
+
else if (value === 0.35) {
|
|
2501
|
+
value = 20;
|
|
2502
|
+
}
|
|
2503
|
+
else if (value === 0.30) {
|
|
2504
|
+
value = 10;
|
|
2505
|
+
}
|
|
2506
|
+
else if (value === 0.25) {
|
|
2507
|
+
value = 0;
|
|
2508
|
+
}
|
|
2509
|
+
else {
|
|
2510
|
+
value *= 100;
|
|
2511
|
+
}
|
|
2512
|
+
this.adjustmentLevel.opacity = value;
|
|
2513
|
+
break;
|
|
2514
|
+
case 'blur':
|
|
2515
|
+
valueArr = splitWords[5].split('(');
|
|
2516
|
+
value = parseFloat(valueArr[1].split(')')[0]);
|
|
2517
|
+
value *= 20;
|
|
2518
|
+
this.adjustmentLevel.blur = value;
|
|
2519
|
+
break;
|
|
2520
|
+
case 'exposure':
|
|
2521
|
+
valueArr = splitWords[0].split('(');
|
|
2522
|
+
value = parseFloat(valueArr[1].split(')')[0]);
|
|
2523
|
+
this.adjustmentLevel.exposure = this.setFilterValue(value);
|
|
2524
|
+
break;
|
|
2525
|
+
}
|
|
2526
|
+
var temp = this.lowerContext.filter;
|
|
2527
|
+
this.updateBrightnessFilter();
|
|
2528
|
+
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
2529
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
2530
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
2531
|
+
for (var j = 0; j < this.objColl.length; j++) {
|
|
2532
|
+
this.apply(this.objColl[j].shape, this.objColl[j]);
|
|
2533
|
+
this.refreshActiveObj();
|
|
2534
|
+
}
|
|
2535
|
+
this.lowerContext.filter = temp;
|
|
2536
|
+
};
|
|
2537
|
+
ImageEditor.prototype.renderSlider = function (type) {
|
|
2538
|
+
var _this = this;
|
|
2539
|
+
var canvasWrapper = document.querySelector('#' + this.element.id + '_contextualToolbarArea');
|
|
2540
|
+
var hdrWrapper = document.querySelector('#' + this.element.id + '_headWrapper');
|
|
2541
|
+
var labelWrapper = document.querySelector('#' + this.element.id + '_labelWrapper');
|
|
2542
|
+
if (!hdrWrapper && !isNullOrUndefined(canvasWrapper)) {
|
|
2543
|
+
hdrWrapper = canvasWrapper.appendChild(this.createElement('div', {
|
|
2544
|
+
id: this.element.id + '_headWrapper',
|
|
2545
|
+
styles: 'position: relative'
|
|
2546
|
+
}));
|
|
2547
|
+
labelWrapper = hdrWrapper.appendChild(this.createElement('label', {
|
|
2548
|
+
id: this.element.id + '_labelWrapper',
|
|
2549
|
+
styles: Browser.isDevice ? 'position: absolute; top: 25%; left: calc(50% - 150px); font-size: 15px; text-transform: capitalize; font-weight: 400;'
|
|
2550
|
+
: 'position: absolute; top: 25%; left: calc(50% - 226px); font-size: 15px; text-transform: capitalize; font-weight: 400;'
|
|
2551
|
+
}));
|
|
2552
|
+
}
|
|
2553
|
+
else {
|
|
2554
|
+
hdrWrapper.style.display = 'block';
|
|
2555
|
+
}
|
|
2556
|
+
labelWrapper.textContent = this.l10n.getConstant(this.toPascalCase(type));
|
|
2557
|
+
var sliderWrapper = hdrWrapper.appendChild(this.createElement('div', {
|
|
2558
|
+
id: this.element.id + '_sliderWrapper',
|
|
2559
|
+
styles: 'position: absolute'
|
|
2560
|
+
}));
|
|
2561
|
+
var value = this.getCurrAdjustmentValue(type);
|
|
2562
|
+
var min;
|
|
2563
|
+
var max;
|
|
2564
|
+
var slider;
|
|
2565
|
+
if (type === 'brightness' || type === 'contrast' || type === 'saturation' || type === 'exposure') {
|
|
2566
|
+
if (this.finetuneSettings) {
|
|
2567
|
+
if (type === 'brightness' && this.finetuneSettings.brightness) {
|
|
2568
|
+
min = this.finetuneSettings.brightness.min;
|
|
2569
|
+
max = this.finetuneSettings.brightness.max;
|
|
2570
|
+
}
|
|
2571
|
+
else if (type === 'contrast' && this.finetuneSettings.contrast) {
|
|
2572
|
+
min = this.finetuneSettings.contrast.min;
|
|
2573
|
+
max = this.finetuneSettings.contrast.max;
|
|
2574
|
+
}
|
|
2575
|
+
else if (type === 'saturation' && this.finetuneSettings.saturation) {
|
|
2576
|
+
min = this.finetuneSettings.saturation.min;
|
|
2577
|
+
max = this.finetuneSettings.saturation.max;
|
|
2578
|
+
}
|
|
2579
|
+
else if (type === 'exposure' && this.finetuneSettings.exposure) {
|
|
2580
|
+
min = this.finetuneSettings.exposure.min;
|
|
2581
|
+
max = this.finetuneSettings.exposure.max;
|
|
2582
|
+
}
|
|
2583
|
+
else {
|
|
2584
|
+
min = -100;
|
|
2585
|
+
max = 100;
|
|
2586
|
+
}
|
|
2587
|
+
}
|
|
2588
|
+
else {
|
|
2589
|
+
min = -100;
|
|
2590
|
+
max = 100;
|
|
2591
|
+
}
|
|
2592
|
+
slider = new Slider({
|
|
2593
|
+
value: value,
|
|
2594
|
+
tooltip: { isVisible: true, placement: 'Before', showOn: 'Always' },
|
|
2595
|
+
type: 'MinRange',
|
|
2596
|
+
min: min,
|
|
2597
|
+
max: max,
|
|
2598
|
+
step: 10,
|
|
2599
|
+
width: Browser.isDevice ? '200px' : '300px',
|
|
2600
|
+
cssClass: 'e-slider',
|
|
2601
|
+
change: function (args) {
|
|
2602
|
+
_this.setCurrAdjustmentValue(type, args.value);
|
|
2603
|
+
}
|
|
2604
|
+
});
|
|
2605
|
+
}
|
|
2606
|
+
else if (type === 'hue' || type === 'blur' || type === 'opacity') {
|
|
2607
|
+
if (this.finetuneSettings) {
|
|
2608
|
+
if (type === 'hue' && this.finetuneSettings.hue) {
|
|
2609
|
+
min = this.finetuneSettings.hue.min;
|
|
2610
|
+
max = this.finetuneSettings.hue.max;
|
|
2611
|
+
}
|
|
2612
|
+
else if (type === 'blur' && this.finetuneSettings.blur) {
|
|
2613
|
+
min = this.finetuneSettings.blur.min;
|
|
2614
|
+
max = this.finetuneSettings.blur.max;
|
|
2615
|
+
}
|
|
2616
|
+
else if (type === 'opacity' && this.finetuneSettings.opacity) {
|
|
2617
|
+
min = this.finetuneSettings.opacity.min;
|
|
2618
|
+
max = this.finetuneSettings.opacity.max;
|
|
2619
|
+
}
|
|
2620
|
+
else {
|
|
2621
|
+
min = 0;
|
|
2622
|
+
max = 100;
|
|
2623
|
+
}
|
|
2624
|
+
}
|
|
2625
|
+
else {
|
|
2626
|
+
min = 0;
|
|
2627
|
+
max = 100;
|
|
2628
|
+
}
|
|
2629
|
+
slider = new Slider({
|
|
2630
|
+
value: value,
|
|
2631
|
+
tooltip: { isVisible: true, placement: 'Before', showOn: 'Always' },
|
|
2632
|
+
type: 'MinRange',
|
|
2633
|
+
min: min,
|
|
2634
|
+
max: max,
|
|
2635
|
+
step: 10,
|
|
2636
|
+
width: Browser.isDevice ? '200px' : '300px',
|
|
2637
|
+
cssClass: 'e-slider',
|
|
2638
|
+
change: function (args) {
|
|
2639
|
+
_this.setCurrAdjustmentValue(type, args.value);
|
|
2640
|
+
}
|
|
2641
|
+
});
|
|
2642
|
+
}
|
|
2643
|
+
slider.appendTo('#' + this.element.id + '_sliderWrapper');
|
|
2644
|
+
sliderWrapper.style.left = (parseFloat(canvasWrapper.style.width) - parseFloat(slider.width)) / 2 + 'px';
|
|
2645
|
+
};
|
|
2646
|
+
ImageEditor.prototype.getCurrAdjustmentValue = function (type) {
|
|
2647
|
+
var value;
|
|
2648
|
+
switch (type) {
|
|
2649
|
+
case 'brightness':
|
|
2650
|
+
value = this.adjustmentLevel.brightness;
|
|
2651
|
+
break;
|
|
2652
|
+
case 'contrast':
|
|
2653
|
+
value = this.adjustmentLevel.contrast;
|
|
2654
|
+
break;
|
|
2655
|
+
case 'hue':
|
|
2656
|
+
value = this.adjustmentLevel.hue;
|
|
2657
|
+
break;
|
|
2658
|
+
case 'saturation':
|
|
2659
|
+
value = this.adjustmentLevel.saturation;
|
|
2660
|
+
break;
|
|
2661
|
+
case 'opacity':
|
|
2662
|
+
value = this.adjustmentLevel.opacity;
|
|
2663
|
+
break;
|
|
2664
|
+
case 'blur':
|
|
2665
|
+
value = this.adjustmentLevel.blur;
|
|
2666
|
+
break;
|
|
2667
|
+
case 'exposure':
|
|
2668
|
+
value = this.adjustmentLevel.exposure;
|
|
2669
|
+
break;
|
|
2670
|
+
}
|
|
2671
|
+
return value;
|
|
2672
|
+
};
|
|
2673
|
+
ImageEditor.prototype.setCurrAdjustmentValue = function (type, value) {
|
|
2674
|
+
var fineTuneValueChanging = { finetune: this.toPascalCase(type), value: value };
|
|
2675
|
+
this.trigger('fineTuneValueChanging', fineTuneValueChanging);
|
|
2676
|
+
switch (type) {
|
|
2677
|
+
case 'brightness':
|
|
2678
|
+
this.setBrightness(value);
|
|
2679
|
+
break;
|
|
2680
|
+
case 'contrast':
|
|
2681
|
+
this.setContrast(value);
|
|
2682
|
+
break;
|
|
2683
|
+
case 'hue':
|
|
2684
|
+
this.setHue(value);
|
|
2685
|
+
break;
|
|
2686
|
+
case 'saturation':
|
|
2687
|
+
this.setSaturation(value);
|
|
2688
|
+
break;
|
|
2689
|
+
case 'opacity':
|
|
2690
|
+
this.setOpacity(value);
|
|
2691
|
+
break;
|
|
2692
|
+
case 'blur':
|
|
2693
|
+
this.setBlur(value);
|
|
2694
|
+
break;
|
|
2695
|
+
case 'exposure':
|
|
2696
|
+
this.setExposure(value);
|
|
2697
|
+
break;
|
|
2698
|
+
}
|
|
2699
|
+
};
|
|
2700
|
+
ImageEditor.prototype.cancelPan = function () {
|
|
2701
|
+
this.applyActObj();
|
|
2702
|
+
var panBtn = this.element.querySelector('.e-img-pan .e-btn');
|
|
2703
|
+
panBtn.classList.remove('e-selected-btn');
|
|
2704
|
+
this.pan(false);
|
|
2705
|
+
};
|
|
2706
|
+
ImageEditor.prototype.callMainToolbar = function (isApplyBtn, isZooming) {
|
|
2707
|
+
this.refreshToolbar('main', isApplyBtn, false, isZooming);
|
|
2708
|
+
};
|
|
2709
|
+
ImageEditor.prototype.cancelItems = function () {
|
|
2710
|
+
var ratio = this.calcRatio();
|
|
2711
|
+
var isCropSelection = false;
|
|
2712
|
+
var splitWords;
|
|
2713
|
+
if (this.activeObj.shape !== undefined) {
|
|
2714
|
+
splitWords = this.activeObj.shape.split('-');
|
|
2715
|
+
}
|
|
2716
|
+
if (splitWords === undefined && this.currObjType.isCustomCrop) {
|
|
2717
|
+
isCropSelection = true;
|
|
2718
|
+
}
|
|
2719
|
+
else if (splitWords !== undefined && splitWords[0] === 'crop') {
|
|
2720
|
+
isCropSelection = true;
|
|
2721
|
+
}
|
|
2722
|
+
if (this.togglePen) {
|
|
2723
|
+
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
2724
|
+
this.togglePen = false;
|
|
2725
|
+
this.upperCanvas.style.cursor = 'default';
|
|
2726
|
+
this.penDrawColl = [];
|
|
2727
|
+
this.imageEditorPointsColl = [];
|
|
2728
|
+
}
|
|
2729
|
+
else if (this.activeObj.shape === 'text') {
|
|
2730
|
+
this.activeObj.strokeSettings = this.tempStrokeSettings;
|
|
2731
|
+
this.activeObj.textSettings = this.tempTextSettings;
|
|
2732
|
+
if (this.activeObj.keyHistory === 'Enter Text' && this.activeObj.activePoint.startX === this.textStartPoints.x
|
|
2733
|
+
&& this.activeObj.activePoint.startY === this.textStartPoints.y) {
|
|
2734
|
+
this.refreshActiveObj();
|
|
2735
|
+
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
2736
|
+
this.drawShapeText();
|
|
2737
|
+
}
|
|
2738
|
+
else {
|
|
2739
|
+
this.redrawText(ratio);
|
|
2740
|
+
this.redrawShape(this.activeObj);
|
|
2741
|
+
if (!isCropSelection && this.activeObj.topLeftCircle !== undefined) {
|
|
2742
|
+
this.applyActObj();
|
|
2743
|
+
}
|
|
2744
|
+
this.clearSelection();
|
|
2745
|
+
}
|
|
2746
|
+
this.tempTextSettings = { text: 'Enter Text', fontFamily: 'Arial', fontSize: null, bold: false, italic: false, underline: false };
|
|
2747
|
+
}
|
|
2748
|
+
else if (this.activeObj.shape === 'rectangle' || this.activeObj.shape === 'ellipse' || this.activeObj.shape === 'line') {
|
|
2749
|
+
this.activeObj.strokeSettings = this.tempStrokeSettings;
|
|
2750
|
+
this.redrawShape(this.activeObj);
|
|
2751
|
+
this.applyActObj();
|
|
2752
|
+
}
|
|
2753
|
+
else {
|
|
2754
|
+
this.refreshActiveObj();
|
|
2755
|
+
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
2756
|
+
}
|
|
2757
|
+
this.upperCanvas.style.cursor = 'default';
|
|
2758
|
+
this.currObjType.isCustomCrop = false;
|
|
2759
|
+
this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null };
|
|
2760
|
+
this.callMainToolbar();
|
|
2761
|
+
};
|
|
2762
|
+
ImageEditor.prototype.gradient = function (a, b) {
|
|
2763
|
+
return (b.y - a.y) / (b.x - a.x);
|
|
2764
|
+
};
|
|
2765
|
+
ImageEditor.prototype.applyPenDraw = function () {
|
|
2766
|
+
if (this.togglePen && this.factor === 1 && !this.currObjType.isZoomed) {
|
|
2767
|
+
this.apply();
|
|
2768
|
+
this.penDrawColl = [];
|
|
2769
|
+
this.imageEditorPointsColl = [];
|
|
2770
|
+
}
|
|
2771
|
+
else {
|
|
2772
|
+
var tempCanvas = this.lowerCanvas.appendChild(this.createElement('canvas', {
|
|
2773
|
+
id: this.element.id + '_tempCanvas', attrs: { name: 'canvasImage' }
|
|
2774
|
+
}));
|
|
2775
|
+
var tempContext = tempCanvas.getContext('2d');
|
|
2776
|
+
tempCanvas.width = this.lowerCanvas.width;
|
|
2777
|
+
tempCanvas.height = this.lowerCanvas.height;
|
|
2778
|
+
var temp = this.lowerContext.filter;
|
|
2779
|
+
this.updateBrightnessFilter();
|
|
2780
|
+
tempContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
2781
|
+
this.lowerContext.filter = temp;
|
|
2782
|
+
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
2783
|
+
for (var i = 0; i < this.penDrawColl.length; i++) {
|
|
2784
|
+
tempContext.lineWidth = 2 * this.penDrawColl[i].strokeWidth;
|
|
2785
|
+
tempContext.strokeStyle = this.penDrawColl[i].strokeColor;
|
|
2786
|
+
var nexP = void 0;
|
|
2787
|
+
var preP = void 0;
|
|
2788
|
+
var f = 0.3;
|
|
2789
|
+
var t = 1;
|
|
2790
|
+
tempContext.beginPath();
|
|
2791
|
+
tempContext.moveTo(this.penDrawColl[i].points[0].x, this.penDrawColl[i].points[0].y);
|
|
2792
|
+
var m = 0;
|
|
2793
|
+
var dx1 = 0;
|
|
2794
|
+
var dx2 = 0;
|
|
2795
|
+
var dy1 = 0;
|
|
2796
|
+
var dy2 = 0;
|
|
2797
|
+
preP = this.penDrawColl[i].points[0];
|
|
2798
|
+
for (var j = 1; j < this.penDrawColl[i].points.length; j++) {
|
|
2799
|
+
var curP = this.penDrawColl[i].points[j];
|
|
2800
|
+
nexP = this.penDrawColl[i].points[j + 1];
|
|
2801
|
+
if (nexP) {
|
|
2802
|
+
m = this.gradient(preP, nexP);
|
|
2803
|
+
dx2 = (nexP.x - curP.x) * -f;
|
|
2804
|
+
dy2 = dx2 * m * t;
|
|
2805
|
+
}
|
|
2806
|
+
else {
|
|
2807
|
+
dx2 = 0;
|
|
2808
|
+
dy2 = 0;
|
|
2809
|
+
}
|
|
2810
|
+
tempContext.bezierCurveTo(preP.x - dx1, preP.y - dy1, curP.x + dx2, curP.y + dy2, curP.x, curP.y);
|
|
2811
|
+
dx1 = dx2;
|
|
2812
|
+
dy1 = dy2;
|
|
2813
|
+
preP = curP;
|
|
2814
|
+
if (this.penDrawColl[i].points.length > 2) {
|
|
2815
|
+
this.penDrawColl[i].points.shift();
|
|
2816
|
+
}
|
|
2817
|
+
tempContext.stroke();
|
|
2818
|
+
}
|
|
2819
|
+
}
|
|
2820
|
+
this.penDrawColl = [];
|
|
2821
|
+
this.imageEditorPointsColl = [];
|
|
2822
|
+
this.togglePen = false;
|
|
2823
|
+
var imgData = tempContext.getImageData(0, 0, tempCanvas.width, tempCanvas.height);
|
|
2824
|
+
var tempObj = void 0;
|
|
2825
|
+
for (var index = 0; index < this.imgDataColl.length; index++) {
|
|
1835
2826
|
if (this.imgDataColl[index].operation !== 'freehanddraw') {
|
|
1836
2827
|
tempObj = this.imgDataColl[index];
|
|
1837
2828
|
break;
|
|
@@ -1845,24 +2836,37 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1845
2836
|
this.inMemoryCanvas.height = imgData.height;
|
|
1846
2837
|
this.inMemoryContext.putImageData(imgData, 0, 0);
|
|
1847
2838
|
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
1848
|
-
this.
|
|
1849
|
-
for (var j = 0; j < this.objColl.length; j++) {
|
|
1850
|
-
this.apply(this.objColl[j].shape, this.objColl[j]);
|
|
1851
|
-
this.refreshActiveObj();
|
|
1852
|
-
}
|
|
2839
|
+
this.redrawImgWithObj();
|
|
1853
2840
|
this.currObjType.isZoomed = false;
|
|
1854
2841
|
}
|
|
1855
2842
|
};
|
|
1856
|
-
ImageEditor.prototype.
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
2843
|
+
ImageEditor.prototype.redrawImgWithObj = function () {
|
|
2844
|
+
this.lowerContext.filter = this.canvasFilter;
|
|
2845
|
+
var temp = this.lowerContext.filter;
|
|
2846
|
+
this.updateBrightnessFilter();
|
|
2847
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
2848
|
+
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
2849
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
2850
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
2851
|
+
for (var j = 0; j < this.objColl.length; j++) {
|
|
2852
|
+
this.apply(this.objColl[j].shape, this.objColl[j]);
|
|
2853
|
+
this.refreshActiveObj();
|
|
1860
2854
|
}
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
2855
|
+
this.lowerContext.filter = temp;
|
|
2856
|
+
};
|
|
2857
|
+
ImageEditor.prototype.refreshToolbar = function (type, isApplyBtn, isCropping, isZooming, cType) {
|
|
2858
|
+
var args = { toolbarType: type };
|
|
2859
|
+
if (type !== 'filter' && type !== 'color') {
|
|
2860
|
+
if (document.getElementById(this.element.id + '_toolbar') && this.defToolbarItems.length > 0) {
|
|
2861
|
+
getComponent(document.getElementById(this.element.id + '_toolbar'), 'toolbar').destroy();
|
|
2862
|
+
}
|
|
2863
|
+
if (document.getElementById(this.element.id + '_bottomToolbar') && this.defToolbarItems.length > 0) {
|
|
2864
|
+
if (document.getElementById(this.element.id + '_bottomToolbar').className.indexOf('e-control') > -1) {
|
|
2865
|
+
getComponent(document.getElementById(this.element.id + '_bottomToolbar'), 'toolbar').destroy();
|
|
2866
|
+
}
|
|
1864
2867
|
}
|
|
1865
2868
|
}
|
|
2869
|
+
this.refreshSlider();
|
|
1866
2870
|
switch (type) {
|
|
1867
2871
|
case 'main':
|
|
1868
2872
|
if (Browser.isDevice) {
|
|
@@ -1912,7 +2916,104 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1912
2916
|
case 'pan':
|
|
1913
2917
|
this.initZoomToolbarItem();
|
|
1914
2918
|
break;
|
|
2919
|
+
case 'adjustment':
|
|
2920
|
+
if (Browser.isDevice) {
|
|
2921
|
+
this.initToolbarItem(false, true, true);
|
|
2922
|
+
}
|
|
2923
|
+
this.initAdjustmentToolbarItem();
|
|
2924
|
+
break;
|
|
2925
|
+
case 'filter':
|
|
2926
|
+
this.updateContextualToolbar(type);
|
|
2927
|
+
break;
|
|
2928
|
+
case 'color':
|
|
2929
|
+
this.updateContextualToolbar(type, cType);
|
|
2930
|
+
break;
|
|
2931
|
+
}
|
|
2932
|
+
};
|
|
2933
|
+
ImageEditor.prototype.getAdjustmentToolbarItem = function () {
|
|
2934
|
+
var toolbarItems = [];
|
|
2935
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Brightness') > -1)) {
|
|
2936
|
+
toolbarItems.push({ id: this.element.id + '_brightness', prefixIcon: 'e-icons e-brightness', cssClass: 'top-icon e-brightness',
|
|
2937
|
+
tooltipText: this.l10n.getConstant('Brightness'), align: 'Center' });
|
|
2938
|
+
}
|
|
2939
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Contrast') > -1)) {
|
|
2940
|
+
toolbarItems.push({ id: this.element.id + '_contrast', prefixIcon: 'e-icons e-contrast', cssClass: 'top-icon e-contrast',
|
|
2941
|
+
tooltipText: this.l10n.getConstant('Contrast'), align: 'Center' });
|
|
2942
|
+
}
|
|
2943
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Hue') > -1)) {
|
|
2944
|
+
toolbarItems.push({ id: this.element.id + '_hue', prefixIcon: 'e-icons e-fade', cssClass: 'top-icon e-fade',
|
|
2945
|
+
tooltipText: this.l10n.getConstant('Hue'), align: 'Center' });
|
|
2946
|
+
}
|
|
2947
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Saturation') > -1)) {
|
|
2948
|
+
toolbarItems.push({ id: this.element.id + '_saturation', prefixIcon: 'e-icons e-saturation', cssClass: 'top-icon e-saturation',
|
|
2949
|
+
tooltipText: this.l10n.getConstant('Saturation'), align: 'Center' });
|
|
2950
|
+
}
|
|
2951
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Exposure') > -1)) {
|
|
2952
|
+
toolbarItems.push({ id: this.element.id + '_exposure', prefixIcon: 'e-icons e-grain', cssClass: 'top-icon e-grain',
|
|
2953
|
+
tooltipText: this.l10n.getConstant('Exposure'), align: 'Center' });
|
|
1915
2954
|
}
|
|
2955
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Opacity') > -1)) {
|
|
2956
|
+
toolbarItems.push({ id: this.element.id + '_opacity', prefixIcon: 'e-icons e-opacity', cssClass: 'top-icon e-opacity',
|
|
2957
|
+
tooltipText: this.l10n.getConstant('Opacity'), align: 'Center' });
|
|
2958
|
+
}
|
|
2959
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Blur') > -1)) {
|
|
2960
|
+
toolbarItems.push({ id: this.element.id + '_blur', prefixIcon: 'e-icons e-tint', cssClass: 'top-icon e-tint',
|
|
2961
|
+
tooltipText: this.l10n.getConstant('Blur'), align: 'Center' });
|
|
2962
|
+
}
|
|
2963
|
+
var tempToolbarItems = this.processToolbar('center');
|
|
2964
|
+
for (var i = 0, len = tempToolbarItems.length; i < len; i++) {
|
|
2965
|
+
toolbarItems.push(tempToolbarItems[i]);
|
|
2966
|
+
}
|
|
2967
|
+
if (!Browser.isDevice) {
|
|
2968
|
+
toolbarItems.push({ id: this.element.id + '_ok', prefixIcon: 'e-icons e-check', cssClass: 'top-icon e-tick',
|
|
2969
|
+
tooltipText: this.l10n.getConstant('OK'), align: 'Right' });
|
|
2970
|
+
toolbarItems.push({ id: this.element.id + '_cancel', prefixIcon: 'e-icons e-close', cssClass: 'top-icon e-save',
|
|
2971
|
+
tooltipText: this.l10n.getConstant('Cancel'), align: 'Right' });
|
|
2972
|
+
}
|
|
2973
|
+
return toolbarItems;
|
|
2974
|
+
};
|
|
2975
|
+
ImageEditor.prototype.getFilterToolbarItem = function () {
|
|
2976
|
+
var toolbarItems = [];
|
|
2977
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Default') > -1)) {
|
|
2978
|
+
toolbarItems.push({ id: this.element.id + '_default', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
|
|
2979
|
+
tooltipText: this.l10n.getConstant('Default'), align: 'Center',
|
|
2980
|
+
template: '<div class="filterwrapper" style="box-sizing: content-box;"><canvas id=' + this.element.id + '_defaultCanvas' + '></canvas><div style="text-align:center;"><span>' + this.l10n.getConstant('Default') + '</span></div></div>' });
|
|
2981
|
+
}
|
|
2982
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Chrome') > -1)) {
|
|
2983
|
+
toolbarItems.push({ id: this.element.id + '_chrome', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
|
|
2984
|
+
tooltipText: this.l10n.getConstant('Chrome'), align: 'Center',
|
|
2985
|
+
template: '<div class="filterwrapper" style="box-sizing: content-box;"><canvas id=' + this.element.id + '_chromeCanvas' + '></canvas><div style="text-align:center;"><span>' + this.l10n.getConstant('Chrome') + '</span></div></div>' });
|
|
2986
|
+
}
|
|
2987
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Cold') > -1)) {
|
|
2988
|
+
toolbarItems.push({ id: this.element.id + '_cold', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
|
|
2989
|
+
tooltipText: this.l10n.getConstant('Cold'), align: 'Center',
|
|
2990
|
+
template: '<div class="filterwrapper" style="box-sizing: content-box;"><canvas id=' + this.element.id + '_coldCanvas' + '></canvas><div style="text-align:center;"><span>' + this.l10n.getConstant('Cold') + '</span></div></div>' });
|
|
2991
|
+
}
|
|
2992
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Warm') > -1)) {
|
|
2993
|
+
toolbarItems.push({ id: this.element.id + '_warm', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
|
|
2994
|
+
tooltipText: this.l10n.getConstant('Warm'), align: 'Center',
|
|
2995
|
+
template: '<div class="filterwrapper" style="box-sizing: content-box;"><canvas id=' + this.element.id + '_warmCanvas' + '></canvas><div style="text-align:center;"><span>' + this.l10n.getConstant('Warm') + '</span></div></div>' });
|
|
2996
|
+
}
|
|
2997
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Grayscale') > -1)) {
|
|
2998
|
+
toolbarItems.push({ id: this.element.id + '_grayscale', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
|
|
2999
|
+
tooltipText: this.l10n.getConstant('Grayscale'), align: 'Center',
|
|
3000
|
+
template: '<div class="filterwrapper" style="box-sizing: content-box;"><canvas id=' + this.element.id + '_grayscaleCanvas' + '></canvas><div style="text-align:center;"><span>' + this.l10n.getConstant('Grayscale') + '</span></div></div>' });
|
|
3001
|
+
}
|
|
3002
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Sepia') > -1)) {
|
|
3003
|
+
toolbarItems.push({ id: this.element.id + '_sepia', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
|
|
3004
|
+
tooltipText: this.l10n.getConstant('Sepia'), align: 'Center',
|
|
3005
|
+
template: '<div class="filterwrapper" style="box-sizing: content-box;"><canvas id=' + this.element.id + '_sepiaCanvas' + '></canvas><div style="text-align:center;"><span>' + this.l10n.getConstant('Sepia') + '</span></div></div>' });
|
|
3006
|
+
}
|
|
3007
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Invert') > -1)) {
|
|
3008
|
+
toolbarItems.push({ id: this.element.id + '_invert', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
|
|
3009
|
+
tooltipText: this.l10n.getConstant('Invert'), align: 'Center',
|
|
3010
|
+
template: '<div class="filterwrapper" style="box-sizing: content-box;"><canvas id=' + this.element.id + '_invertCanvas' + '></canvas><div style="text-align:center;"><span>' + this.l10n.getConstant('Invert') + '</span></div></div>' });
|
|
3011
|
+
}
|
|
3012
|
+
var tempToolbarItems = this.processToolbar('center');
|
|
3013
|
+
for (var i = 0, len = tempToolbarItems.length; i < len; i++) {
|
|
3014
|
+
toolbarItems.push(tempToolbarItems[i]);
|
|
3015
|
+
}
|
|
3016
|
+
return toolbarItems;
|
|
1916
3017
|
};
|
|
1917
3018
|
ImageEditor.prototype.getPenToolbarItem = function (items) {
|
|
1918
3019
|
var toolbarItems = [];
|
|
@@ -2033,7 +3134,12 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2033
3134
|
if (items.indexOf('strokeWidth') > -1) {
|
|
2034
3135
|
var strokeWidthBtn = document.getElementById(this.element.id + '_penStrokeWidth');
|
|
2035
3136
|
var spanElem_3 = document.createElement('span');
|
|
2036
|
-
|
|
3137
|
+
if (isNullOrUndefined(this.penStrokeWidth)) {
|
|
3138
|
+
spanElem_3.innerHTML = this.l10n.getConstant('Small');
|
|
3139
|
+
}
|
|
3140
|
+
else {
|
|
3141
|
+
spanElem_3.innerHTML = this.getPenStroke(this.penStrokeWidth, this.calcRatio());
|
|
3142
|
+
}
|
|
2037
3143
|
spanElem_3.className = 'e-pen-stroke-width';
|
|
2038
3144
|
strokeWidthBtn.appendChild(spanElem_3);
|
|
2039
3145
|
var drpDownBtn_2 = new DropDownButton({ items: strokeWidthItems,
|
|
@@ -2051,15 +3157,15 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2051
3157
|
if (Browser.isDevice) {
|
|
2052
3158
|
if (!isNullOrUndefined(document.getElementById(_this.element.id + '_bottomToolbar'))) {
|
|
2053
3159
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
2054
|
-
var
|
|
2055
|
-
|
|
3160
|
+
var toolbar_8 = getComponent(_this.element.id + '_bottomToolbar', 'toolbar');
|
|
3161
|
+
toolbar_8.refreshOverflow();
|
|
2056
3162
|
}
|
|
2057
3163
|
}
|
|
2058
3164
|
else {
|
|
2059
3165
|
if (!isNullOrUndefined(document.getElementById(_this.element.id + '_toolbar'))) {
|
|
2060
3166
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
2061
|
-
var
|
|
2062
|
-
|
|
3167
|
+
var toolbar_9 = getComponent(_this.element.id + '_toolbar', 'toolbar');
|
|
3168
|
+
toolbar_9.refreshOverflow();
|
|
2063
3169
|
}
|
|
2064
3170
|
}
|
|
2065
3171
|
}
|
|
@@ -2087,6 +3193,159 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2087
3193
|
break;
|
|
2088
3194
|
}
|
|
2089
3195
|
};
|
|
3196
|
+
ImageEditor.prototype.getPenStroke = function (value, ratio) {
|
|
3197
|
+
var textContent = '';
|
|
3198
|
+
if (Math.round(value / 0.4) === Math.round(ratio.width + ratio.height)) {
|
|
3199
|
+
textContent = this.l10n.getConstant('XSmall');
|
|
3200
|
+
}
|
|
3201
|
+
else if (Math.round(value / 0.8) === Math.round(ratio.width + ratio.height)) {
|
|
3202
|
+
textContent = this.l10n.getConstant('Small');
|
|
3203
|
+
}
|
|
3204
|
+
else if (Math.round(value / 1.2) === Math.round(ratio.width + ratio.height)) {
|
|
3205
|
+
textContent = this.l10n.getConstant('Medium');
|
|
3206
|
+
}
|
|
3207
|
+
else if (Math.round(value / 1.6) === Math.round(ratio.width + ratio.height)) {
|
|
3208
|
+
textContent = this.l10n.getConstant('Large');
|
|
3209
|
+
}
|
|
3210
|
+
else if (Math.round(value / 2) === Math.round(ratio.width + ratio.height)) {
|
|
3211
|
+
textContent = this.l10n.getConstant('XLarge');
|
|
3212
|
+
}
|
|
3213
|
+
return textContent;
|
|
3214
|
+
};
|
|
3215
|
+
ImageEditor.prototype.initAdjustmentToolbarItem = function () {
|
|
3216
|
+
var _this = this;
|
|
3217
|
+
var leftItem = this.getLeftToolbarItem();
|
|
3218
|
+
var rightItem = this.getRightToolbarItem();
|
|
3219
|
+
var mainItem = this.getAdjustmentToolbarItem();
|
|
3220
|
+
var zoomItem = this.getZoomToolbarItem();
|
|
3221
|
+
if (Browser.isDevice) {
|
|
3222
|
+
this.defToolbarItems = mainItem;
|
|
3223
|
+
}
|
|
3224
|
+
else {
|
|
3225
|
+
this.defToolbarItems = leftItem.concat(zoomItem, mainItem, rightItem);
|
|
3226
|
+
}
|
|
3227
|
+
var toolbar = new Toolbar({
|
|
3228
|
+
width: '100%',
|
|
3229
|
+
items: this.defToolbarItems,
|
|
3230
|
+
clicked: this.defToolbarClicked.bind(this),
|
|
3231
|
+
created: function () {
|
|
3232
|
+
if (!Browser.isDevice) {
|
|
3233
|
+
_this.renderSaveBtn();
|
|
3234
|
+
}
|
|
3235
|
+
if (Browser.isDevice) {
|
|
3236
|
+
if (_this.defToolbarItems.length > 0 && (!isNullOrUndefined(document.getElementById(_this.element.id + '_toolbar')))) {
|
|
3237
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
3238
|
+
toolbar.refreshOverflow();
|
|
3239
|
+
}
|
|
3240
|
+
}
|
|
3241
|
+
else {
|
|
3242
|
+
_this.createLeftToolbarControls();
|
|
3243
|
+
if (_this.defToolbarItems.length > 0 && (!isNullOrUndefined(document.getElementById(_this.element.id + '_toolbar')))) {
|
|
3244
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
3245
|
+
toolbar.refreshOverflow();
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3248
|
+
}
|
|
3249
|
+
});
|
|
3250
|
+
if (Browser.isDevice) {
|
|
3251
|
+
toolbar.appendTo('#' + this.element.id + '_bottomToolbar');
|
|
3252
|
+
}
|
|
3253
|
+
else {
|
|
3254
|
+
toolbar.appendTo('#' + this.element.id + '_toolbar');
|
|
3255
|
+
}
|
|
3256
|
+
};
|
|
3257
|
+
ImageEditor.prototype.initFilterToolbarItem = function () {
|
|
3258
|
+
var _this = this;
|
|
3259
|
+
var mainItem = this.getFilterToolbarItem();
|
|
3260
|
+
if (!isNullOrUndefined(document.querySelector('#' + this.element.id + '_contextualToolbar')) &&
|
|
3261
|
+
document.querySelector('#' + this.element.id + '_contextualToolbar').classList.contains('e-control')) {
|
|
3262
|
+
getComponent(document.getElementById(this.element.id + '_contextualToolbar'), 'toolbar').destroy();
|
|
3263
|
+
}
|
|
3264
|
+
var toolbar = new Toolbar({
|
|
3265
|
+
width: '100%',
|
|
3266
|
+
items: mainItem,
|
|
3267
|
+
clicked: this.contextualToolbarClicked.bind(this),
|
|
3268
|
+
created: function () {
|
|
3269
|
+
_this.createCanvasFilter();
|
|
3270
|
+
if (_this.currentFilter === '') {
|
|
3271
|
+
_this.currentFilter = _this.element.id + '_default';
|
|
3272
|
+
}
|
|
3273
|
+
var hdrWrapper = document.querySelector('#' + _this.element.id + '_headWrapper');
|
|
3274
|
+
if (hdrWrapper) {
|
|
3275
|
+
hdrWrapper.style.display = 'none';
|
|
3276
|
+
}
|
|
3277
|
+
document.getElementById(_this.currentFilter + 'Canvas').parentElement.parentElement.classList.add('e-selected');
|
|
3278
|
+
toolbar.refreshOverflow();
|
|
3279
|
+
}
|
|
3280
|
+
});
|
|
3281
|
+
toolbar.appendTo('#' + this.element.id + '_contextualToolbar');
|
|
3282
|
+
};
|
|
3283
|
+
ImageEditor.prototype.createCanvasFilter = function () {
|
|
3284
|
+
if (this.adjustmentLevel.sharpen || this.adjustmentLevel.bw) {
|
|
3285
|
+
this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
|
|
3286
|
+
this.inMemoryCanvas.width = this.tempImageData.width;
|
|
3287
|
+
this.inMemoryCanvas.height = this.tempImageData.height;
|
|
3288
|
+
this.inMemoryContext.putImageData(this.tempImageData, 0, 0);
|
|
3289
|
+
}
|
|
3290
|
+
var noFilter = document.querySelector('#' + this.element.id + '_defaultCanvas');
|
|
3291
|
+
noFilter.style.width = '100px';
|
|
3292
|
+
noFilter.style.height = '100px';
|
|
3293
|
+
noFilter.style.filter = this.updateAdjustment('default', null, true);
|
|
3294
|
+
var ctx = noFilter.getContext('2d');
|
|
3295
|
+
ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
|
|
3296
|
+
var chrome = document.querySelector('#' + this.element.id + '_chromeCanvas');
|
|
3297
|
+
chrome.style.width = '100px';
|
|
3298
|
+
chrome.style.height = '100px';
|
|
3299
|
+
chrome.style.filter = this.updateAdjustment('chrome', null, true);
|
|
3300
|
+
ctx = chrome.getContext('2d');
|
|
3301
|
+
ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
|
|
3302
|
+
var cold = document.querySelector('#' + this.element.id + '_coldCanvas');
|
|
3303
|
+
cold.style.width = '100px';
|
|
3304
|
+
cold.style.height = '100px';
|
|
3305
|
+
cold.style.filter = this.updateAdjustment('cold', null, true);
|
|
3306
|
+
ctx = cold.getContext('2d');
|
|
3307
|
+
ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
|
|
3308
|
+
var warm = document.querySelector('#' + this.element.id + '_warmCanvas');
|
|
3309
|
+
warm.style.width = '100px';
|
|
3310
|
+
warm.style.height = '100px';
|
|
3311
|
+
warm.style.filter = this.updateAdjustment('warm', null, true);
|
|
3312
|
+
ctx = warm.getContext('2d');
|
|
3313
|
+
ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
|
|
3314
|
+
var temp = this.lowerContext.filter;
|
|
3315
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
3316
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
3317
|
+
for (var i = 0; i < this.objColl.length; i++) {
|
|
3318
|
+
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
3319
|
+
this.refreshActiveObj();
|
|
3320
|
+
}
|
|
3321
|
+
this.lowerContext.filter = temp;
|
|
3322
|
+
var grayscale = document.querySelector('#' + this.element.id + '_grayscaleCanvas');
|
|
3323
|
+
grayscale.style.width = '100px';
|
|
3324
|
+
grayscale.style.height = '100px';
|
|
3325
|
+
grayscale.style.filter = this.updateAdjustment('grayscale', null, true);
|
|
3326
|
+
ctx = grayscale.getContext('2d');
|
|
3327
|
+
ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
|
|
3328
|
+
var tempFilter = this.lowerContext.filter;
|
|
3329
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
3330
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
3331
|
+
for (var i = 0; i < this.objColl.length; i++) {
|
|
3332
|
+
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
3333
|
+
this.refreshActiveObj();
|
|
3334
|
+
}
|
|
3335
|
+
this.lowerContext.filter = tempFilter;
|
|
3336
|
+
var sepia = document.querySelector('#' + this.element.id + '_sepiaCanvas');
|
|
3337
|
+
sepia.style.width = '100px';
|
|
3338
|
+
sepia.style.height = '100px';
|
|
3339
|
+
sepia.style.filter = this.updateAdjustment('sepia', null, true);
|
|
3340
|
+
ctx = sepia.getContext('2d');
|
|
3341
|
+
ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
|
|
3342
|
+
var invert = document.querySelector('#' + this.element.id + '_invertCanvas');
|
|
3343
|
+
invert.style.width = '100px';
|
|
3344
|
+
invert.style.height = '100px';
|
|
3345
|
+
invert.style.filter = this.updateAdjustment('invert', null, true);
|
|
3346
|
+
ctx = invert.getContext('2d');
|
|
3347
|
+
ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
|
|
3348
|
+
};
|
|
2090
3349
|
ImageEditor.prototype.updateCanvas = function () {
|
|
2091
3350
|
this.lastX = this.baseImg.width / 2;
|
|
2092
3351
|
this.lastY = this.baseImg.height / 2;
|
|
@@ -2105,9 +3364,10 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2105
3364
|
maxDimension.width -= toolbarHeight;
|
|
2106
3365
|
maxDimension.height -= toolbarHeight;
|
|
2107
3366
|
}
|
|
3367
|
+
var tempFilter = this.lowerContext.filter;
|
|
2108
3368
|
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
2109
|
-
this.lowerCanvas.width = this.upperCanvas.width = this.
|
|
2110
|
-
this.lowerCanvas.height = this.upperCanvas.height = this.
|
|
3369
|
+
this.lowerCanvas.width = this.upperCanvas.width = this.baseImg.width;
|
|
3370
|
+
this.lowerCanvas.height = this.upperCanvas.height = this.baseImg.height;
|
|
2111
3371
|
this.lowerCanvas.style.maxWidth = this.upperCanvas.style.maxWidth = maxDimension.width + 'px';
|
|
2112
3372
|
this.lowerCanvas.style.maxHeight = this.upperCanvas.style.maxHeight = maxDimension.height + 'px';
|
|
2113
3373
|
this.lowerCanvas.style.left = this.upperCanvas.style.left = (wrapperWidth - maxDimension.width) / 2 + 1 + 'px';
|
|
@@ -2117,16 +3377,37 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2117
3377
|
if (canvasWrapper) {
|
|
2118
3378
|
this.lowerCanvas.style.top = this.upperCanvas.style.top = (parseFloat(canvasWrapper.style.height) - maxDimension.height - 1) / 2 + 'px';
|
|
2119
3379
|
}
|
|
2120
|
-
this.lowerContext.
|
|
2121
|
-
this.
|
|
3380
|
+
this.lowerContext.filter = tempFilter;
|
|
3381
|
+
if (this.lowerContext.filter === 'none' || this.lowerContext.filter === 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
3382
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)' ||
|
|
3383
|
+
this.isInitialLoading) {
|
|
3384
|
+
this.lowerContext.drawImage(this.baseImg, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
3385
|
+
this.updateInMemoryCanvas('updateCanvas');
|
|
3386
|
+
if (this.canvasFilter !== 'none') {
|
|
3387
|
+
this.lowerContext.filter = this.canvasFilter;
|
|
3388
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
3389
|
+
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
3390
|
+
}
|
|
3391
|
+
if (this.isInitialLoading) {
|
|
3392
|
+
this.initializeFilter();
|
|
3393
|
+
this.isInitialLoading = false;
|
|
3394
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
3395
|
+
this.lowerContext.drawImage(this.baseImg, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
3396
|
+
}
|
|
3397
|
+
}
|
|
3398
|
+
else {
|
|
3399
|
+
var temp = this.lowerContext.filter;
|
|
3400
|
+
this.updateBrightnessFilter();
|
|
3401
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
3402
|
+
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
3403
|
+
this.lowerContext.filter = temp;
|
|
3404
|
+
}
|
|
3405
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
3406
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
2122
3407
|
for (var i = 0, len = this.objColl.length; i < len; i++) {
|
|
2123
3408
|
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
2124
3409
|
}
|
|
2125
|
-
|
|
2126
|
-
if (this.flipState !== '') {
|
|
2127
|
-
this.flip(this.flipState);
|
|
2128
|
-
}
|
|
2129
|
-
}
|
|
3410
|
+
this.lowerContext.filter = tempFilter;
|
|
2130
3411
|
if (this.disabled) {
|
|
2131
3412
|
this.element.setAttribute('class', 'e-disabled');
|
|
2132
3413
|
}
|
|
@@ -2136,7 +3417,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2136
3417
|
var _this = this;
|
|
2137
3418
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
2138
3419
|
var proxy = this;
|
|
2139
|
-
proxy.baseImg.src = proxy.baseImgSrc = src;
|
|
3420
|
+
proxy.baseImg.src = proxy.baseImgSrc.id = src;
|
|
2140
3421
|
this.baseImg.onload = function () {
|
|
2141
3422
|
_this.lowerContext.drawImage(_this.baseImg, 0, 0, _this.lowerCanvas.width, _this.lowerCanvas.height);
|
|
2142
3423
|
if (_this.togglePen) {
|
|
@@ -2157,7 +3438,6 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2157
3438
|
hideSpinner(_this.element);
|
|
2158
3439
|
_this.element.style.opacity = '1';
|
|
2159
3440
|
_this.updateCanvas();
|
|
2160
|
-
_this.isUndoRedo = false;
|
|
2161
3441
|
}
|
|
2162
3442
|
if (Browser.isDevice) {
|
|
2163
3443
|
if (_this.isToolbar() && (!isNullOrUndefined(document.getElementById(_this.element.id + '_toolbar'))) &&
|
|
@@ -2334,9 +3614,6 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2334
3614
|
this.degree = 0;
|
|
2335
3615
|
}
|
|
2336
3616
|
};
|
|
2337
|
-
ImageEditor.prototype.updateUndoRedoColl = function (operation, value, previousObj, currentObj) {
|
|
2338
|
-
this.undoRedoColl.push({ operation: operation, value: value, previousObj: previousObj, currentObj: currentObj });
|
|
2339
|
-
};
|
|
2340
3617
|
ImageEditor.prototype.fileSelect = function (inputElement, args) {
|
|
2341
3618
|
showSpinner(this.element);
|
|
2342
3619
|
this.element.style.opacity = '0.5';
|
|
@@ -2495,7 +3772,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2495
3772
|
}
|
|
2496
3773
|
if (strokeWidthElem) {
|
|
2497
3774
|
var strokeWidth = Math.round((this.activeObj.strokeSettings.strokeWidth /
|
|
2498
|
-
(ratio.width + ratio.height))).toString();
|
|
3775
|
+
(ratio.width + ratio.height)) * this.factor).toString();
|
|
2499
3776
|
strokeWidthElem.textContent = this.getStrokeWidth(strokeWidth);
|
|
2500
3777
|
}
|
|
2501
3778
|
};
|
|
@@ -2507,10 +3784,32 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2507
3784
|
}
|
|
2508
3785
|
}
|
|
2509
3786
|
};
|
|
3787
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
3788
|
+
ImageEditor.prototype.targetTouches = function (touches) {
|
|
3789
|
+
var p1 = { x: touches[0].pageX, y: touches[0].pageY };
|
|
3790
|
+
var p2 = { x: touches[1].pageX, y: touches[1].pageY };
|
|
3791
|
+
var points = [p1, p2];
|
|
3792
|
+
return points;
|
|
3793
|
+
};
|
|
3794
|
+
ImageEditor.prototype.calculateScale = function (startTouches, endTouches) {
|
|
3795
|
+
var startDistance = this.getDistance(startTouches[0], startTouches[1]);
|
|
3796
|
+
var endDistance = this.getDistance(endTouches[0], endTouches[1]);
|
|
3797
|
+
return endDistance / startDistance;
|
|
3798
|
+
};
|
|
3799
|
+
ImageEditor.prototype.getDistance = function (a, b) {
|
|
3800
|
+
var x = a.x - b.x;
|
|
3801
|
+
var y = a.y - b.y;
|
|
3802
|
+
return Math.sqrt(x * x + y * y);
|
|
3803
|
+
};
|
|
2510
3804
|
ImageEditor.prototype.touchStartHandler = function (e) {
|
|
2511
3805
|
e.preventDefault();
|
|
2512
|
-
|
|
2513
|
-
|
|
3806
|
+
if (e.touches.length === 2) {
|
|
3807
|
+
this.isFirstMove = true;
|
|
3808
|
+
}
|
|
3809
|
+
else {
|
|
3810
|
+
this.timer = setTimeout(this.setTimer.bind(this), 1000, e);
|
|
3811
|
+
this.mouseDownEventHandler(e);
|
|
3812
|
+
}
|
|
2514
3813
|
EventHandler.add(this.lowerCanvas, 'touchend', this.mouseUpEventHandler, this);
|
|
2515
3814
|
EventHandler.add(this.lowerCanvas, 'touchmove', this.mouseMoveEventHandler, this); // Unbind mousedown to prevent double triggers from touch devices
|
|
2516
3815
|
EventHandler.add(this.upperCanvas, 'touchend', this.mouseUpEventHandler, this);
|
|
@@ -2537,6 +3836,14 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2537
3836
|
this.touchEndPoint.y = y = e.touches[0].clientY;
|
|
2538
3837
|
}
|
|
2539
3838
|
this.redrawActObj(x, y);
|
|
3839
|
+
if ((!isNullOrUndefined(this.element.querySelector('#' + this.element.id + '_contextualToolbar')) &&
|
|
3840
|
+
!this.element.querySelector('#' + this.element.id + '_contextualToolbar').parentElement.classList.contains('e-hide')) ||
|
|
3841
|
+
(!isNullOrUndefined(this.element.querySelector('#' + this.element.id + '_headWrapper'))
|
|
3842
|
+
&& !this.element.querySelector('#' + this.element.id + '_headWrapper').parentElement.classList.contains('e-hide'))) {
|
|
3843
|
+
this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
|
|
3844
|
+
this.okBtn();
|
|
3845
|
+
this.refreshToolbar('main');
|
|
3846
|
+
}
|
|
2540
3847
|
if (this.upperCanvas.style.cursor === 'crosshair' || (Browser.isDevice && this.togglePen)) {
|
|
2541
3848
|
if (this.togglePen) {
|
|
2542
3849
|
this.canvasRatio = this.calcRatio();
|
|
@@ -2600,6 +3907,47 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2600
3907
|
};
|
|
2601
3908
|
ImageEditor.prototype.mouseMoveEventHandler = function (e) {
|
|
2602
3909
|
e.preventDefault();
|
|
3910
|
+
if (e.type === 'touchmove' && e.touches.length === 2) {
|
|
3911
|
+
if (this.isFirstMove) {
|
|
3912
|
+
this.startTouches = this.targetTouches(e.touches);
|
|
3913
|
+
this.tempTouches = [];
|
|
3914
|
+
this.tempTouches.push({ x: e.touches[0].clientX || (e.touches[0].pageX - this.lowerCanvas.offsetLeft),
|
|
3915
|
+
y: e.touches[0].clientY || (e.touches[0].pageY - this.lowerCanvas.offsetTop) });
|
|
3916
|
+
this.tempTouches.push({ x: e.touches[1].clientX || (e.touches[1].pageX - this.lowerCanvas.offsetLeft),
|
|
3917
|
+
y: e.touches[1].clientY || (e.touches[1].pageY - this.lowerCanvas.offsetTop) });
|
|
3918
|
+
}
|
|
3919
|
+
else {
|
|
3920
|
+
var ratio = this.calcRatio();
|
|
3921
|
+
var firstFingerX = e.touches[0].clientX || (e.touches[0].pageX - this.lowerCanvas.offsetLeft);
|
|
3922
|
+
var firstFingerY = e.touches[0].clientY || (e.touches[0].pageY - this.lowerCanvas.offsetTop);
|
|
3923
|
+
var secondFingerX = e.touches[1].clientX || (e.touches[1].pageX - this.lowerCanvas.offsetLeft);
|
|
3924
|
+
var secondFingerY = e.touches[1].clientY || (e.touches[1].pageY - this.lowerCanvas.offsetTop);
|
|
3925
|
+
this.lastX = firstFingerX > secondFingerX ? secondFingerX + (firstFingerX - secondFingerX) : firstFingerX +
|
|
3926
|
+
(secondFingerX - firstFingerX);
|
|
3927
|
+
this.lastY = firstFingerY > secondFingerY ? secondFingerY + (firstFingerY - secondFingerY) : firstFingerY +
|
|
3928
|
+
(secondFingerY - firstFingerY);
|
|
3929
|
+
this.lastX *= ratio.width;
|
|
3930
|
+
this.lastY *= ratio.height;
|
|
3931
|
+
var scale = this.calculateScale(this.startTouches, this.targetTouches(e.touches));
|
|
3932
|
+
// Need to set lastX and lastY points
|
|
3933
|
+
if (this.tempTouches[0].x !== firstFingerX && this.tempTouches[0].y !== firstFingerY &&
|
|
3934
|
+
this.tempTouches[1].x !== secondFingerX && this.tempTouches[1].y !== secondFingerY) {
|
|
3935
|
+
if (scale > 1) {
|
|
3936
|
+
this.zoom(1.1);
|
|
3937
|
+
}
|
|
3938
|
+
else {
|
|
3939
|
+
this.zoom(-1.1);
|
|
3940
|
+
}
|
|
3941
|
+
this.tempTouches = [];
|
|
3942
|
+
this.tempTouches.push({ x: e.touches[0].clientX || (e.touches[0].pageX - this.lowerCanvas.offsetLeft),
|
|
3943
|
+
y: e.touches[0].clientY || (e.touches[0].pageY - this.lowerCanvas.offsetTop) });
|
|
3944
|
+
this.tempTouches.push({ x: e.touches[1].clientX || (e.touches[1].pageX - this.lowerCanvas.offsetLeft),
|
|
3945
|
+
y: e.touches[1].clientY || (e.touches[1].pageY - this.lowerCanvas.offsetTop) });
|
|
3946
|
+
}
|
|
3947
|
+
}
|
|
3948
|
+
this.isFirstMove = false;
|
|
3949
|
+
return;
|
|
3950
|
+
}
|
|
2603
3951
|
if (this.textBox.style.display === 'none') {
|
|
2604
3952
|
this.isTimer = true;
|
|
2605
3953
|
}
|
|
@@ -2618,6 +3966,11 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2618
3966
|
!this.dragCanvas || this.activeObj.activePoint !== undefined) {
|
|
2619
3967
|
if (this.dragElement === '') {
|
|
2620
3968
|
this.setCursor(x, y);
|
|
3969
|
+
if (this.activeObj.activePoint.width === 0 && this.upperCanvas.style.cursor !== 'default' &&
|
|
3970
|
+
this.upperCanvas.style.cursor !== 'move' && this.upperCanvas.style.cursor !== 'crosshair'
|
|
3971
|
+
&& this.upperCanvas.style.cursor !== 'grab') {
|
|
3972
|
+
this.upperCanvas.style.cursor = 'move';
|
|
3973
|
+
}
|
|
2621
3974
|
this.findTarget(x, y, e.type);
|
|
2622
3975
|
}
|
|
2623
3976
|
}
|
|
@@ -2640,6 +3993,8 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2640
3993
|
y = this.touchEndPoint.y;
|
|
2641
3994
|
}
|
|
2642
3995
|
if (e.type === 'touchend') {
|
|
3996
|
+
this.startTouches = this.tempTouches = [];
|
|
3997
|
+
this.isFirstMove = false;
|
|
2643
3998
|
if (this.textBox.style.display === 'none') {
|
|
2644
3999
|
this.isTimer = false;
|
|
2645
4000
|
this.timer = 0;
|
|
@@ -2658,8 +4013,16 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2658
4013
|
if (e.currentTarget === this.upperCanvas) {
|
|
2659
4014
|
this.currObjType.shape = this.currObjType.shape.toLowerCase();
|
|
2660
4015
|
if (!this.togglePen && !this.dragCanvas) {
|
|
4016
|
+
if (!isNullOrUndefined(this.tempObjColl) && this.activeObj.activePoint.width !== 0) {
|
|
4017
|
+
this.objColl.push(this.activeObj);
|
|
4018
|
+
this.redrawShape(this.objColl[this.objColl.length - 1]);
|
|
4019
|
+
this.tempObjColl = undefined;
|
|
4020
|
+
}
|
|
2661
4021
|
this.applyCurrActObj(x, y);
|
|
2662
4022
|
}
|
|
4023
|
+
else if (this.dragCanvas) {
|
|
4024
|
+
this.setPanPoints();
|
|
4025
|
+
}
|
|
2663
4026
|
}
|
|
2664
4027
|
if (this.togglePen && e.currentTarget === this.upperCanvas) {
|
|
2665
4028
|
this.penDrawColl.push({ strokeWidth: this.penStrokeWidth, strokeColor: this.activeObj.strokeSettings.strokeColor, points: this.imageEditorPointsColl });
|
|
@@ -2688,11 +4051,13 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2688
4051
|
e.stopImmediatePropagation();
|
|
2689
4052
|
break;
|
|
2690
4053
|
case 'Delete':
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
4054
|
+
if (this.textBox.style.display === 'none') {
|
|
4055
|
+
shapeChangingArgs = { action: 'delete', previousShapeSettings: this.activeObj, currentShapeSettings: null };
|
|
4056
|
+
this.keyHistory = '';
|
|
4057
|
+
this.clearSelection();
|
|
4058
|
+
this.trigger('shapeChanging', shapeChangingArgs);
|
|
4059
|
+
this.refreshToolbar('main');
|
|
4060
|
+
}
|
|
2696
4061
|
break;
|
|
2697
4062
|
case 'Escape':
|
|
2698
4063
|
if (this.togglePan) {
|
|
@@ -2714,7 +4079,10 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2714
4079
|
}
|
|
2715
4080
|
};
|
|
2716
4081
|
ImageEditor.prototype.keyUpEventHandler = function (e) {
|
|
2717
|
-
|
|
4082
|
+
// eslint-disable-next-line
|
|
4083
|
+
if (this.textBox.style.display === 'block' && e.target.id === this.element.id + '_textBox') {
|
|
4084
|
+
setTimeout(this.textKeyDown.bind(this), 1, e);
|
|
4085
|
+
}
|
|
2718
4086
|
};
|
|
2719
4087
|
ImageEditor.prototype.canvasMouseDownHandler = function (e) {
|
|
2720
4088
|
e.preventDefault();
|
|
@@ -2732,7 +4100,6 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2732
4100
|
if (this.dragCanvas || this.factor !== 1) {
|
|
2733
4101
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
2734
4102
|
this.dragStart = this.lowerContext.transformedPoint(this.lastX, this.lastY);
|
|
2735
|
-
this.dragged = false;
|
|
2736
4103
|
}
|
|
2737
4104
|
};
|
|
2738
4105
|
ImageEditor.prototype.canvasMouseMoveHandler = function (e) {
|
|
@@ -2754,55 +4121,39 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2754
4121
|
}
|
|
2755
4122
|
this.lastX *= ratio.width;
|
|
2756
4123
|
this.lastY *= ratio.height;
|
|
2757
|
-
this.dragged = true;
|
|
2758
4124
|
if (this.dragStart && this.dragCanvas) {
|
|
2759
|
-
|
|
2760
|
-
var pt = this.lowerContext.transformedPoint(this.lastX, this.lastY);
|
|
2761
|
-
var transitionArgs = { startPoint: { x: this.dragStart.x, y: this.dragStart.y },
|
|
2762
|
-
endPoint: { x: pt.x, y: pt.y } };
|
|
2763
|
-
this.trigger('panning', transitionArgs);
|
|
2764
|
-
var xDiff = pt.x - this.dragStart.x;
|
|
2765
|
-
var yDiff = pt.y - this.dragStart.y;
|
|
2766
|
-
var xxDiff = xDiff;
|
|
2767
|
-
var yyDiff = yDiff;
|
|
2768
|
-
this.lowerContext.translate(xDiff, yDiff);
|
|
2769
|
-
this.upperContext.translate(xDiff, yDiff);
|
|
2770
|
-
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
2771
|
-
var pt1 = this.lowerContext.transformedPoint(0, 0);
|
|
2772
|
-
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
2773
|
-
var pt2 = this.lowerContext.transformedPoint(this.lowerCanvas.width, this.lowerCanvas.height);
|
|
2774
|
-
if (xDiff >= 0) {
|
|
2775
|
-
if (pt1.x < 1) {
|
|
2776
|
-
xDiff = 0;
|
|
2777
|
-
}
|
|
2778
|
-
}
|
|
2779
|
-
else {
|
|
2780
|
-
if (pt2.x > this.lowerCanvas.width) {
|
|
2781
|
-
xDiff = 0;
|
|
2782
|
-
}
|
|
2783
|
-
}
|
|
2784
|
-
if (yDiff >= 0) {
|
|
2785
|
-
if (pt1.y < 1) {
|
|
2786
|
-
yDiff = 0;
|
|
2787
|
-
}
|
|
2788
|
-
}
|
|
2789
|
-
else {
|
|
2790
|
-
if (pt2.y > this.lowerCanvas.height) {
|
|
2791
|
-
yDiff = 0;
|
|
2792
|
-
}
|
|
2793
|
-
}
|
|
2794
|
-
this.lowerContext.translate(-xxDiff, -yyDiff);
|
|
2795
|
-
this.upperContext.translate(-xxDiff, -yyDiff);
|
|
2796
|
-
this.lowerContext.translate(xDiff, yDiff);
|
|
2797
|
-
this.upperContext.translate(xDiff, yDiff);
|
|
2798
|
-
this.redraw();
|
|
4125
|
+
this.drawPanImg();
|
|
2799
4126
|
}
|
|
2800
4127
|
};
|
|
2801
4128
|
ImageEditor.prototype.canvasMouseUpHandler = function (e) {
|
|
2802
4129
|
e.preventDefault();
|
|
4130
|
+
if (this.togglePan && e.currentTarget === this.lowerCanvas) {
|
|
4131
|
+
var ratio = this.calcRatio();
|
|
4132
|
+
if (e.type === 'mouseup') {
|
|
4133
|
+
this.lastX = e.offsetX || (e.pageX - this.lowerCanvas.offsetLeft);
|
|
4134
|
+
this.lastY = e.offsetY || (e.pageY - this.lowerCanvas.offsetTop);
|
|
4135
|
+
}
|
|
4136
|
+
else {
|
|
4137
|
+
this.lastX = e.touches[0].clientX || (e.touches[0].pageX - this.lowerCanvas.offsetLeft);
|
|
4138
|
+
this.lastY = e.touches[0].clientY || (e.touches[0].pageY - this.lowerCanvas.offsetTop);
|
|
4139
|
+
}
|
|
4140
|
+
this.lastX *= ratio.width;
|
|
4141
|
+
this.lastY *= ratio.height;
|
|
4142
|
+
this.setPanPoints();
|
|
4143
|
+
}
|
|
2803
4144
|
this.dragStart = null;
|
|
4145
|
+
// zooms on mouse click point
|
|
4146
|
+
// if (e.currentTarget !== document) {
|
|
4147
|
+
// this.zoom(e.shiftKey ? -1 : 1 );
|
|
4148
|
+
// }
|
|
2804
4149
|
this.currObjType.isDragging = false;
|
|
2805
4150
|
};
|
|
4151
|
+
ImageEditor.prototype.setPanPoints = function () {
|
|
4152
|
+
if (this.dragCanvas || this.factor !== 1) {
|
|
4153
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
4154
|
+
this.dragStart = this.lowerContext.transformedPoint(this.lastX, this.lastY);
|
|
4155
|
+
}
|
|
4156
|
+
};
|
|
2806
4157
|
ImageEditor.prototype.textKeyDown = function (e) {
|
|
2807
4158
|
if (String.fromCharCode(e.which) === '\r') {
|
|
2808
4159
|
this.textRow += 1;
|
|
@@ -2821,6 +4172,8 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2821
4172
|
ImageEditor.prototype.adjustToScreen = function () {
|
|
2822
4173
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
2823
4174
|
var proxy = this;
|
|
4175
|
+
var tempFilter = this.lowerContext.filter;
|
|
4176
|
+
this.okBtn();
|
|
2824
4177
|
this.applyActObj();
|
|
2825
4178
|
this.refreshActiveObj();
|
|
2826
4179
|
if (this.imgDataColl.length > 0) {
|
|
@@ -2842,15 +4195,32 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2842
4195
|
canvasWrapper.style.height = (parseFloat(canvasWrapper.style.height) - this.toolbarHeight) - 3 + 'px';
|
|
2843
4196
|
}
|
|
2844
4197
|
}
|
|
2845
|
-
this.redrawImg();
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
4198
|
+
this.redrawImg(tempFilter);
|
|
4199
|
+
if (!this.currObjType.isSave) {
|
|
4200
|
+
// eslint-disable-next-line @typescript-eslint/tslint/config
|
|
4201
|
+
this.lowerCanvas.toBlob(function (blob) {
|
|
4202
|
+
proxy.lowerContext.filter = proxy.initialAdjustmentValue = proxy.adjustmentValue = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
4203
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
4204
|
+
if (proxy.cssClass) {
|
|
4205
|
+
addClass([proxy.element], proxy.cssClass.split(' '));
|
|
4206
|
+
}
|
|
4207
|
+
proxy.lowerContext.clearRect(0, 0, proxy.lowerCanvas.width, proxy.lowerCanvas.height);
|
|
4208
|
+
proxy.lowerContext.drawImage(proxy.inMemoryCanvas, 0, 0);
|
|
4209
|
+
proxy.baseImg.src = URL.createObjectURL(blob);
|
|
4210
|
+
proxy.lowerContext.filter = tempFilter;
|
|
4211
|
+
}, 'image/png');
|
|
4212
|
+
}
|
|
4213
|
+
else {
|
|
4214
|
+
hideSpinner(this.element);
|
|
4215
|
+
this.element.style.opacity = '1';
|
|
4216
|
+
}
|
|
2850
4217
|
if (this.defToolbarItems.length > 0 && (!isNullOrUndefined(document.getElementById(this.element.id + '_toolbar')))) {
|
|
2851
4218
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
2852
|
-
var
|
|
2853
|
-
|
|
4219
|
+
var toolbar_10 = getComponent(proxy.element.id + '_toolbar', 'toolbar');
|
|
4220
|
+
toolbar_10.refreshOverflow();
|
|
4221
|
+
if (!isNullOrUndefined(this.element.querySelector('.e-contextual-toolbar-wrapper'))) {
|
|
4222
|
+
this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
|
|
4223
|
+
}
|
|
2854
4224
|
}
|
|
2855
4225
|
};
|
|
2856
4226
|
ImageEditor.prototype.screenOrientation = function () {
|
|
@@ -2864,7 +4234,49 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2864
4234
|
this.adjustToScreen();
|
|
2865
4235
|
}
|
|
2866
4236
|
};
|
|
2867
|
-
ImageEditor.prototype.
|
|
4237
|
+
ImageEditor.prototype.drawPanImg = function () {
|
|
4238
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
4239
|
+
var pt = this.lowerContext.transformedPoint(this.lastX, this.lastY);
|
|
4240
|
+
var transitionArgs = { startPoint: { x: this.dragStart.x, y: this.dragStart.y },
|
|
4241
|
+
endPoint: { x: pt.x, y: pt.y } };
|
|
4242
|
+
this.trigger('panning', transitionArgs);
|
|
4243
|
+
var xDiff = pt.x - this.dragStart.x;
|
|
4244
|
+
var yDiff = pt.y - this.dragStart.y;
|
|
4245
|
+
var xxDiff = xDiff;
|
|
4246
|
+
var yyDiff = yDiff;
|
|
4247
|
+
this.lowerContext.translate(xDiff, yDiff);
|
|
4248
|
+
this.upperContext.translate(xDiff, yDiff);
|
|
4249
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
4250
|
+
var pt1 = this.lowerContext.transformedPoint(0, 0);
|
|
4251
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
4252
|
+
var pt2 = this.lowerContext.transformedPoint(this.lowerCanvas.width, this.lowerCanvas.height);
|
|
4253
|
+
if (xDiff >= 0) {
|
|
4254
|
+
if (pt1.x < 1) {
|
|
4255
|
+
xDiff = 0;
|
|
4256
|
+
}
|
|
4257
|
+
}
|
|
4258
|
+
else {
|
|
4259
|
+
if (pt2.x > this.lowerCanvas.width) {
|
|
4260
|
+
xDiff = 0;
|
|
4261
|
+
}
|
|
4262
|
+
}
|
|
4263
|
+
if (yDiff >= 0) {
|
|
4264
|
+
if (pt1.y < 1) {
|
|
4265
|
+
yDiff = 0;
|
|
4266
|
+
}
|
|
4267
|
+
}
|
|
4268
|
+
else {
|
|
4269
|
+
if (pt2.y > this.lowerCanvas.height) {
|
|
4270
|
+
yDiff = 0;
|
|
4271
|
+
}
|
|
4272
|
+
}
|
|
4273
|
+
this.lowerContext.translate(-xxDiff, -yyDiff);
|
|
4274
|
+
this.upperContext.translate(-xxDiff, -yyDiff);
|
|
4275
|
+
this.lowerContext.translate(xDiff, yDiff);
|
|
4276
|
+
this.upperContext.translate(xDiff, yDiff);
|
|
4277
|
+
this.redraw();
|
|
4278
|
+
};
|
|
4279
|
+
ImageEditor.prototype.redrawImg = function (tempFilter) {
|
|
2868
4280
|
var wrapperWidth;
|
|
2869
4281
|
var canvasWrapper = document.querySelector('#' + this.element.id + '_canvasWrapper');
|
|
2870
4282
|
if (this.isScreenOriented) {
|
|
@@ -2880,7 +4292,17 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2880
4292
|
this.lowerCanvas.style.maxHeight = this.upperCanvas.style.maxHeight = maxDimension.height + 'px';
|
|
2881
4293
|
this.lowerCanvas.style.left = this.upperCanvas.style.left = (wrapperWidth - maxDimension.width) / 2 + 1 + 'px';
|
|
2882
4294
|
this.lowerCanvas.style.top = this.upperCanvas.style.top = (this.element.offsetHeight - this.toolbarHeight - maxDimension.height) / 2 + 1 + 'px';
|
|
4295
|
+
this.lowerContext.filter = tempFilter;
|
|
4296
|
+
var temp = this.lowerContext.filter;
|
|
4297
|
+
this.updateBrightnessFilter();
|
|
2883
4298
|
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
4299
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
4300
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
4301
|
+
for (var i = 0; i < this.objColl.length; i++) {
|
|
4302
|
+
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
4303
|
+
this.refreshActiveObj();
|
|
4304
|
+
}
|
|
4305
|
+
this.lowerContext.filter = temp;
|
|
2884
4306
|
};
|
|
2885
4307
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
2886
4308
|
ImageEditor.prototype.updateContext = function (ctx) {
|
|
@@ -2929,7 +4351,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2929
4351
|
var transform = ctx.transform;
|
|
2930
4352
|
ctx.transform = function (a, b, c, d, e, f) {
|
|
2931
4353
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
2932
|
-
var m2 = new DOMMatrix(
|
|
4354
|
+
var m2 = new DOMMatrix();
|
|
2933
4355
|
m2.a = a;
|
|
2934
4356
|
m2.b = b;
|
|
2935
4357
|
m2.c = c;
|
|
@@ -2957,6 +4379,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2957
4379
|
return pt.matrixTransform(xform.inverse());
|
|
2958
4380
|
};
|
|
2959
4381
|
};
|
|
4382
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
2960
4383
|
ImageEditor.prototype.scaleNonUniform = function (xform, sx, sy) {
|
|
2961
4384
|
xform.m11 *= sx;
|
|
2962
4385
|
xform.m12 *= sx;
|
|
@@ -2993,11 +4416,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2993
4416
|
this.upperContext.setTransform(1, 0, 0, 1, 0, 0);
|
|
2994
4417
|
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
2995
4418
|
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
2996
|
-
this.
|
|
2997
|
-
for (var j = 0; j < this.objColl.length; j++) {
|
|
2998
|
-
this.apply(this.objColl[j].shape, this.objColl[j]);
|
|
2999
|
-
this.refreshActiveObj();
|
|
3000
|
-
}
|
|
4419
|
+
this.redrawImgWithObj();
|
|
3001
4420
|
}
|
|
3002
4421
|
else {
|
|
3003
4422
|
if (this.factor > 1) {
|
|
@@ -3060,11 +4479,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
3060
4479
|
this.upperContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
3061
4480
|
this.lowerContext.restore();
|
|
3062
4481
|
this.upperContext.restore();
|
|
3063
|
-
this.
|
|
3064
|
-
for (var j = 0; j < this.objColl.length; j++) {
|
|
3065
|
-
this.apply(this.objColl[j].shape, this.objColl[j]);
|
|
3066
|
-
this.refreshActiveObj();
|
|
3067
|
-
}
|
|
4482
|
+
this.redrawImgWithObj();
|
|
3068
4483
|
};
|
|
3069
4484
|
ImageEditor.prototype.applyCurrActObj = function (x, y) {
|
|
3070
4485
|
var isInside = false;
|
|
@@ -3088,9 +4503,13 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
3088
4503
|
}
|
|
3089
4504
|
if (this.activeObj.shape === 'text' || (this.currObjType.shape === 'ellipse' || this.currObjType.shape === 'rectangle' ||
|
|
3090
4505
|
this.currObjType.shape === 'line')) {
|
|
4506
|
+
var tempFilter = this.lowerContext.filter;
|
|
4507
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
4508
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
3091
4509
|
for (var j = 0; j < this.objColl.length; j++) {
|
|
3092
4510
|
this.apply(this.objColl[j].shape, this.objColl[j]);
|
|
3093
4511
|
}
|
|
4512
|
+
this.lowerContext.filter = tempFilter;
|
|
3094
4513
|
this.apply('shape');
|
|
3095
4514
|
}
|
|
3096
4515
|
}
|
|
@@ -3116,6 +4535,24 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
3116
4535
|
this.setTextSelection(width, height);
|
|
3117
4536
|
this.updateActiveObject(ratio, this.activeObj.activePoint, this.activeObj);
|
|
3118
4537
|
};
|
|
4538
|
+
ImageEditor.prototype.setTextBoxStylesToActObj = function () {
|
|
4539
|
+
var ratio = this.calcRatio();
|
|
4540
|
+
this.activeObj.textSettings.fontFamily = this.textBox.style.fontFamily;
|
|
4541
|
+
this.activeObj.strokeSettings.strokeColor = this.textBox.style.color;
|
|
4542
|
+
if (this.textBox.style.fontWeight === 'bold') {
|
|
4543
|
+
this.activeObj.textSettings.bold = true;
|
|
4544
|
+
}
|
|
4545
|
+
else {
|
|
4546
|
+
this.activeObj.textSettings.bold = false;
|
|
4547
|
+
}
|
|
4548
|
+
if (this.textBox.style.fontStyle === 'italic') {
|
|
4549
|
+
this.activeObj.textSettings.italic = true;
|
|
4550
|
+
}
|
|
4551
|
+
else {
|
|
4552
|
+
this.activeObj.textSettings.italic = false;
|
|
4553
|
+
}
|
|
4554
|
+
this.activeObj.textSettings.fontSize = (parseFloat(this.textBox.style.fontSize) * ((ratio.width + ratio.height) / 2)) / this.factor;
|
|
4555
|
+
};
|
|
3119
4556
|
ImageEditor.prototype.redrawActObj = function (x, y) {
|
|
3120
4557
|
var ratio = this.calcRatio();
|
|
3121
4558
|
var splitWords;
|
|
@@ -3125,21 +4562,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
3125
4562
|
}
|
|
3126
4563
|
if (this.activeObj.horTopLine !== undefined && (this.activeObj.shape !== undefined && splitWords[0] !== 'crop')) {
|
|
3127
4564
|
if (this.textBox.style.display === 'block') {
|
|
3128
|
-
this.
|
|
3129
|
-
this.activeObj.strokeSettings.strokeColor = this.textBox.style.color;
|
|
3130
|
-
if (this.textBox.style.fontWeight === 'bold') {
|
|
3131
|
-
this.activeObj.textSettings.bold = true;
|
|
3132
|
-
}
|
|
3133
|
-
else {
|
|
3134
|
-
this.activeObj.textSettings.bold = false;
|
|
3135
|
-
}
|
|
3136
|
-
if (this.textBox.style.fontStyle === 'italic') {
|
|
3137
|
-
this.activeObj.textSettings.italic = true;
|
|
3138
|
-
}
|
|
3139
|
-
else {
|
|
3140
|
-
this.activeObj.textSettings.italic = false;
|
|
3141
|
-
}
|
|
3142
|
-
this.activeObj.textSettings.fontSize = (parseFloat(this.textBox.style.fontSize) * ((ratio.width + ratio.height) / 2)) / this.factor;
|
|
4565
|
+
this.setTextBoxStylesToActObj();
|
|
3143
4566
|
if (x && y) {
|
|
3144
4567
|
x -= bbox.left;
|
|
3145
4568
|
y -= bbox.top;
|
|
@@ -3601,10 +5024,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
3601
5024
|
}
|
|
3602
5025
|
}
|
|
3603
5026
|
this.lowerContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
3604
|
-
this.
|
|
3605
|
-
for (var i = 0; i < this.objColl.length; i++) {
|
|
3606
|
-
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
3607
|
-
}
|
|
5027
|
+
this.redrawImgWithObj();
|
|
3608
5028
|
this.activeObj = temp;
|
|
3609
5029
|
this.updateFontStyles();
|
|
3610
5030
|
if (this.factor === 1) {
|
|
@@ -4009,7 +5429,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
4009
5429
|
else {
|
|
4010
5430
|
diff = Math.max(this.diffPoint.x, this.diffPoint.y);
|
|
4011
5431
|
}
|
|
4012
|
-
percentage = diff / 10;
|
|
5432
|
+
percentage = (diff / 10) * this.factor;
|
|
4013
5433
|
this.activeObj.activePoint.startX -= (maxDimension.width / 100) * percentage;
|
|
4014
5434
|
this.activeObj.activePoint.startY -= (maxDimension.height / 100) * percentage;
|
|
4015
5435
|
this.activeObj.activePoint.width = this.activeObj.activePoint.endX - this.activeObj.activePoint.startX;
|
|
@@ -4154,7 +5574,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
4154
5574
|
else {
|
|
4155
5575
|
diff = Math.max(this.diffPoint.x, this.diffPoint.y);
|
|
4156
5576
|
}
|
|
4157
|
-
percentage = diff / 10;
|
|
5577
|
+
percentage = (diff / 10) * this.factor;
|
|
4158
5578
|
this.activeObj.activePoint.endX += (maxDimension.width / 100) * percentage;
|
|
4159
5579
|
this.activeObj.activePoint.startY -= (maxDimension.height / 100) * percentage;
|
|
4160
5580
|
this.activeObj.activePoint.width = this.activeObj.activePoint.endX - this.activeObj.activePoint.startX;
|
|
@@ -4350,7 +5770,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
4350
5770
|
else {
|
|
4351
5771
|
diff = Math.max(this.diffPoint.x, this.diffPoint.y);
|
|
4352
5772
|
}
|
|
4353
|
-
percentage = diff / 10;
|
|
5773
|
+
percentage = (diff / 10) * this.factor;
|
|
4354
5774
|
this.activeObj.activePoint.startX -= (maxDimension.width / 100) * percentage;
|
|
4355
5775
|
this.activeObj.activePoint.endY += (maxDimension.height / 100) * percentage;
|
|
4356
5776
|
this.activeObj.activePoint.width = this.activeObj.activePoint.endX - this.activeObj.activePoint.startX;
|
|
@@ -4497,7 +5917,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
4497
5917
|
else {
|
|
4498
5918
|
diff = Math.min(this.diffPoint.x, this.diffPoint.y);
|
|
4499
5919
|
}
|
|
4500
|
-
percentage = diff / 10;
|
|
5920
|
+
percentage = (diff / 10) * this.factor;
|
|
4501
5921
|
this.activeObj.activePoint.endX += (maxDimension.width / 50) * percentage;
|
|
4502
5922
|
this.activeObj.activePoint.endY += (maxDimension.height / 50) * percentage;
|
|
4503
5923
|
this.activeObj.activePoint.width = this.activeObj.activePoint.endX - this.activeObj.activePoint.startX;
|
|
@@ -4543,8 +5963,6 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
4543
5963
|
width = this.activeObj.activePoint.endX - x;
|
|
4544
5964
|
height = this.activeObj.activePoint.endY - y;
|
|
4545
5965
|
scale = Math.min(width, height);
|
|
4546
|
-
var ratio = this.activeObj.shape.split('-');
|
|
4547
|
-
ratio = ratio[1].split(':');
|
|
4548
5966
|
var newScale = this.getScaleRatio(scale);
|
|
4549
5967
|
this.activeObj.activePoint.endX -= newScale.x;
|
|
4550
5968
|
this.activeObj.activePoint.endY -= newScale.y;
|
|
@@ -5203,6 +6621,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
5203
6621
|
this.refreshActiveObj();
|
|
5204
6622
|
return;
|
|
5205
6623
|
}
|
|
6624
|
+
this.tempObjColl = extend([], this.objColl, [], true);
|
|
5206
6625
|
this.currObjType.isCustomCrop = false;
|
|
5207
6626
|
var temp = this.activeObj = extend({}, this.objColl[i], {}, true);
|
|
5208
6627
|
this.objColl.splice(i, 1);
|
|
@@ -5212,11 +6631,35 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
5212
6631
|
this.inMemoryContext.putImageData(this.imgDataColl[0].value, 0, 0);
|
|
5213
6632
|
}
|
|
5214
6633
|
else {
|
|
6634
|
+
if ((this.adjustmentLevel.sharpen || this.adjustmentLevel.bw) && !this.sharpenedImgData) {
|
|
6635
|
+
var data = void 0;
|
|
6636
|
+
var tempImageData = this.currImgData;
|
|
6637
|
+
if (this.adjustmentLevel.sharpen) {
|
|
6638
|
+
data = this.getSharpenData(this.currImgData);
|
|
6639
|
+
}
|
|
6640
|
+
else {
|
|
6641
|
+
data = this.getBlackAndWhiteData(tempImageData);
|
|
6642
|
+
}
|
|
6643
|
+
this.currImgData = data;
|
|
6644
|
+
this.sharpenedImgData = true;
|
|
6645
|
+
}
|
|
5215
6646
|
this.inMemoryCanvas.width = this.currImgData.width;
|
|
5216
6647
|
this.inMemoryCanvas.height = this.currImgData.height;
|
|
5217
6648
|
this.inMemoryContext.putImageData(this.currImgData, 0, 0);
|
|
5218
6649
|
}
|
|
5219
6650
|
if (this.flipState !== '') {
|
|
6651
|
+
if ((this.adjustmentLevel.sharpen || this.adjustmentLevel.bw) && !this.sharpenedImgData) {
|
|
6652
|
+
var data = void 0;
|
|
6653
|
+
var tempImageData = this.currImgData;
|
|
6654
|
+
if (this.adjustmentLevel.sharpen) {
|
|
6655
|
+
data = this.getSharpenData(this.currImgData);
|
|
6656
|
+
}
|
|
6657
|
+
else {
|
|
6658
|
+
data = this.getBlackAndWhiteData(tempImageData);
|
|
6659
|
+
}
|
|
6660
|
+
this.currImgData = data;
|
|
6661
|
+
this.sharpenedImgData = true;
|
|
6662
|
+
}
|
|
5220
6663
|
this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
|
|
5221
6664
|
this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.height, this.inMemoryCanvas.width);
|
|
5222
6665
|
this.inMemoryCanvas.width = this.currImgData.width;
|
|
@@ -5225,15 +6668,10 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
5225
6668
|
}
|
|
5226
6669
|
this.setActivePoint();
|
|
5227
6670
|
this.upperContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
6671
|
+
this.lowerContext.filter = this.canvasFilter;
|
|
5228
6672
|
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
5229
|
-
this.
|
|
6673
|
+
this.redrawImgWithObj();
|
|
5230
6674
|
this.upperContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
5231
|
-
for (var j = 0; j < this.objColl.length; j++) {
|
|
5232
|
-
if (this.objColl[j].shape === 'text' && this.objColl[j].shapeFlip !== this.currFlipState) {
|
|
5233
|
-
this.objColl[j].flippedText = true;
|
|
5234
|
-
}
|
|
5235
|
-
this.apply(this.objColl[j].shape, this.objColl[j]);
|
|
5236
|
-
}
|
|
5237
6675
|
this.activeObj = extend({}, temp, {}, true);
|
|
5238
6676
|
var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height - this.pannEnd.startY };
|
|
5239
6677
|
if (this.factor !== 1 && (this.activeObj.activePoint.startX < this.pannStart.startX || this.activeObj.activePoint.startY <
|
|
@@ -5616,7 +7054,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
5616
7054
|
}
|
|
5617
7055
|
else {
|
|
5618
7056
|
if (this.currObjType.isCustomCrop) {
|
|
5619
|
-
this.upperCanvas.style.cursor = '
|
|
7057
|
+
this.upperCanvas.style.cursor = 'crosshair';
|
|
5620
7058
|
}
|
|
5621
7059
|
this.upperCanvas.style.cursor = 'default';
|
|
5622
7060
|
}
|
|
@@ -5713,7 +7151,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
5713
7151
|
}
|
|
5714
7152
|
else {
|
|
5715
7153
|
if (this.currObjType.isCustomCrop) {
|
|
5716
|
-
this.upperCanvas.style.cursor = '
|
|
7154
|
+
this.upperCanvas.style.cursor = 'crosshair';
|
|
5717
7155
|
}
|
|
5718
7156
|
this.upperCanvas.style.cursor = 'default';
|
|
5719
7157
|
}
|
|
@@ -5773,7 +7211,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
5773
7211
|
// eslint-disable-next-line @typescript-eslint/tslint/config
|
|
5774
7212
|
this.lowerCanvas.toBlob(function (blob) {
|
|
5775
7213
|
var blobUrl = URL.createObjectURL(blob);
|
|
5776
|
-
proxy.baseImg.src = blobUrl;
|
|
7214
|
+
//proxy.baseImg.src = blobUrl;
|
|
5777
7215
|
proxy.downloadImg(blobUrl, fileName + '.' + type);
|
|
5778
7216
|
}, 'image/png');
|
|
5779
7217
|
};
|
|
@@ -5823,21 +7261,6 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
5823
7261
|
this.inMemoryContext.putImageData(imgData, 0, 0);
|
|
5824
7262
|
}
|
|
5825
7263
|
};
|
|
5826
|
-
ImageEditor.prototype.drawBaseImg = function () {
|
|
5827
|
-
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
5828
|
-
this.lowerContext.clearRect(0, 0, this.lowerCanvas.height, this.lowerCanvas.width);
|
|
5829
|
-
this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
5830
|
-
this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.height, this.lowerCanvas.width);
|
|
5831
|
-
this.inMemoryCanvas.width = this.lowerCanvas.width = this.imgDataColl[0].value.width;
|
|
5832
|
-
this.inMemoryCanvas.height = this.lowerCanvas.height = this.imgDataColl[0].value.height;
|
|
5833
|
-
this.inMemoryContext.putImageData(this.imgDataColl[0].value, 0, 0);
|
|
5834
|
-
var maxDimension = this.calcMaxDimension(this.inMemoryCanvas.width, this.inMemoryCanvas.height);
|
|
5835
|
-
this.lowerCanvas.style.maxWidth = this.upperCanvas.style.maxWidth = maxDimension.width + 'px';
|
|
5836
|
-
this.lowerCanvas.style.maxHeight = this.upperCanvas.style.maxHeight = maxDimension.height + 'px';
|
|
5837
|
-
this.lowerCanvas.style.left = this.upperCanvas.style.left = (this.element.clientWidth - maxDimension.width) / 2 + 1 + 'px';
|
|
5838
|
-
this.lowerCanvas.style.top = this.upperCanvas.style.top = (this.element.clientHeight - this.toolbarHeight - maxDimension.height) / 2 + 1 + 'px';
|
|
5839
|
-
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
5840
|
-
};
|
|
5841
7264
|
ImageEditor.prototype.calcPrevRatio = function () {
|
|
5842
7265
|
var oldWidthRatio;
|
|
5843
7266
|
var oldHeightRatio;
|
|
@@ -5944,15 +7367,23 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
5944
7367
|
}
|
|
5945
7368
|
else if (degree === 90 || degree === -90) {
|
|
5946
7369
|
this.updateCurrentActiveObjPoint(degree);
|
|
7370
|
+
var tempFilter = this.lowerContext.filter;
|
|
7371
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
7372
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
5947
7373
|
for (var i = 0; i < this.objColl.length; i++) {
|
|
5948
7374
|
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
5949
7375
|
}
|
|
7376
|
+
this.lowerContext.filter = tempFilter;
|
|
5950
7377
|
}
|
|
5951
7378
|
else {
|
|
5952
7379
|
this.updateCurrentActiveObjPoint('zoom');
|
|
7380
|
+
var tempFilter = this.lowerContext.filter;
|
|
7381
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
7382
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
5953
7383
|
for (var i = 0; i < this.objColl.length; i++) {
|
|
5954
7384
|
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
5955
7385
|
}
|
|
7386
|
+
this.lowerContext.filter = tempFilter;
|
|
5956
7387
|
}
|
|
5957
7388
|
}
|
|
5958
7389
|
else if (this.objColl.length === 0 && (degree === 'horizontal' || degree === 'vertical' || degree === 'Horizontal' || degree === 'Vertical')) {
|
|
@@ -6000,12 +7431,14 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6000
7431
|
if (this.objColl[i].activePoint.startX <= this.lowerCanvas.width / 2) {
|
|
6001
7432
|
this.objColl[i].activePoint.startX = this.lowerCanvas.width / 2 + ((this.lowerCanvas.width / 2) -
|
|
6002
7433
|
this.objColl[i].activePoint.endX);
|
|
6003
|
-
this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX +
|
|
7434
|
+
this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX +
|
|
7435
|
+
this.objColl[i].activePoint.width;
|
|
6004
7436
|
this.updateActiveObject(ratio, this.objColl[i].activePoint, this.objColl[i]);
|
|
6005
7437
|
}
|
|
6006
7438
|
else if (this.objColl[i].activePoint.startX >= this.lowerCanvas.width / 2) {
|
|
6007
7439
|
this.objColl[i].activePoint.startX = this.lowerCanvas.width - this.objColl[i].activePoint.endX;
|
|
6008
|
-
this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX +
|
|
7440
|
+
this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX +
|
|
7441
|
+
this.objColl[i].activePoint.width;
|
|
6009
7442
|
this.updateActiveObject(ratio, this.objColl[i].activePoint, this.objColl[i]);
|
|
6010
7443
|
}
|
|
6011
7444
|
}
|
|
@@ -6015,12 +7448,14 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6015
7448
|
if (this.objColl[i].activePoint.startY <= this.lowerCanvas.height / 2) {
|
|
6016
7449
|
this.objColl[i].activePoint.startY = this.lowerCanvas.height / 2 + ((this.lowerCanvas.height / 2) -
|
|
6017
7450
|
this.objColl[i].activePoint.endY);
|
|
6018
|
-
this.objColl[i].activePoint.endY = this.objColl[i].activePoint.startY +
|
|
7451
|
+
this.objColl[i].activePoint.endY = this.objColl[i].activePoint.startY +
|
|
7452
|
+
this.objColl[i].activePoint.height;
|
|
6019
7453
|
this.updateActiveObject(ratio, this.objColl[i].activePoint, this.objColl[i]);
|
|
6020
7454
|
}
|
|
6021
7455
|
else if (this.objColl[i].activePoint.startY >= this.lowerCanvas.height / 2) {
|
|
6022
7456
|
this.objColl[i].activePoint.startY = this.lowerCanvas.height - this.objColl[i].activePoint.endY;
|
|
6023
|
-
this.objColl[i].activePoint.endY = this.objColl[i].activePoint.startY +
|
|
7457
|
+
this.objColl[i].activePoint.endY = this.objColl[i].activePoint.startY +
|
|
7458
|
+
this.objColl[i].activePoint.height;
|
|
6024
7459
|
this.updateActiveObject(ratio, this.objColl[i].activePoint, this.objColl[i]);
|
|
6025
7460
|
}
|
|
6026
7461
|
}
|
|
@@ -6035,22 +7470,30 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6035
7470
|
this.objColl[i].activePoint.startY /= oldRatio.height;
|
|
6036
7471
|
this.objColl[i].activePoint.endX /= oldRatio.width;
|
|
6037
7472
|
this.objColl[i].activePoint.endY /= oldRatio.height;
|
|
6038
|
-
this.objColl[i].activePoint.height = this.objColl[i].activePoint.endX -
|
|
6039
|
-
|
|
7473
|
+
this.objColl[i].activePoint.height = this.objColl[i].activePoint.endX -
|
|
7474
|
+
this.objColl[i].activePoint.startX;
|
|
7475
|
+
this.objColl[i].activePoint.width = this.objColl[i].activePoint.endY -
|
|
7476
|
+
this.objColl[i].activePoint.startY;
|
|
6040
7477
|
this.objColl[i].strokeSettings.strokeWidth /= (oldRatio.width / this.factor);
|
|
6041
7478
|
this.calcCurrPoints(degree, this.objColl[i]);
|
|
6042
|
-
this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX +
|
|
6043
|
-
|
|
6044
|
-
this.objColl[i].activePoint.
|
|
6045
|
-
|
|
7479
|
+
this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX +
|
|
7480
|
+
this.objColl[i].activePoint.width;
|
|
7481
|
+
this.objColl[i].activePoint.endY = this.objColl[i].activePoint.startY +
|
|
7482
|
+
this.objColl[i].activePoint.height;
|
|
7483
|
+
this.objColl[i].activePoint.width = this.objColl[i].activePoint.endX -
|
|
7484
|
+
this.objColl[i].activePoint.startX;
|
|
7485
|
+
this.objColl[i].activePoint.height = this.objColl[i].activePoint.endY -
|
|
7486
|
+
this.objColl[i].activePoint.startY;
|
|
6046
7487
|
}
|
|
6047
7488
|
for (var i = 0; i < this.objColl.length; i++) {
|
|
6048
7489
|
this.objColl[i].activePoint.startX *= oldRatio.width;
|
|
6049
7490
|
this.objColl[i].activePoint.startY *= oldRatio.height;
|
|
6050
7491
|
this.objColl[i].activePoint.endX *= oldRatio.width;
|
|
6051
7492
|
this.objColl[i].activePoint.endY *= oldRatio.height;
|
|
6052
|
-
this.objColl[i].activePoint.width = this.objColl[i].activePoint.endX -
|
|
6053
|
-
|
|
7493
|
+
this.objColl[i].activePoint.width = this.objColl[i].activePoint.endX -
|
|
7494
|
+
this.objColl[i].activePoint.startX;
|
|
7495
|
+
this.objColl[i].activePoint.height = this.objColl[i].activePoint.endY -
|
|
7496
|
+
this.objColl[i].activePoint.startY;
|
|
6054
7497
|
this.objColl[i].strokeSettings.strokeWidth *= ratio.width;
|
|
6055
7498
|
}
|
|
6056
7499
|
for (var i = 0; i < this.objColl.length; i++) {
|
|
@@ -6120,10 +7563,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6120
7563
|
tempObjColl = [];
|
|
6121
7564
|
this.refreshActiveObj();
|
|
6122
7565
|
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
6123
|
-
this.
|
|
6124
|
-
for (var i = 0; i < this.objColl.length; i++) {
|
|
6125
|
-
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
6126
|
-
}
|
|
7566
|
+
this.redrawImgWithObj();
|
|
6127
7567
|
this.activeObj.flippedText = false;
|
|
6128
7568
|
this.currObjType.shape = '';
|
|
6129
7569
|
this.refreshActiveObj();
|
|
@@ -6141,17 +7581,27 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6141
7581
|
showSpinner(proxy_1.element);
|
|
6142
7582
|
proxy_1.element.style.opacity = '0.5';
|
|
6143
7583
|
proxy_1.lowerContext.clearRect(0, 0, proxy_1.lowerCanvas.width, proxy_1.lowerCanvas.height);
|
|
7584
|
+
var temp = proxy_1.lowerContext.filter;
|
|
7585
|
+
proxy_1.lowerContext.filter = proxy_1.initialAdjustmentValue = proxy_1.adjustmentValue = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
7586
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
7587
|
+
if (proxy_1.cssClass) {
|
|
7588
|
+
addClass([proxy_1.element], proxy_1.cssClass.split(' '));
|
|
7589
|
+
}
|
|
6144
7590
|
proxy_1.lowerContext.drawImage(proxy_1.inMemoryCanvas, 0, 0);
|
|
6145
7591
|
proxy_1.baseImg.src = URL.createObjectURL(blob);
|
|
6146
7592
|
proxy_1.upperContext.clearRect(0, 0, proxy_1.upperCanvas.width, proxy_1.upperCanvas.height);
|
|
6147
7593
|
proxy_1.togglePen = false;
|
|
6148
7594
|
proxy_1.upperCanvas.style.cursor = 'default';
|
|
7595
|
+
proxy_1.lowerContext.filter = temp;
|
|
7596
|
+
var tempFilter = proxy_1.lowerContext.filter;
|
|
7597
|
+
proxy_1.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
7598
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
6149
7599
|
for (var i = 0, len = proxy_1.objColl.length; i < len; i++) {
|
|
6150
7600
|
proxy_1.apply(proxy_1.objColl[i].shape, proxy_1.objColl[i], 'duplicate');
|
|
6151
7601
|
}
|
|
7602
|
+
proxy_1.lowerContext.filter = tempFilter;
|
|
6152
7603
|
proxy_1.togglePen = true;
|
|
6153
7604
|
}, 'image/png');
|
|
6154
|
-
this.isUndoRedo = false;
|
|
6155
7605
|
this.degree = 0;
|
|
6156
7606
|
}
|
|
6157
7607
|
else {
|
|
@@ -6166,7 +7616,6 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6166
7616
|
}
|
|
6167
7617
|
this.keyHistory = '';
|
|
6168
7618
|
}
|
|
6169
|
-
this.isUndoRedo = false;
|
|
6170
7619
|
}
|
|
6171
7620
|
}
|
|
6172
7621
|
};
|
|
@@ -6299,6 +7748,9 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6299
7748
|
if (this.activeObj.textSettings.fontSize < 20 * (ratio.width + ratio.height)) {
|
|
6300
7749
|
this.activeObj.textSettings.fontSize = 20 * (ratio.width + ratio.height);
|
|
6301
7750
|
}
|
|
7751
|
+
if (this.factor > 1) {
|
|
7752
|
+
this.activeObj.textSettings.fontSize /= this.factor;
|
|
7753
|
+
}
|
|
6302
7754
|
}
|
|
6303
7755
|
this.activeObj.shapeDegree = this.degree;
|
|
6304
7756
|
this.activeObj.shapeFlip = this.currFlipState;
|
|
@@ -6317,6 +7769,8 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6317
7769
|
this.setCenterPoints(true, width, height);
|
|
6318
7770
|
}
|
|
6319
7771
|
this.addLetter(this.activeObj.textSettings.text);
|
|
7772
|
+
this.objColl.push(this.activeObj);
|
|
7773
|
+
this.redrawShape(this.objColl[this.objColl.length - 1]);
|
|
6320
7774
|
this.refreshToolbar('text');
|
|
6321
7775
|
}
|
|
6322
7776
|
};
|
|
@@ -6390,7 +7844,28 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6390
7844
|
inRange = true;
|
|
6391
7845
|
}
|
|
6392
7846
|
}
|
|
6393
|
-
return inRange;
|
|
7847
|
+
return inRange;
|
|
7848
|
+
};
|
|
7849
|
+
ImageEditor.prototype.updateInMemoryContext = function (imgData, isUpdate) {
|
|
7850
|
+
var temp = extend({}, this.activeObj, {}, true);
|
|
7851
|
+
this.redrawImgWithObj();
|
|
7852
|
+
this.activeObj = temp;
|
|
7853
|
+
if (isNullOrUndefined(isUpdate)) {
|
|
7854
|
+
imgData = this.lowerContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
7855
|
+
}
|
|
7856
|
+
this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
|
|
7857
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
7858
|
+
this.inMemoryCanvas.width = imgData.width;
|
|
7859
|
+
this.inMemoryCanvas.height = imgData.height;
|
|
7860
|
+
this.inMemoryContext.putImageData(imgData, 0, 0);
|
|
7861
|
+
};
|
|
7862
|
+
ImageEditor.prototype.clearActObj = function () {
|
|
7863
|
+
if (this.textBox.style.display === 'none') {
|
|
7864
|
+
this.refreshActiveObj();
|
|
7865
|
+
this.applyActObj();
|
|
7866
|
+
this.refreshActiveObj();
|
|
7867
|
+
this.currObjType.isCustomCrop = false;
|
|
7868
|
+
}
|
|
6394
7869
|
};
|
|
6395
7870
|
ImageEditor.prototype.rotateMultiple = function (length, degree) {
|
|
6396
7871
|
for (var i = 0; i < length; i++) {
|
|
@@ -6403,6 +7878,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6403
7878
|
if (this.degree === 360) {
|
|
6404
7879
|
this.degree = 0;
|
|
6405
7880
|
}
|
|
7881
|
+
var temp = this.lowerContext.filter;
|
|
6406
7882
|
this.lowerContext.save();
|
|
6407
7883
|
this.setMaximumDimension(90 * (i + 1));
|
|
6408
7884
|
this.lowerContext.translate(this.lowerCanvas.width / 2, this.lowerCanvas.height / 2);
|
|
@@ -6414,7 +7890,9 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6414
7890
|
}
|
|
6415
7891
|
this.lowerCanvas.style.left = this.upperCanvas.style.left = (this.element.clientWidth - parseInt(this.lowerCanvas.style.maxWidth, 10) - 18) / 2 + 1 + 'px';
|
|
6416
7892
|
this.lowerCanvas.style.top = this.upperCanvas.style.top = (this.element.clientHeight - this.toolbarHeight - parseInt(this.lowerCanvas.style.maxHeight, 10)) / 2 + 1 + 'px';
|
|
7893
|
+
this.updateBrightnessFilter();
|
|
6417
7894
|
this.lowerContext.drawImage(this.inMemoryCanvas, -this.lowerCanvas.height / 2, -this.lowerCanvas.width / 2);
|
|
7895
|
+
this.lowerContext.filter = temp;
|
|
6418
7896
|
if (degree > 0) {
|
|
6419
7897
|
this.lowerContext.rotate(Math.PI / 180 * -90);
|
|
6420
7898
|
}
|
|
@@ -6428,7 +7906,11 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6428
7906
|
this.inMemoryCanvas.width = this.currImgData.width;
|
|
6429
7907
|
this.inMemoryCanvas.height = this.currImgData.height;
|
|
6430
7908
|
this.inMemoryContext.putImageData(this.currImgData, 0, 0);
|
|
7909
|
+
this.lowerContext.filter = this.canvasFilter;
|
|
7910
|
+
this.updateBrightnessFilter();
|
|
7911
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
6431
7912
|
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
7913
|
+
this.lowerContext.filter = temp;
|
|
6432
7914
|
if (degree > 0) {
|
|
6433
7915
|
this.redrawObj(90);
|
|
6434
7916
|
}
|
|
@@ -6437,6 +7919,415 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6437
7919
|
}
|
|
6438
7920
|
}
|
|
6439
7921
|
};
|
|
7922
|
+
ImageEditor.prototype.setBrightness = function (value) {
|
|
7923
|
+
if (!this.disabled && this.imgDataColl.length > 0) {
|
|
7924
|
+
if (this.currObjType.shape === 'freehanddraw') {
|
|
7925
|
+
this.apply();
|
|
7926
|
+
this.upperCanvas.style.cursor = 'default';
|
|
7927
|
+
this.currObjType.shape = '';
|
|
7928
|
+
}
|
|
7929
|
+
this.clearActObj();
|
|
7930
|
+
this.adjustmentLevel.brightness = value;
|
|
7931
|
+
value = this.getFilterValue(value);
|
|
7932
|
+
this.updateAdjustment('brightness', value);
|
|
7933
|
+
}
|
|
7934
|
+
};
|
|
7935
|
+
ImageEditor.prototype.setContrast = function (value) {
|
|
7936
|
+
if (!this.disabled && this.imgDataColl.length > 0) {
|
|
7937
|
+
if (this.currObjType.shape === 'freehanddraw') {
|
|
7938
|
+
this.apply();
|
|
7939
|
+
this.upperCanvas.style.cursor = 'default';
|
|
7940
|
+
this.currObjType.shape = '';
|
|
7941
|
+
}
|
|
7942
|
+
this.clearActObj();
|
|
7943
|
+
this.adjustmentLevel.contrast = value;
|
|
7944
|
+
value = this.getFilterValue(value);
|
|
7945
|
+
value *= 100;
|
|
7946
|
+
this.updateAdjustment('contrast', value);
|
|
7947
|
+
}
|
|
7948
|
+
};
|
|
7949
|
+
ImageEditor.prototype.setHue = function (value) {
|
|
7950
|
+
if (!this.disabled && this.imgDataColl.length > 0) {
|
|
7951
|
+
if (this.currObjType.shape === 'freehanddraw') {
|
|
7952
|
+
this.apply();
|
|
7953
|
+
this.upperCanvas.style.cursor = 'default';
|
|
7954
|
+
this.currObjType.shape = '';
|
|
7955
|
+
}
|
|
7956
|
+
this.clearActObj();
|
|
7957
|
+
this.adjustmentLevel.hue = value;
|
|
7958
|
+
value *= 3;
|
|
7959
|
+
this.updateAdjustment('hue', value);
|
|
7960
|
+
}
|
|
7961
|
+
};
|
|
7962
|
+
ImageEditor.prototype.setSaturation = function (value) {
|
|
7963
|
+
if (!this.disabled && this.imgDataColl.length > 0) {
|
|
7964
|
+
if (this.currObjType.shape === 'freehanddraw') {
|
|
7965
|
+
this.apply();
|
|
7966
|
+
this.upperCanvas.style.cursor = 'default';
|
|
7967
|
+
this.currObjType.shape = '';
|
|
7968
|
+
}
|
|
7969
|
+
this.clearActObj();
|
|
7970
|
+
this.adjustmentLevel.saturation = value;
|
|
7971
|
+
value = this.getSaturationFilterValue(value);
|
|
7972
|
+
value *= 100;
|
|
7973
|
+
this.updateAdjustment('saturation', value);
|
|
7974
|
+
}
|
|
7975
|
+
};
|
|
7976
|
+
ImageEditor.prototype.setOpacity = function (value) {
|
|
7977
|
+
if (!this.disabled && this.imgDataColl.length > 0) {
|
|
7978
|
+
if (this.currObjType.shape === 'freehanddraw') {
|
|
7979
|
+
this.apply();
|
|
7980
|
+
this.upperCanvas.style.cursor = 'default';
|
|
7981
|
+
this.currObjType.shape = '';
|
|
7982
|
+
}
|
|
7983
|
+
this.clearActObj();
|
|
7984
|
+
this.adjustmentLevel.opacity = value;
|
|
7985
|
+
if (value >= 50) {
|
|
7986
|
+
value /= 100;
|
|
7987
|
+
}
|
|
7988
|
+
else if (value === 40) {
|
|
7989
|
+
value = 0.45;
|
|
7990
|
+
}
|
|
7991
|
+
else if (value === 30) {
|
|
7992
|
+
value = 0.40;
|
|
7993
|
+
}
|
|
7994
|
+
else if (value === 20) {
|
|
7995
|
+
value = 0.35;
|
|
7996
|
+
}
|
|
7997
|
+
else if (value === 10) {
|
|
7998
|
+
value = 0.30;
|
|
7999
|
+
}
|
|
8000
|
+
else if (value === 0) {
|
|
8001
|
+
value = 0.25;
|
|
8002
|
+
}
|
|
8003
|
+
this.updateAdjustment('opacity', value);
|
|
8004
|
+
}
|
|
8005
|
+
};
|
|
8006
|
+
ImageEditor.prototype.setBlur = function (value) {
|
|
8007
|
+
if (!this.disabled && this.imgDataColl.length > 0) {
|
|
8008
|
+
if (this.currObjType.shape === 'freehanddraw') {
|
|
8009
|
+
this.apply();
|
|
8010
|
+
this.upperCanvas.style.cursor = 'default';
|
|
8011
|
+
this.currObjType.shape = '';
|
|
8012
|
+
}
|
|
8013
|
+
this.clearActObj();
|
|
8014
|
+
this.adjustmentLevel.blur = value;
|
|
8015
|
+
value /= 20;
|
|
8016
|
+
this.updateAdjustment('blur', value);
|
|
8017
|
+
}
|
|
8018
|
+
};
|
|
8019
|
+
ImageEditor.prototype.setExposure = function (value) {
|
|
8020
|
+
if (!this.disabled && this.imgDataColl.length > 0) {
|
|
8021
|
+
if (this.currObjType.shape === 'freehanddraw') {
|
|
8022
|
+
this.apply();
|
|
8023
|
+
this.upperCanvas.style.cursor = 'default';
|
|
8024
|
+
this.currObjType.shape = '';
|
|
8025
|
+
}
|
|
8026
|
+
this.clearActObj();
|
|
8027
|
+
this.adjustmentLevel.exposure = value;
|
|
8028
|
+
value = this.getFilterValue(value);
|
|
8029
|
+
this.updateAdjustment('exposure', value);
|
|
8030
|
+
}
|
|
8031
|
+
};
|
|
8032
|
+
ImageEditor.prototype.setFilter = function (type) {
|
|
8033
|
+
if (!this.disabled && this.imgDataColl.length > 0) {
|
|
8034
|
+
if (this.currObjType.shape === 'freehanddraw') {
|
|
8035
|
+
this.apply();
|
|
8036
|
+
this.upperCanvas.style.cursor = 'default';
|
|
8037
|
+
this.currObjType.shape = '';
|
|
8038
|
+
}
|
|
8039
|
+
this.clearActObj();
|
|
8040
|
+
this.updateAdjustment(type, null);
|
|
8041
|
+
}
|
|
8042
|
+
};
|
|
8043
|
+
ImageEditor.prototype.setBlackAndWhiteFilter = function (boolean) {
|
|
8044
|
+
if (!this.disabled && this.imgDataColl.length > 0) {
|
|
8045
|
+
if (this.currObjType.shape === 'freehanddraw') {
|
|
8046
|
+
this.apply();
|
|
8047
|
+
this.upperCanvas.style.cursor = 'default';
|
|
8048
|
+
this.currObjType.shape = '';
|
|
8049
|
+
}
|
|
8050
|
+
this.clearActObj();
|
|
8051
|
+
this.adjustmentLevel.bw = boolean;
|
|
8052
|
+
if (boolean) {
|
|
8053
|
+
if (this.degree === 0 && this.currFlipState === '') {
|
|
8054
|
+
this.replaceBWSharpenData('bw');
|
|
8055
|
+
}
|
|
8056
|
+
else if (this.degree !== 0) {
|
|
8057
|
+
var tempDegree = this.degree;
|
|
8058
|
+
this.rotate(-tempDegree);
|
|
8059
|
+
this.replaceBWSharpenData('bw');
|
|
8060
|
+
this.rotate(tempDegree);
|
|
8061
|
+
this.refreshToolbar('filter');
|
|
8062
|
+
}
|
|
8063
|
+
else if (this.currFlipState !== '') {
|
|
8064
|
+
var tempFlipState = this.currFlipState;
|
|
8065
|
+
this.flip(tempFlipState);
|
|
8066
|
+
this.replaceBWSharpenData('bw');
|
|
8067
|
+
this.flip(tempFlipState);
|
|
8068
|
+
this.refreshToolbar('filter');
|
|
8069
|
+
}
|
|
8070
|
+
var data = this.inMemoryContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
8071
|
+
var imageData = this.getBlackAndWhiteData(data);
|
|
8072
|
+
this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
|
|
8073
|
+
this.inMemoryCanvas.width = imageData.width;
|
|
8074
|
+
this.inMemoryCanvas.height = imageData.height;
|
|
8075
|
+
this.inMemoryContext.putImageData(imageData, 0, 0);
|
|
8076
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
8077
|
+
this.lowerContext.filter = this.canvasFilter;
|
|
8078
|
+
var temp = this.lowerContext.filter;
|
|
8079
|
+
this.updateBrightnessFilter();
|
|
8080
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
8081
|
+
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
8082
|
+
this.lowerContext.filter = temp;
|
|
8083
|
+
}
|
|
8084
|
+
else {
|
|
8085
|
+
if (this.degree === 0 && this.currFlipState === '') {
|
|
8086
|
+
this.updateBWSharpness();
|
|
8087
|
+
}
|
|
8088
|
+
else if (this.degree !== 0) {
|
|
8089
|
+
var tempDegree = this.degree;
|
|
8090
|
+
this.rotate(-tempDegree);
|
|
8091
|
+
this.updateBWSharpness();
|
|
8092
|
+
this.rotate(tempDegree);
|
|
8093
|
+
this.refreshToolbar('filter');
|
|
8094
|
+
if (this.sharpenedImgData) {
|
|
8095
|
+
this.sharpenedImgData = false;
|
|
8096
|
+
}
|
|
8097
|
+
}
|
|
8098
|
+
else if (this.currFlipState !== '') {
|
|
8099
|
+
var tempFlipState = this.currFlipState;
|
|
8100
|
+
this.flip(tempFlipState);
|
|
8101
|
+
this.updateBWSharpness();
|
|
8102
|
+
this.flip(tempFlipState);
|
|
8103
|
+
this.refreshToolbar('filter');
|
|
8104
|
+
if (this.sharpenedImgData) {
|
|
8105
|
+
this.sharpenedImgData = false;
|
|
8106
|
+
}
|
|
8107
|
+
}
|
|
8108
|
+
}
|
|
8109
|
+
}
|
|
8110
|
+
};
|
|
8111
|
+
ImageEditor.prototype.setSharpness = function (boolean) {
|
|
8112
|
+
if (!this.disabled && this.imgDataColl.length > 0) {
|
|
8113
|
+
if (this.currObjType.shape === 'freehanddraw') {
|
|
8114
|
+
this.apply();
|
|
8115
|
+
this.upperCanvas.style.cursor = 'default';
|
|
8116
|
+
this.currObjType.shape = '';
|
|
8117
|
+
}
|
|
8118
|
+
this.clearActObj();
|
|
8119
|
+
this.adjustmentLevel.sharpen = boolean;
|
|
8120
|
+
if (boolean) {
|
|
8121
|
+
if (this.degree === 0 && this.currFlipState === '') {
|
|
8122
|
+
this.replaceBWSharpenData('sharpen');
|
|
8123
|
+
}
|
|
8124
|
+
else if (this.degree !== 0) {
|
|
8125
|
+
var tempDegree = this.degree;
|
|
8126
|
+
this.rotate(-tempDegree);
|
|
8127
|
+
this.replaceBWSharpenData('sharpen');
|
|
8128
|
+
this.rotate(tempDegree);
|
|
8129
|
+
this.refreshToolbar('filter');
|
|
8130
|
+
}
|
|
8131
|
+
else if (this.currFlipState !== '') {
|
|
8132
|
+
var tempFlipState = this.currFlipState;
|
|
8133
|
+
this.flip(tempFlipState);
|
|
8134
|
+
this.replaceBWSharpenData('sharpen');
|
|
8135
|
+
this.flip(tempFlipState);
|
|
8136
|
+
this.refreshToolbar('filter');
|
|
8137
|
+
}
|
|
8138
|
+
var data = this.inMemoryContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
8139
|
+
var imageData = this.getSharpenData(data);
|
|
8140
|
+
this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
|
|
8141
|
+
this.inMemoryCanvas.width = imageData.width;
|
|
8142
|
+
this.inMemoryCanvas.height = imageData.height;
|
|
8143
|
+
this.inMemoryContext.putImageData(imageData, 0, 0);
|
|
8144
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
8145
|
+
this.lowerContext.filter = this.canvasFilter;
|
|
8146
|
+
var temp = this.lowerContext.filter;
|
|
8147
|
+
this.updateBrightnessFilter();
|
|
8148
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
8149
|
+
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
8150
|
+
this.lowerContext.filter = temp;
|
|
8151
|
+
}
|
|
8152
|
+
else {
|
|
8153
|
+
if (this.degree === 0 && this.currFlipState === '') {
|
|
8154
|
+
this.updateBWSharpness();
|
|
8155
|
+
}
|
|
8156
|
+
else if (this.degree !== 0) {
|
|
8157
|
+
var tempDegree = this.degree;
|
|
8158
|
+
this.rotate(-tempDegree);
|
|
8159
|
+
this.updateBWSharpness();
|
|
8160
|
+
this.rotate(tempDegree);
|
|
8161
|
+
this.refreshToolbar('filter');
|
|
8162
|
+
if (this.sharpenedImgData) {
|
|
8163
|
+
this.sharpenedImgData = false;
|
|
8164
|
+
}
|
|
8165
|
+
}
|
|
8166
|
+
else if (this.currFlipState !== '') {
|
|
8167
|
+
var tempFlipState = this.currFlipState;
|
|
8168
|
+
this.flip(tempFlipState);
|
|
8169
|
+
this.updateBWSharpness();
|
|
8170
|
+
this.flip(tempFlipState);
|
|
8171
|
+
this.refreshToolbar('filter');
|
|
8172
|
+
if (this.sharpenedImgData) {
|
|
8173
|
+
this.sharpenedImgData = false;
|
|
8174
|
+
}
|
|
8175
|
+
}
|
|
8176
|
+
}
|
|
8177
|
+
}
|
|
8178
|
+
};
|
|
8179
|
+
ImageEditor.prototype.replaceBWSharpenData = function (type) {
|
|
8180
|
+
this.tempImageData = this.inMemoryContext.getImageData(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
|
|
8181
|
+
var imageData = this.inMemoryContext.getImageData(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
|
|
8182
|
+
if (type === 'sharpen') {
|
|
8183
|
+
imageData = this.getSharpenData(this.tempImageData);
|
|
8184
|
+
}
|
|
8185
|
+
else {
|
|
8186
|
+
imageData = this.getBlackAndWhiteData(imageData);
|
|
8187
|
+
}
|
|
8188
|
+
this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
|
|
8189
|
+
this.inMemoryCanvas.width = imageData.width;
|
|
8190
|
+
this.inMemoryCanvas.height = imageData.height;
|
|
8191
|
+
this.inMemoryContext.putImageData(imageData, 0, 0);
|
|
8192
|
+
var tempObj;
|
|
8193
|
+
for (var index = 0; index < this.imgDataColl.length; index++) {
|
|
8194
|
+
if (this.imgDataColl[index].operation !== 'freehanddraw') {
|
|
8195
|
+
tempObj = this.imgDataColl[index];
|
|
8196
|
+
break;
|
|
8197
|
+
}
|
|
8198
|
+
}
|
|
8199
|
+
this.imgDataColl.splice(0, 1, { operation: 'updateCanvas', value: imageData });
|
|
8200
|
+
this.imgDataColl.splice(1, 1, tempObj);
|
|
8201
|
+
this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
|
|
8202
|
+
this.inMemoryCanvas.width = this.tempImageData.width;
|
|
8203
|
+
this.inMemoryCanvas.height = this.tempImageData.height;
|
|
8204
|
+
this.inMemoryContext.putImageData(this.tempImageData, 0, 0);
|
|
8205
|
+
};
|
|
8206
|
+
ImageEditor.prototype.updateBWSharpness = function () {
|
|
8207
|
+
this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
|
|
8208
|
+
this.inMemoryCanvas.width = this.tempImageData.width;
|
|
8209
|
+
this.inMemoryCanvas.height = this.tempImageData.height;
|
|
8210
|
+
this.inMemoryContext.putImageData(this.tempImageData, 0, 0);
|
|
8211
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
8212
|
+
this.lowerContext.filter = this.canvasFilter;
|
|
8213
|
+
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
8214
|
+
this.imgDataColl.shift();
|
|
8215
|
+
};
|
|
8216
|
+
ImageEditor.prototype.getSharpenData = function (imageData) {
|
|
8217
|
+
var data = imageData.data;
|
|
8218
|
+
var weights = [0, -1, 0, -1, 5, -1, 0, -1, 0];
|
|
8219
|
+
var side = Math.round(Math.sqrt(weights.length));
|
|
8220
|
+
var halfSide = Math.floor(side / 2);
|
|
8221
|
+
var sw = imageData.width;
|
|
8222
|
+
var sh = imageData.height;
|
|
8223
|
+
var output = this.inMemoryContext.createImageData(sw, sh);
|
|
8224
|
+
var dst = output.data;
|
|
8225
|
+
// go through the destination image pixels
|
|
8226
|
+
var alphaFac = 0;
|
|
8227
|
+
var r;
|
|
8228
|
+
var g;
|
|
8229
|
+
var b;
|
|
8230
|
+
var a;
|
|
8231
|
+
var dstOff;
|
|
8232
|
+
var scx;
|
|
8233
|
+
var scy;
|
|
8234
|
+
var srcOff;
|
|
8235
|
+
var wt;
|
|
8236
|
+
var x;
|
|
8237
|
+
var y;
|
|
8238
|
+
var cx;
|
|
8239
|
+
var cy;
|
|
8240
|
+
for (y = 0; y < sh; y++) {
|
|
8241
|
+
for (x = 0; x < sw; x++) {
|
|
8242
|
+
dstOff = (y * sw + x) * 4;
|
|
8243
|
+
r = 0;
|
|
8244
|
+
g = 0;
|
|
8245
|
+
b = 0;
|
|
8246
|
+
a = 0;
|
|
8247
|
+
for (cy = 0; cy < side; cy++) {
|
|
8248
|
+
for (cx = 0; cx < side; cx++) {
|
|
8249
|
+
scy = y + cy - halfSide;
|
|
8250
|
+
scx = x + cx - halfSide;
|
|
8251
|
+
if (scy < 0 || scy >= sh || scx < 0 || scx >= sw) {
|
|
8252
|
+
continue;
|
|
8253
|
+
}
|
|
8254
|
+
srcOff = (scy * sw + scx) * 4;
|
|
8255
|
+
wt = weights[cy * side + cx];
|
|
8256
|
+
r += data[srcOff] * wt;
|
|
8257
|
+
g += data[srcOff + 1] * wt;
|
|
8258
|
+
b += data[srcOff + 2] * wt;
|
|
8259
|
+
if (!alphaFac) {
|
|
8260
|
+
a += data[srcOff + 3] * wt;
|
|
8261
|
+
}
|
|
8262
|
+
}
|
|
8263
|
+
}
|
|
8264
|
+
dst[dstOff] = r;
|
|
8265
|
+
dst[dstOff + 1] = g;
|
|
8266
|
+
dst[dstOff + 2] = b;
|
|
8267
|
+
if (!alphaFac) {
|
|
8268
|
+
dst[dstOff + 3] = a;
|
|
8269
|
+
}
|
|
8270
|
+
else {
|
|
8271
|
+
dst[dstOff + 3] = data[dstOff + 3];
|
|
8272
|
+
}
|
|
8273
|
+
}
|
|
8274
|
+
}
|
|
8275
|
+
return output;
|
|
8276
|
+
};
|
|
8277
|
+
ImageEditor.prototype.getFilterValue = function (value) {
|
|
8278
|
+
var filterValue;
|
|
8279
|
+
if (value === 0) {
|
|
8280
|
+
filterValue = 1;
|
|
8281
|
+
}
|
|
8282
|
+
else {
|
|
8283
|
+
filterValue = 1 + ((value * 0.5) / 100);
|
|
8284
|
+
}
|
|
8285
|
+
return filterValue;
|
|
8286
|
+
};
|
|
8287
|
+
ImageEditor.prototype.setFilterValue = function (value) {
|
|
8288
|
+
var filterValue;
|
|
8289
|
+
if (value === 1) {
|
|
8290
|
+
filterValue = 0;
|
|
8291
|
+
}
|
|
8292
|
+
else {
|
|
8293
|
+
filterValue = ((value - 1) * 100) / 0.5;
|
|
8294
|
+
}
|
|
8295
|
+
return Math.round(filterValue);
|
|
8296
|
+
};
|
|
8297
|
+
ImageEditor.prototype.getSaturationFilterValue = function (value) {
|
|
8298
|
+
var filterValue;
|
|
8299
|
+
if (value === 0) {
|
|
8300
|
+
filterValue = 1;
|
|
8301
|
+
}
|
|
8302
|
+
else {
|
|
8303
|
+
filterValue = 1 + (value / 100);
|
|
8304
|
+
}
|
|
8305
|
+
return filterValue;
|
|
8306
|
+
};
|
|
8307
|
+
ImageEditor.prototype.setSaturationFilterValue = function (value) {
|
|
8308
|
+
var filterValue;
|
|
8309
|
+
if (value === 1) {
|
|
8310
|
+
filterValue = 0;
|
|
8311
|
+
}
|
|
8312
|
+
else {
|
|
8313
|
+
filterValue = (value - 1) * 100;
|
|
8314
|
+
}
|
|
8315
|
+
return Math.round(filterValue);
|
|
8316
|
+
};
|
|
8317
|
+
ImageEditor.prototype.getBlackAndWhiteData = function (imageData) {
|
|
8318
|
+
for (var i = 0; i < imageData.data.length; i += 4) {
|
|
8319
|
+
var count = imageData.data[i] + imageData.data[i + 1] + imageData.data[i + 2];
|
|
8320
|
+
var colour = 0;
|
|
8321
|
+
if (count > 383) {
|
|
8322
|
+
colour = 255;
|
|
8323
|
+
}
|
|
8324
|
+
imageData.data[i] = colour;
|
|
8325
|
+
imageData.data[i + 1] = colour;
|
|
8326
|
+
imageData.data[i + 2] = colour;
|
|
8327
|
+
imageData.data[i + 3] = 255;
|
|
8328
|
+
}
|
|
8329
|
+
return imageData;
|
|
8330
|
+
};
|
|
6440
8331
|
/**
|
|
6441
8332
|
* Clear a current selection.
|
|
6442
8333
|
*
|
|
@@ -6473,11 +8364,22 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6473
8364
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
6474
8365
|
var proxy_2 = this;
|
|
6475
8366
|
isCrop = true;
|
|
8367
|
+
var canvasFilter = this.canvasFilter;
|
|
8368
|
+
var tempActObj = extend({}, this.activeObj, {}, true);
|
|
8369
|
+
this.lowerContext.filter = this.canvasFilter = 'none';
|
|
8370
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
8371
|
+
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
8372
|
+
for (var j = 0; j < this.objColl.length; j++) {
|
|
8373
|
+
this.apply(this.objColl[j].shape, this.objColl[j]);
|
|
8374
|
+
this.refreshActiveObj();
|
|
8375
|
+
}
|
|
8376
|
+
this.activeObj = tempActObj;
|
|
6476
8377
|
this.upperCanvas.style.display = 'none';
|
|
6477
8378
|
var widthRatio = void 0;
|
|
6478
8379
|
var heightRatio = void 0;
|
|
6479
8380
|
var imgData = void 0;
|
|
6480
8381
|
var zoomedRotate = false;
|
|
8382
|
+
var factor = this.factor;
|
|
6481
8383
|
if (this.factor === 1) {
|
|
6482
8384
|
imgData = this.lowerContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
6483
8385
|
widthRatio = this.lowerCanvas.width / parseInt(this.lowerCanvas.style.maxWidth, 10);
|
|
@@ -6512,6 +8414,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6512
8414
|
this.updateInMemoryContext(imgData);
|
|
6513
8415
|
}
|
|
6514
8416
|
this.degree = 0;
|
|
8417
|
+
this.updateBrightnessFilter();
|
|
6515
8418
|
this.lowerContext.drawImage(this.inMemoryCanvas, tempObj.activePoint.startX, tempObj.activePoint.startY, tempObj.activePoint.width, tempObj.activePoint.height, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
6516
8419
|
}
|
|
6517
8420
|
if (this.flipState !== '') {
|
|
@@ -6526,6 +8429,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6526
8429
|
this.lowerCanvas.style.maxHeight = this.upperCanvas.style.maxHeight = maxDimension.height + 'px';
|
|
6527
8430
|
this.lowerCanvas.width = this.upperCanvas.width = maxDimension.width * widthRatio;
|
|
6528
8431
|
this.lowerCanvas.height = this.upperCanvas.height = maxDimension.height * heightRatio;
|
|
8432
|
+
this.updateBrightnessFilter();
|
|
6529
8433
|
this.lowerContext.drawImage(this.inMemoryCanvas, tempObj.activePoint.startX, tempObj.activePoint.startY, tempObj.activePoint.width, tempObj.activePoint.height, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
6530
8434
|
}
|
|
6531
8435
|
}
|
|
@@ -6546,6 +8450,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6546
8450
|
((this.element.clientWidth - parseInt(cssObj.width, 10) - 18) / 2) + 1 + 'px';
|
|
6547
8451
|
this.lowerCanvas.style.top = this.upperCanvas.style.top = ((this.element.clientHeight - this.toolbarHeight
|
|
6548
8452
|
- parseInt(cssObj.height, 10)) / 2) + 1 + 'px';
|
|
8453
|
+
this.updateBrightnessFilter();
|
|
6549
8454
|
this.lowerContext.drawImage(this.inMemoryCanvas, this.activeObj.activePoint.startX, this.activeObj.activePoint.startY, this.activeObj.activePoint.width, this.activeObj.activePoint.height, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
6550
8455
|
}
|
|
6551
8456
|
if (this.activeObj.shape === 'crop-circle') {
|
|
@@ -6554,6 +8459,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6554
8459
|
this.inMemoryCanvas.height = imgData_1.height;
|
|
6555
8460
|
this.inMemoryContext.putImageData(imgData_1, 0, 0);
|
|
6556
8461
|
this.lowerContext.save();
|
|
8462
|
+
this.updateBrightnessFilter();
|
|
6557
8463
|
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0, this.baseImg.width, this.baseImg.height);
|
|
6558
8464
|
this.lowerContext.globalCompositeOperation = 'destination-in';
|
|
6559
8465
|
this.lowerContext.beginPath();
|
|
@@ -6566,18 +8472,11 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6566
8472
|
showSpinner(this.element);
|
|
6567
8473
|
this.element.style.opacity = '0.5';
|
|
6568
8474
|
var blobUrl_1;
|
|
6569
|
-
var data_1;
|
|
6570
8475
|
// eslint-disable-next-line @typescript-eslint/tslint/config
|
|
6571
8476
|
this.lowerCanvas.toBlob(function (blob) {
|
|
6572
8477
|
blobUrl_1 = URL.createObjectURL(blob);
|
|
6573
|
-
proxy_2.isUndoRedo = false;
|
|
6574
8478
|
proxy_2.baseImg.src = blobUrl_1;
|
|
6575
|
-
data_1 = proxy_2.lowerContext.getImageData(0, 0, proxy_2.lowerCanvas.width, proxy_2.lowerCanvas.height);
|
|
6576
8479
|
proxy_2.imgDataColl = [];
|
|
6577
|
-
if (!proxy_2.isUndoRedo) {
|
|
6578
|
-
proxy_2.updateUndoRedoColl('crop', data_1, proxy_2.objColl);
|
|
6579
|
-
}
|
|
6580
|
-
proxy_2.isUndoRedo = false;
|
|
6581
8480
|
}, 'image/png');
|
|
6582
8481
|
this.objColl = [];
|
|
6583
8482
|
this.refreshActiveObj();
|
|
@@ -6586,26 +8485,11 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6586
8485
|
this.upperContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
6587
8486
|
this.lowerContext.globalAlpha = 0;
|
|
6588
8487
|
this.lowerContext.fillRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
6589
|
-
this.lowerContext.setTransform(1, 0, 0, 1, 0, 0);
|
|
6590
|
-
this.upperContext.setTransform(1, 0, 0, 1, 0, 0);
|
|
6591
8488
|
this.factor = 1;
|
|
8489
|
+
this.canvasFilter = canvasFilter;
|
|
6592
8490
|
}
|
|
6593
8491
|
return isCrop;
|
|
6594
8492
|
};
|
|
6595
|
-
ImageEditor.prototype.updateInMemoryContext = function (imgData) {
|
|
6596
|
-
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
6597
|
-
var temp = extend({}, this.activeObj, {}, true);
|
|
6598
|
-
for (var i = 0; i < this.objColl.length; i++) {
|
|
6599
|
-
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
6600
|
-
}
|
|
6601
|
-
this.activeObj = temp;
|
|
6602
|
-
imgData = this.lowerContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
6603
|
-
this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
|
|
6604
|
-
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
6605
|
-
this.inMemoryCanvas.width = imgData.width;
|
|
6606
|
-
this.inMemoryCanvas.height = imgData.height;
|
|
6607
|
-
this.inMemoryContext.putImageData(imgData, 0, 0);
|
|
6608
|
-
};
|
|
6609
8493
|
/**
|
|
6610
8494
|
* Flips an image by horizontally or vertically.
|
|
6611
8495
|
*
|
|
@@ -6622,8 +8506,8 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6622
8506
|
}
|
|
6623
8507
|
var transitionArgs = { direction: direction };
|
|
6624
8508
|
this.trigger('flipping', transitionArgs);
|
|
6625
|
-
this.
|
|
6626
|
-
|
|
8509
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
8510
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
6627
8511
|
var splitWords = [];
|
|
6628
8512
|
var activeObjShape = void 0;
|
|
6629
8513
|
if (!isNullOrUndefined(this.activeObj.activePoint)) {
|
|
@@ -6644,7 +8528,6 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6644
8528
|
this.lowerContext.scale(-1, 1);
|
|
6645
8529
|
this.upperContext.translate(this.upperContext.canvas.width, 0);
|
|
6646
8530
|
this.upperContext.scale(-1, 1);
|
|
6647
|
-
this.flipDirection = 'horizontal';
|
|
6648
8531
|
if (this.flipState === '' || this.flipState.toLowerCase() === 'vertical') {
|
|
6649
8532
|
this.flipState = 'horizontal';
|
|
6650
8533
|
}
|
|
@@ -6660,7 +8543,6 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6660
8543
|
this.lowerContext.scale(1, -1);
|
|
6661
8544
|
this.upperContext.translate(0, this.upperContext.canvas.height);
|
|
6662
8545
|
this.upperContext.scale(1, -1);
|
|
6663
|
-
this.flipDirection = 'vertical';
|
|
6664
8546
|
if (this.flipState.toLowerCase() === '' || this.flipState.toLowerCase() === 'horizontal') {
|
|
6665
8547
|
this.flipState = 'vertical';
|
|
6666
8548
|
}
|
|
@@ -6671,13 +8553,25 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6671
8553
|
this.currFlipState = 'vertical';
|
|
6672
8554
|
}
|
|
6673
8555
|
}
|
|
8556
|
+
var temp = this.lowerContext.filter;
|
|
8557
|
+
this.updateBrightnessFilter();
|
|
8558
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
6674
8559
|
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
8560
|
+
this.lowerContext.filter = temp;
|
|
6675
8561
|
this.currImgData = this.lowerContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
8562
|
+
this.lowerContext.filter = this.canvasFilter;
|
|
8563
|
+
this.updateBrightnessFilter();
|
|
8564
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
8565
|
+
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
8566
|
+
this.lowerContext.filter = temp;
|
|
6676
8567
|
this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
6677
8568
|
this.inMemoryCanvas.width = this.currImgData.width;
|
|
6678
8569
|
this.inMemoryCanvas.height = this.currImgData.height;
|
|
6679
8570
|
this.inMemoryContext.putImageData(this.currImgData, 0, 0);
|
|
6680
8571
|
if (this.flipState.toLowerCase() === 'horizontal') {
|
|
8572
|
+
var tempFilter = this.lowerContext.filter;
|
|
8573
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
8574
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
6681
8575
|
for (var i = 0, len = this.objColl.length; i < len; i++) {
|
|
6682
8576
|
this.objColl[i].flippedText = false;
|
|
6683
8577
|
if (this.objColl[i].shapeFlip !== '' && this.objColl[i].shapeFlip === this.currFlipState) {
|
|
@@ -6687,13 +8581,16 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6687
8581
|
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
6688
8582
|
}
|
|
6689
8583
|
}
|
|
8584
|
+
this.lowerContext.filter = tempFilter;
|
|
6690
8585
|
this.lowerContext.translate(this.lowerContext.canvas.width, 0);
|
|
6691
8586
|
this.lowerContext.scale(-1, 1);
|
|
6692
8587
|
this.upperContext.translate(this.upperContext.canvas.width, 0);
|
|
6693
8588
|
this.upperContext.scale(-1, 1);
|
|
6694
|
-
this.flipDirection = '';
|
|
6695
8589
|
}
|
|
6696
8590
|
else if (this.flipState.toLowerCase() === 'vertical') {
|
|
8591
|
+
var tempFilter = this.lowerContext.filter;
|
|
8592
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
8593
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
6697
8594
|
for (var i = 0, len = this.objColl.length; i < len; i++) {
|
|
6698
8595
|
this.objColl[i].flippedText = false;
|
|
6699
8596
|
if (this.objColl[i].shapeFlip !== '' && this.objColl[i].shapeFlip === this.currFlipState) {
|
|
@@ -6703,11 +8600,11 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6703
8600
|
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
6704
8601
|
}
|
|
6705
8602
|
}
|
|
8603
|
+
this.lowerContext.filter = tempFilter;
|
|
6706
8604
|
this.lowerContext.translate(0, this.lowerContext.canvas.height);
|
|
6707
8605
|
this.lowerContext.scale(1, -1);
|
|
6708
8606
|
this.upperContext.translate(0, this.upperContext.canvas.height);
|
|
6709
8607
|
this.upperContext.scale(1, -1);
|
|
6710
|
-
this.flipDirection = '';
|
|
6711
8608
|
}
|
|
6712
8609
|
for (var i = 0, len = this.objColl.length; i < len; i++) {
|
|
6713
8610
|
if (this.objColl[i].flipObjColl.length === 0) {
|
|
@@ -6722,15 +8619,15 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6722
8619
|
}
|
|
6723
8620
|
this.redrawObj(direction.toLowerCase());
|
|
6724
8621
|
if (this.flipState === '') {
|
|
8622
|
+
var tempFilter = this.lowerContext.filter;
|
|
8623
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
8624
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
6725
8625
|
for (var i = 0, len = this.objColl.length; i < len; i++) {
|
|
6726
8626
|
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
6727
8627
|
}
|
|
8628
|
+
this.lowerContext.filter = tempFilter;
|
|
6728
8629
|
}
|
|
6729
8630
|
this.refreshActiveObj();
|
|
6730
|
-
if (!this.isUndoRedo) {
|
|
6731
|
-
this.updateUndoRedoColl('flip', direction, this.objColl);
|
|
6732
|
-
}
|
|
6733
|
-
this.isUndoRedo = this.flipMethod = false;
|
|
6734
8631
|
if (!isNullOrUndefined(activeObjShape)) {
|
|
6735
8632
|
if (activeObjShape === 'custom') {
|
|
6736
8633
|
this.activeObj.activePoint = { startX: 0, startY: 0, endX: this.lowerCanvas.width,
|
|
@@ -6742,6 +8639,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6742
8639
|
this.select(activeObjShape);
|
|
6743
8640
|
}
|
|
6744
8641
|
}
|
|
8642
|
+
this.refreshToolbar('main');
|
|
6745
8643
|
}
|
|
6746
8644
|
};
|
|
6747
8645
|
/**
|
|
@@ -6762,11 +8660,13 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6762
8660
|
*/
|
|
6763
8661
|
ImageEditor.prototype.open = function (data) {
|
|
6764
8662
|
if (!this.disabled) {
|
|
8663
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
8664
|
+
var proxy_3 = this;
|
|
6765
8665
|
showSpinner(this.element);
|
|
6766
8666
|
this.element.style.opacity = '0.5';
|
|
6767
|
-
var
|
|
6768
|
-
if (
|
|
6769
|
-
|
|
8667
|
+
var toolbar_11 = document.querySelector('#' + this.element.id + '_currPos');
|
|
8668
|
+
if (toolbar_11) {
|
|
8669
|
+
toolbar_11.style.display = 'none';
|
|
6770
8670
|
}
|
|
6771
8671
|
if (this.defToolbarItems.length === 0 &&
|
|
6772
8672
|
(isNullOrUndefined(document.getElementById(this.element.id + '_toolbar')))) {
|
|
@@ -6775,11 +8675,16 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6775
8675
|
if (isNullOrUndefined(this.toolbarTemplate)) {
|
|
6776
8676
|
this.update();
|
|
6777
8677
|
}
|
|
8678
|
+
this.degree = 0;
|
|
8679
|
+
this.flipState = '';
|
|
8680
|
+
this.factor = 1;
|
|
8681
|
+
this.imgDataColl = [];
|
|
6778
8682
|
var type = typeof (data);
|
|
6779
8683
|
if (type === 'string') {
|
|
6780
8684
|
this.imageOnLoad(data);
|
|
6781
8685
|
}
|
|
6782
8686
|
else {
|
|
8687
|
+
var tempFilter = this.lowerContext.filter;
|
|
6783
8688
|
this.lowerCanvas = document.querySelector('#' + this.element.id + '_lowerCanvas');
|
|
6784
8689
|
this.upperCanvas = document.querySelector('#' + this.element.id + '_upperCanvas');
|
|
6785
8690
|
this.lowerContext = this.lowerCanvas.getContext('2d');
|
|
@@ -6793,10 +8698,19 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6793
8698
|
this.imgDataColl.push({ operation: 'open', value: data });
|
|
6794
8699
|
this.lowerCanvas.width = this.upperCanvas.width = data.width;
|
|
6795
8700
|
this.lowerCanvas.height = this.upperCanvas.height = data.height;
|
|
8701
|
+
this.lowerContext.filter = tempFilter;
|
|
8702
|
+
var temp = this.lowerContext.filter;
|
|
8703
|
+
this.updateBrightnessFilter();
|
|
6796
8704
|
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
6797
|
-
this.
|
|
8705
|
+
this.lowerContext.filter = temp;
|
|
8706
|
+
this.redrawImg(this.lowerContext.filter);
|
|
6798
8707
|
hideSpinner(this.element);
|
|
6799
8708
|
this.element.style.opacity = '1';
|
|
8709
|
+
// eslint-disable-next-line @typescript-eslint/tslint/config
|
|
8710
|
+
this.lowerCanvas.toBlob(function (blob) {
|
|
8711
|
+
showSpinner(proxy_3.element);
|
|
8712
|
+
proxy_3.baseImg.src = URL.createObjectURL(blob);
|
|
8713
|
+
}, 'image/png');
|
|
6800
8714
|
}
|
|
6801
8715
|
}
|
|
6802
8716
|
};
|
|
@@ -6813,6 +8727,8 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6813
8727
|
this.lowerContext.clearRect(0, 0, this.inMemoryCanvas.height, this.inMemoryCanvas.width);
|
|
6814
8728
|
this.upperContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
|
|
6815
8729
|
this.upperContext.clearRect(0, 0, this.inMemoryCanvas.height, this.inMemoryCanvas.width);
|
|
8730
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
8731
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
6816
8732
|
showSpinner(this.element);
|
|
6817
8733
|
this.element.style.opacity = '0.5';
|
|
6818
8734
|
if (this.imgDataColl.length > 0) {
|
|
@@ -6823,11 +8739,13 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6823
8739
|
this.inMemoryCanvas.width = this.imgDataColl[0].value.width;
|
|
6824
8740
|
this.inMemoryCanvas.height = this.imgDataColl[0].value.height;
|
|
6825
8741
|
this.inMemoryContext.putImageData(this.imgDataColl[0].value, 0, 0);
|
|
6826
|
-
this.redrawImg();
|
|
8742
|
+
this.redrawImg(this.lowerContext.filter);
|
|
8743
|
+
this.lowerCanvas.width = this.baseImg.width;
|
|
8744
|
+
this.lowerCanvas.height = this.baseImg.height;
|
|
6827
8745
|
}
|
|
6828
8746
|
this.lowerContext.setTransform(1, 0, 0, 1, 0, 0);
|
|
6829
8747
|
this.upperContext.setTransform(1, 0, 0, 1, 0, 0);
|
|
6830
|
-
this.baseImg.src = this.baseImgSrc;
|
|
8748
|
+
this.baseImg.src = this.baseImgSrc.id;
|
|
6831
8749
|
this.factor = 1;
|
|
6832
8750
|
this.refreshToolbar('main');
|
|
6833
8751
|
if (Browser.isDevice && document.getElementById(this.element.id + '_bottomToolbar')) {
|
|
@@ -6836,22 +8754,20 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6836
8754
|
this.objColl = [];
|
|
6837
8755
|
this.imgDataColl = [];
|
|
6838
8756
|
this.degree = 0;
|
|
6839
|
-
this.flipState = this.keyHistory = this.currFlipState =
|
|
8757
|
+
this.flipState = this.keyHistory = this.currFlipState = '';
|
|
6840
8758
|
this.upperCanvas.style.display = 'none';
|
|
8759
|
+
this.togglePan = this.togglePen = false;
|
|
6841
8760
|
this.upperCanvas.style.cursor = this.lowerCanvas.style.cursor = 'default';
|
|
6842
|
-
this.
|
|
6843
|
-
this.dragCanvas = this.dragged = this.isUndoRedo = this.activeObj.flippedText = this.flipMethod = false;
|
|
8761
|
+
this.dragCanvas = this.activeObj.flippedText = false;
|
|
6844
8762
|
this.currImgData = {};
|
|
6845
8763
|
this.pannStart = { startX: 0, startY: 0, width: 0, height: 0 };
|
|
6846
8764
|
this.pannEnd = { startX: 0, startY: 0, width: 0, height: 0 };
|
|
6847
8765
|
this.lowerContext.lineWidth = this.upperContext.lineWidth = undefined;
|
|
6848
|
-
this.togglePan = this.togglePen = this.rotateMethod = false;
|
|
6849
8766
|
this.lastX = this.lastY = 0;
|
|
6850
8767
|
this.dragStart = { x: 0, y: 0 };
|
|
6851
8768
|
this.touchEndPoint = {};
|
|
6852
8769
|
this.prevX = this.currX = this.prevY = this.currY = 0;
|
|
6853
|
-
this.
|
|
6854
|
-
this.isBoldbtn = this.isItalicbtn = false;
|
|
8770
|
+
this.tempKeyHistory = '';
|
|
6855
8771
|
this.currentToolbar = 'main';
|
|
6856
8772
|
this.textStartPoints = { x: 0, y: 0 };
|
|
6857
8773
|
this.fontSizeColl = this.penDrawColl = [];
|
|
@@ -6861,14 +8777,24 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6861
8777
|
this.textSettings =
|
|
6862
8778
|
{ text: 'Enter Text', fontFamily: 'Arial', fontSize: null, bold: false, italic: false, underline: false };
|
|
6863
8779
|
this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null };
|
|
6864
|
-
this.penStrokeWidth = undefined;
|
|
6865
8780
|
this.tempTextSettings =
|
|
6866
8781
|
{ text: 'Enter Text', fontFamily: 'Arial', fontSize: null, bold: false, italic: false, underline: false };
|
|
6867
8782
|
this.refreshActiveObj();
|
|
6868
8783
|
this.timer = undefined;
|
|
8784
|
+
this.penStrokeWidth = undefined;
|
|
6869
8785
|
this.isScreenOriented = false;
|
|
8786
|
+
this.tempObjColl = [];
|
|
8787
|
+
this.tempObjColl = undefined;
|
|
8788
|
+
this.adjustmentLevel = { brightness: 0, contrast: 0, hue: 0, opacity: 100, saturation: 0, blur: 0, exposure: 0, sharpen: false, bw: false };
|
|
8789
|
+
this.tempAdjustmentLevel = { brightness: 0, contrast: 0, hue: 0, opacity: 100, saturation: 0, blur: 0, exposure: 0, sharpen: false, bw: false };
|
|
8790
|
+
this.canvasFilter = this.currentFilter = this.tempAdjustmentValue = '';
|
|
8791
|
+
this.lowerContext.filter = this.initialAdjustmentValue = this.adjustmentValue = 'brightness(' + 1 + ') ' + 'contrast(' + 100
|
|
8792
|
+
+ '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
8793
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
8794
|
+
this.tempImageData = undefined;
|
|
8795
|
+
this.sharpenedImgData = this.isBrightnessAdjusted = this.isInitialLoading = false;
|
|
6870
8796
|
this.currObjType = { shape: '', isDragging: false, isActiveObj: false, isText: false, isInitialText: false, isLine: false,
|
|
6871
|
-
isInitialLine: false, isCustomCrop: false, isZoomed: false };
|
|
8797
|
+
isInitialLine: false, isCustomCrop: false, isZoomed: false, isFiltered: false, isSave: false };
|
|
6872
8798
|
}
|
|
6873
8799
|
};
|
|
6874
8800
|
/**
|
|
@@ -6896,7 +8822,6 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6896
8822
|
}
|
|
6897
8823
|
}
|
|
6898
8824
|
this.redrawActObj();
|
|
6899
|
-
var factor = this.factor;
|
|
6900
8825
|
if (this.factor !== 1) {
|
|
6901
8826
|
this.lowerContext.setTransform(1, 0, 0, 1, 0, 0);
|
|
6902
8827
|
this.upperContext.setTransform(1, 0, 0, 1, 0, 0);
|
|
@@ -6912,13 +8837,16 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6912
8837
|
if (this.degree === 360) {
|
|
6913
8838
|
this.degree = 0;
|
|
6914
8839
|
}
|
|
8840
|
+
var temp = this.lowerContext.filter;
|
|
6915
8841
|
this.lowerContext.save();
|
|
6916
8842
|
this.setMaximumDimension(this.degree);
|
|
6917
8843
|
this.lowerContext.translate(this.lowerCanvas.width / 2, this.lowerCanvas.height / 2);
|
|
6918
8844
|
this.lowerContext.rotate(Math.PI / 180 * degree);
|
|
6919
8845
|
this.lowerCanvas.style.left = this.upperCanvas.style.left = (this.element.clientWidth - parseInt(this.lowerCanvas.style.maxWidth, 10) - 18) / 2 + 1 + 'px';
|
|
6920
8846
|
this.lowerCanvas.style.top = this.upperCanvas.style.top = (this.element.clientHeight - this.toolbarHeight - parseInt(this.lowerCanvas.style.maxHeight, 10)) / 2 + 1 + 'px';
|
|
8847
|
+
this.updateBrightnessFilter();
|
|
6921
8848
|
this.lowerContext.drawImage(this.inMemoryCanvas, -this.lowerCanvas.height / 2, -this.lowerCanvas.width / 2);
|
|
8849
|
+
this.lowerContext.filter = temp;
|
|
6922
8850
|
this.lowerContext.rotate(Math.PI / 180 * -degree);
|
|
6923
8851
|
this.lowerContext.translate(-this.lowerCanvas.width / 2, -this.lowerCanvas.height / 2);
|
|
6924
8852
|
this.lowerContext.restore();
|
|
@@ -6927,12 +8855,17 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6927
8855
|
this.inMemoryCanvas.width = this.currImgData.width;
|
|
6928
8856
|
this.inMemoryCanvas.height = this.currImgData.height;
|
|
6929
8857
|
this.inMemoryContext.putImageData(this.currImgData, 0, 0);
|
|
8858
|
+
this.lowerContext.filter = this.canvasFilter;
|
|
8859
|
+
this.updateBrightnessFilter();
|
|
8860
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
6930
8861
|
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
8862
|
+
this.lowerContext.filter = temp;
|
|
6931
8863
|
this.redrawObj(degree);
|
|
6932
8864
|
}
|
|
6933
8865
|
if (!isNullOrUndefined(activeObjShape)) {
|
|
6934
8866
|
if (activeObjShape === 'custom') {
|
|
6935
|
-
var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height -
|
|
8867
|
+
var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height -
|
|
8868
|
+
this.pannEnd.startY };
|
|
6936
8869
|
this.activeObj.activePoint = { startX: this.pannStart.startX, startY: this.pannStart.startY, endX: endPoint.x,
|
|
6937
8870
|
endY: endPoint.y, width: endPoint.x - this.pannStart.startX, height: endPoint.y - this.pannStart.startY };
|
|
6938
8871
|
this.updateActiveObject(this.calcRatio(), this.activeObj.activePoint, this.activeObj);
|
|
@@ -6944,10 +8877,6 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6944
8877
|
this.refreshToolbar('main', true, true);
|
|
6945
8878
|
}
|
|
6946
8879
|
this.factor = 1;
|
|
6947
|
-
if (!this.isUndoRedo) {
|
|
6948
|
-
this.updateUndoRedoColl('rotate', degree, this.objColl, null);
|
|
6949
|
-
}
|
|
6950
|
-
this.isUndoRedo = false;
|
|
6951
8880
|
this.refreshToolbar('main');
|
|
6952
8881
|
}
|
|
6953
8882
|
return isRotate;
|
|
@@ -6968,17 +8897,14 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6968
8897
|
this.applyPenDraw();
|
|
6969
8898
|
}
|
|
6970
8899
|
this.applyActObj();
|
|
8900
|
+
this.lowerContext.filter = this.canvasFilter;
|
|
6971
8901
|
if (this.factor !== 1) {
|
|
6972
8902
|
this.lowerContext.setTransform(1, 0, 0, 1, 0, 0);
|
|
6973
8903
|
this.upperContext.setTransform(1, 0, 0, 1, 0, 0);
|
|
6974
8904
|
this.factor = 1;
|
|
6975
8905
|
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
6976
8906
|
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
6977
|
-
this.
|
|
6978
|
-
for (var i = 0; i < this.objColl.length; i++) {
|
|
6979
|
-
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
6980
|
-
this.refreshActiveObj();
|
|
6981
|
-
}
|
|
8907
|
+
this.redrawImgWithObj();
|
|
6982
8908
|
}
|
|
6983
8909
|
type = type ? type : 'Png';
|
|
6984
8910
|
this.redrawActObj();
|
|
@@ -6986,6 +8912,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6986
8912
|
var saved_1 = { fileName: fileName ? fileName : 'ImageEditor', fileType: type };
|
|
6987
8913
|
this.trigger('beforeSave', beforeSave, function (observableSaveArgs) {
|
|
6988
8914
|
if (!observableSaveArgs.cancel) {
|
|
8915
|
+
_this.currObjType.isSave = true;
|
|
6989
8916
|
fileName = observableSaveArgs.fileName ? observableSaveArgs.fileName : fileName;
|
|
6990
8917
|
if (type.toLowerCase() === 'svg') {
|
|
6991
8918
|
fileName = fileName || 'ImageEditor';
|
|
@@ -7046,7 +8973,8 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
7046
8973
|
this.upperCanvas.style.cursor = 'crosshair';
|
|
7047
8974
|
if (Browser.isDevice) {
|
|
7048
8975
|
var arcRadius = (7.5 * (ratio.width > ratio.height ? ratio.width : ratio.height)) / this.factor;
|
|
7049
|
-
var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height -
|
|
8976
|
+
var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height -
|
|
8977
|
+
this.pannEnd.startY };
|
|
7050
8978
|
this.activeObj.activePoint = { startX: this.pannStart.startX + arcRadius, startY: this.pannStart.startY + arcRadius,
|
|
7051
8979
|
endX: endPoint.x - arcRadius, endY: endPoint.y - arcRadius };
|
|
7052
8980
|
this.activeObj.activePoint.width = this.activeObj.activePoint.endX - this.activeObj.activePoint.startX;
|
|
@@ -7099,7 +9027,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
7099
9027
|
ImageEditor.prototype.freeHandDraw = function (value) {
|
|
7100
9028
|
if (value) {
|
|
7101
9029
|
this.togglePen = true;
|
|
7102
|
-
this.upperCanvas.style.cursor = '
|
|
9030
|
+
this.upperCanvas.style.cursor = 'crosshair';
|
|
7103
9031
|
this.drawPen();
|
|
7104
9032
|
}
|
|
7105
9033
|
else {
|
|
@@ -7113,7 +9041,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
7113
9041
|
*
|
|
7114
9042
|
* @param {boolean} value - Specifies a value whether enable or disable freehand drawing.
|
|
7115
9043
|
*
|
|
7116
|
-
*
|
|
9044
|
+
* @returns {void}.
|
|
7117
9045
|
*/
|
|
7118
9046
|
ImageEditor.prototype.freehandDraw = function (value) {
|
|
7119
9047
|
this.freeHandDraw(value);
|
|
@@ -7164,17 +9092,8 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
7164
9092
|
this.redrawActObj();
|
|
7165
9093
|
this.refreshActiveObj();
|
|
7166
9094
|
this.upperContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
9095
|
+
this.lowerContext.filter = this.canvasFilter;
|
|
7167
9096
|
this.upperCanvas.style.cursor = 'default';
|
|
7168
|
-
var zoomState = void 0;
|
|
7169
|
-
if (value === 3.75 || value === 1) {
|
|
7170
|
-
zoomState = 0.1;
|
|
7171
|
-
}
|
|
7172
|
-
else if (value === -3.75) {
|
|
7173
|
-
zoomState = -0.1;
|
|
7174
|
-
}
|
|
7175
|
-
else {
|
|
7176
|
-
zoomState = value;
|
|
7177
|
-
}
|
|
7178
9097
|
if (this.degree !== 0) {
|
|
7179
9098
|
this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
7180
9099
|
this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.height, this.lowerCanvas.width);
|
|
@@ -7186,16 +9105,22 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
7186
9105
|
this.lastX = this.lowerCanvas.width / 2;
|
|
7187
9106
|
this.lastY = this.lowerCanvas.height / 2;
|
|
7188
9107
|
}
|
|
7189
|
-
if (value
|
|
7190
|
-
this.zoomImg(
|
|
9108
|
+
if (value === 1.1 || value === -1.1) {
|
|
9109
|
+
this.zoomImg(value);
|
|
7191
9110
|
}
|
|
7192
9111
|
else {
|
|
7193
|
-
|
|
9112
|
+
if (value > 0) {
|
|
9113
|
+
this.zoomImg(3.75);
|
|
9114
|
+
}
|
|
9115
|
+
else {
|
|
9116
|
+
this.zoomImg(-3.75);
|
|
9117
|
+
}
|
|
7194
9118
|
}
|
|
7195
9119
|
this.refreshActiveObj();
|
|
7196
9120
|
if (!isNullOrUndefined(activeObjShape)) {
|
|
7197
9121
|
if (activeObjShape === 'custom') {
|
|
7198
|
-
var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height -
|
|
9122
|
+
var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height -
|
|
9123
|
+
this.pannEnd.startY };
|
|
7199
9124
|
this.activeObj.activePoint = { startX: this.pannStart.startX, startY: this.pannStart.startY, endX: endPoint.x,
|
|
7200
9125
|
endY: endPoint.y, width: endPoint.x - this.pannStart.startX, height: endPoint.y - this.pannStart.startY };
|
|
7201
9126
|
this.updateActiveObject(this.calcRatio(), this.activeObj.activePoint, this.activeObj);
|
|
@@ -7206,10 +9131,6 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
7206
9131
|
}
|
|
7207
9132
|
this.refreshToolbar('main', true, true);
|
|
7208
9133
|
}
|
|
7209
|
-
if (!this.isUndoRedo) {
|
|
7210
|
-
this.updateUndoRedoColl('zoom', zoomState, this.objColl);
|
|
7211
|
-
}
|
|
7212
|
-
this.isUndoRedo = false;
|
|
7213
9134
|
var zoomOut = document.querySelector('#' + this.element.id + '_zoomOut');
|
|
7214
9135
|
if (!isNullOrUndefined(zoomOut) && this.factor === 1) {
|
|
7215
9136
|
zoomOut.classList.add('e-disabled');
|
|
@@ -7217,6 +9138,23 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
7217
9138
|
else if (!isNullOrUndefined(zoomOut)) {
|
|
7218
9139
|
zoomOut.classList.remove('e-disabled');
|
|
7219
9140
|
}
|
|
9141
|
+
if (!this.togglePan) {
|
|
9142
|
+
this.callMainToolbar(false, true);
|
|
9143
|
+
}
|
|
9144
|
+
this.autoEnablePan();
|
|
9145
|
+
if (isNullOrUndefined(this.activeObj.activePoint) || this.activeObj.activePoint.width === 0) {
|
|
9146
|
+
this.refreshToolbar('main');
|
|
9147
|
+
}
|
|
9148
|
+
else {
|
|
9149
|
+
this.refreshToolbar('main', true, true);
|
|
9150
|
+
}
|
|
9151
|
+
var panBtn = this.element.querySelector('.e-img-pan .e-btn');
|
|
9152
|
+
if (!isNullOrUndefined(panBtn) && this.togglePan) {
|
|
9153
|
+
panBtn.classList.add('e-selected-btn');
|
|
9154
|
+
}
|
|
9155
|
+
else if (!isNullOrUndefined(panBtn)) {
|
|
9156
|
+
panBtn.classList.remove('e-selected-btn');
|
|
9157
|
+
}
|
|
7220
9158
|
}
|
|
7221
9159
|
};
|
|
7222
9160
|
/**
|
|
@@ -7397,6 +9335,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
7397
9335
|
else {
|
|
7398
9336
|
isSelected = true;
|
|
7399
9337
|
this.activeObj = obj;
|
|
9338
|
+
this.lowerContext.filter = this.canvasFilter;
|
|
7400
9339
|
this.redrawShape(this.activeObj);
|
|
7401
9340
|
if (this.activeObj.shape === 'text') {
|
|
7402
9341
|
this.refreshToolbar('text');
|
|
@@ -7438,12 +9377,9 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
7438
9377
|
break;
|
|
7439
9378
|
}
|
|
7440
9379
|
}
|
|
9380
|
+
this.lowerContext.filter = this.canvasFilter;
|
|
7441
9381
|
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
7442
|
-
this.
|
|
7443
|
-
for (var i = 0; i < this.objColl.length; i++) {
|
|
7444
|
-
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
7445
|
-
this.refreshActiveObj();
|
|
7446
|
-
}
|
|
9382
|
+
this.redrawImgWithObj();
|
|
7447
9383
|
this.refreshToolbar('main');
|
|
7448
9384
|
};
|
|
7449
9385
|
/**
|
|
@@ -7508,9 +9444,60 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
7508
9444
|
canvasWrapper.style.height = this.element.offsetHeight - this.toolbarHeight - 1 + 'px';
|
|
7509
9445
|
this.lowerCanvas.height = this.upperCanvas.height = this.element.offsetHeight - this.toolbarHeight - 1;
|
|
7510
9446
|
}
|
|
9447
|
+
this.lowerContext.filter = this.canvasFilter;
|
|
7511
9448
|
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
7512
9449
|
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
7513
9450
|
};
|
|
9451
|
+
/**
|
|
9452
|
+
* To apply the filters to an image
|
|
9453
|
+
*
|
|
9454
|
+
* @param {ImageFilterOptions } filterOption - Specifies the filter options to the image.
|
|
9455
|
+
* @returns {void}.
|
|
9456
|
+
*/
|
|
9457
|
+
ImageEditor.prototype.applyImageFilter = function (filterOption) {
|
|
9458
|
+
if (this.initialAdjustmentValue === '') {
|
|
9459
|
+
this.initialAdjustmentValue = 'brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)';
|
|
9460
|
+
}
|
|
9461
|
+
this.lowerContext.filter = this.initialAdjustmentValue;
|
|
9462
|
+
this.setFilter(filterOption.toString());
|
|
9463
|
+
};
|
|
9464
|
+
/**
|
|
9465
|
+
* To apply the filters to an image
|
|
9466
|
+
*
|
|
9467
|
+
* @param {ImageFinetuneOptions } finetuneOption - Specifies the finetune options to the image.
|
|
9468
|
+
* @param {number } value - Specifies the value for finetuning the image.
|
|
9469
|
+
* @returns {void}.
|
|
9470
|
+
*
|
|
9471
|
+
*/
|
|
9472
|
+
ImageEditor.prototype.finetuneImage = function (finetuneOption, value) {
|
|
9473
|
+
if (this.initialAdjustmentValue === '') {
|
|
9474
|
+
this.initialAdjustmentValue = 'brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)';
|
|
9475
|
+
}
|
|
9476
|
+
this.lowerContext.filter = this.initialAdjustmentValue;
|
|
9477
|
+
switch (finetuneOption) {
|
|
9478
|
+
case 'Brightness':
|
|
9479
|
+
this.setBrightness(value);
|
|
9480
|
+
break;
|
|
9481
|
+
case 'Contrast':
|
|
9482
|
+
this.setContrast(value);
|
|
9483
|
+
break;
|
|
9484
|
+
case 'Hue':
|
|
9485
|
+
this.setHue(value);
|
|
9486
|
+
break;
|
|
9487
|
+
case 'Saturation':
|
|
9488
|
+
this.setSaturation(value);
|
|
9489
|
+
break;
|
|
9490
|
+
case 'Opacity':
|
|
9491
|
+
this.setOpacity(value);
|
|
9492
|
+
break;
|
|
9493
|
+
case 'Blur':
|
|
9494
|
+
this.setBlur(value);
|
|
9495
|
+
break;
|
|
9496
|
+
case 'Exposure':
|
|
9497
|
+
this.setExposure(value);
|
|
9498
|
+
break;
|
|
9499
|
+
}
|
|
9500
|
+
};
|
|
7514
9501
|
/**
|
|
7515
9502
|
* To check whether the undo collection is empty or not.
|
|
7516
9503
|
*
|
|
@@ -7563,7 +9550,8 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
7563
9550
|
* @private
|
|
7564
9551
|
*/
|
|
7565
9552
|
ImageEditor.prototype.getBlob = function (url) {
|
|
7566
|
-
|
|
9553
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
9554
|
+
return url;
|
|
7567
9555
|
};
|
|
7568
9556
|
/**
|
|
7569
9557
|
* To check whether the signature is empty or not.
|
|
@@ -7613,7 +9601,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
7613
9601
|
/**
|
|
7614
9602
|
* To save the signature with the given file type and file name.
|
|
7615
9603
|
*
|
|
7616
|
-
* @param {
|
|
9604
|
+
* @param {FileType} type - specify type of the file to be saved a signature.
|
|
7617
9605
|
* @param {string} fileName - specify name of the file to be saved a signature.
|
|
7618
9606
|
*
|
|
7619
9607
|
* @returns {void}.
|
|
@@ -7636,9 +9624,10 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
7636
9624
|
/**
|
|
7637
9625
|
* Returns the persistence data for component.
|
|
7638
9626
|
*
|
|
7639
|
-
* @returns any.
|
|
9627
|
+
* @returns {any}.
|
|
7640
9628
|
* @private
|
|
7641
9629
|
*/
|
|
9630
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
7642
9631
|
ImageEditor.prototype.getLocalData = function () {
|
|
7643
9632
|
return null;
|
|
7644
9633
|
};
|
|
@@ -7694,6 +9683,12 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
7694
9683
|
__decorate([
|
|
7695
9684
|
Property(false)
|
|
7696
9685
|
], ImageEditor.prototype, "enablePersistence", void 0);
|
|
9686
|
+
__decorate([
|
|
9687
|
+
Complex({}, FinetuneSettings)
|
|
9688
|
+
], ImageEditor.prototype, "finetuneSettings", void 0);
|
|
9689
|
+
__decorate([
|
|
9690
|
+
Property('')
|
|
9691
|
+
], ImageEditor.prototype, "signatureValue", void 0);
|
|
7697
9692
|
__decorate([
|
|
7698
9693
|
Event()
|
|
7699
9694
|
], ImageEditor.prototype, "beforeSave", void 0);
|
|
@@ -7736,6 +9731,12 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
7736
9731
|
__decorate([
|
|
7737
9732
|
Event()
|
|
7738
9733
|
], ImageEditor.prototype, "toolbarItemClicked", void 0);
|
|
9734
|
+
__decorate([
|
|
9735
|
+
Event()
|
|
9736
|
+
], ImageEditor.prototype, "imageFiltering", void 0);
|
|
9737
|
+
__decorate([
|
|
9738
|
+
Event()
|
|
9739
|
+
], ImageEditor.prototype, "fineTuneValueChanging", void 0);
|
|
7739
9740
|
ImageEditor = ImageEditor_1 = __decorate([
|
|
7740
9741
|
NotifyPropertyChanges
|
|
7741
9742
|
], ImageEditor);
|