@syncfusion/ej2-image-editor 20.4.51 → 21.1.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/.eslintrc.json +1 -0
  2. package/CHANGELOG.md +55 -5
  3. package/dist/ej2-image-editor.umd.min.js +2 -2
  4. package/dist/ej2-image-editor.umd.min.js.map +1 -1
  5. package/dist/es6/ej2-image-editor.es2015.js +20032 -11350
  6. package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
  7. package/dist/es6/ej2-image-editor.es5.js +20027 -11313
  8. package/dist/es6/ej2-image-editor.es5.js.map +1 -1
  9. package/dist/global/ej2-image-editor.min.js +2 -2
  10. package/dist/global/ej2-image-editor.min.js.map +1 -1
  11. package/dist/global/index.d.ts +1 -1
  12. package/package.json +12 -12
  13. package/src/image-editor/action/crop.d.ts +36 -0
  14. package/src/image-editor/action/crop.js +829 -0
  15. package/src/image-editor/action/draw.d.ts +125 -0
  16. package/src/image-editor/action/draw.js +3263 -0
  17. package/src/image-editor/action/export.d.ts +23 -0
  18. package/src/image-editor/action/export.js +364 -0
  19. package/src/image-editor/action/filter.d.ts +35 -0
  20. package/src/image-editor/action/filter.js +699 -0
  21. package/src/image-editor/action/freehand-draw.d.ts +61 -0
  22. package/src/image-editor/action/freehand-draw.js +1015 -0
  23. package/src/image-editor/action/index.d.ts +9 -0
  24. package/src/image-editor/action/index.js +9 -0
  25. package/src/image-editor/action/selection.d.ts +139 -0
  26. package/src/image-editor/action/selection.js +4518 -0
  27. package/src/image-editor/action/shape.d.ts +94 -0
  28. package/src/image-editor/action/shape.js +2745 -0
  29. package/src/image-editor/action/transform.d.ts +67 -0
  30. package/src/image-editor/action/transform.js +1859 -0
  31. package/src/image-editor/action/undo-redo.d.ts +43 -0
  32. package/src/image-editor/action/undo-redo.js +800 -0
  33. package/src/image-editor/base/enum.d.ts +189 -0
  34. package/src/image-editor/base/enum.js +198 -0
  35. package/src/image-editor/base/image-editor-model.d.ts +626 -0
  36. package/src/image-editor/base/image-editor.d.ts +1300 -0
  37. package/src/image-editor/base/image-editor.js +2270 -0
  38. package/src/image-editor/base/index.d.ts +4 -0
  39. package/src/image-editor/base/index.js +2 -0
  40. package/src/image-editor/base/interface.d.ts +1128 -0
  41. package/src/image-editor/base/interface.js +1 -0
  42. package/src/image-editor/index.d.ts +3 -5
  43. package/src/image-editor/index.js +3 -4
  44. package/src/image-editor/renderer/index.d.ts +1 -0
  45. package/src/image-editor/renderer/index.js +1 -0
  46. package/src/image-editor/renderer/toolbar.d.ts +105 -0
  47. package/src/image-editor/renderer/toolbar.js +3018 -0
  48. package/styles/bootstrap-dark.css +79 -8
  49. package/styles/bootstrap.css +79 -8
  50. package/styles/bootstrap4.css +79 -8
  51. package/styles/bootstrap5-dark.css +81 -11
  52. package/styles/bootstrap5.css +81 -11
  53. package/styles/fabric-dark.css +79 -8
  54. package/styles/fabric.css +79 -8
  55. package/styles/fluent-dark.css +79 -8
  56. package/styles/fluent.css +79 -8
  57. package/styles/highcontrast-light.css +81 -10
  58. package/styles/highcontrast.css +82 -10
  59. package/styles/image-editor/_highcontrast-definition.scss +1 -1
  60. package/styles/image-editor/_highcontrast-light-definition.scss +1 -1
  61. package/styles/image-editor/_layout.scss +28 -18
  62. package/styles/image-editor/_material3-dark-definition.scss +1 -0
  63. package/styles/image-editor/_material3-definition.scss +10 -10
  64. package/styles/image-editor/_theme.scss +11 -6
  65. package/styles/image-editor/bootstrap-dark.css +79 -8
  66. package/styles/image-editor/bootstrap.css +79 -8
  67. package/styles/image-editor/bootstrap4.css +79 -8
  68. package/styles/image-editor/bootstrap5-dark.css +81 -11
  69. package/styles/image-editor/bootstrap5.css +81 -11
  70. package/styles/image-editor/fabric-dark.css +79 -8
  71. package/styles/image-editor/fabric.css +79 -8
  72. package/styles/image-editor/fluent-dark.css +79 -8
  73. package/styles/image-editor/fluent.css +79 -8
  74. package/styles/image-editor/highcontrast-light.css +81 -10
  75. package/styles/image-editor/highcontrast.css +82 -10
  76. package/styles/image-editor/icons/_bootstrap-dark.scss +132 -0
  77. package/styles/image-editor/icons/_bootstrap.scss +132 -0
  78. package/styles/image-editor/icons/_bootstrap4.scss +132 -0
  79. package/styles/image-editor/icons/_bootstrap5.scss +132 -0
  80. package/styles/image-editor/icons/_fabric-dark.scss +132 -0
  81. package/styles/image-editor/icons/_fabric.scss +132 -0
  82. package/styles/image-editor/icons/_fluent.scss +132 -0
  83. package/styles/image-editor/icons/_fusionnew.scss +132 -0
  84. package/styles/image-editor/icons/_highcontrast-light.scss +132 -0
  85. package/styles/image-editor/icons/_highcontrast.scss +132 -0
  86. package/styles/image-editor/icons/_material-dark.scss +132 -0
  87. package/styles/image-editor/icons/_material.scss +132 -0
  88. package/styles/image-editor/icons/_material3-dark.scss +1 -0
  89. package/styles/image-editor/icons/_material3.scss +133 -1
  90. package/styles/image-editor/icons/_tailwind.scss +132 -0
  91. package/styles/image-editor/material-dark.css +79 -16
  92. package/styles/image-editor/material.css +79 -11
  93. package/styles/image-editor/material3-dark.css +453 -0
  94. package/styles/image-editor/material3-dark.scss +14 -0
  95. package/styles/image-editor/material3.css +509 -0
  96. package/styles/image-editor/material3.scss +14 -0
  97. package/styles/image-editor/tailwind-dark.css +79 -8
  98. package/styles/image-editor/tailwind.css +79 -8
  99. package/styles/material-dark.css +79 -16
  100. package/styles/material.css +79 -11
  101. package/styles/material3-dark.css +453 -0
  102. package/styles/material3-dark.scss +3 -0
  103. package/styles/material3.css +509 -0
  104. package/styles/material3.scss +3 -0
  105. package/styles/tailwind-dark.css +79 -8
  106. package/styles/tailwind.css +79 -8
  107. package/GitLeaksReport.json +0 -1
  108. package/gitleaks-ci/gitleaks +0 -0
  109. package/gitleaks-ci.tar.gz +0 -0
  110. package/src/image-editor/image-editor-model.d.ts +0 -331
  111. package/src/image-editor/image-editor.d.ts +0 -1428
  112. package/src/image-editor/image-editor.js +0 -12849
@@ -0,0 +1,23 @@
1
+ import { ImageEditor } from '../index';
2
+ export declare class Export {
3
+ private parent;
4
+ private lowerContext;
5
+ constructor(parent: ImageEditor);
6
+ destroy(): void;
7
+ private addEventListener;
8
+ private removeEventListener;
9
+ private export;
10
+ getModuleName(): string;
11
+ private updatePvtVar;
12
+ private exportImg;
13
+ private beforeSaveEvent;
14
+ private toSVGImg;
15
+ private toBlobFn;
16
+ private exportToCanvas;
17
+ private downloadImg;
18
+ private exportTransformedImage;
19
+ private exportRotate;
20
+ private exportFlip;
21
+ private updateSaveContext;
22
+ private setMaxDim;
23
+ }
@@ -0,0 +1,364 @@
1
+ import { extend, isBlazor, isNullOrUndefined } from '@syncfusion/ej2-base';
2
+ import { hideSpinner, showSpinner } from '@syncfusion/ej2-popups';
3
+ var Export = /** @class */ (function () {
4
+ function Export(parent) {
5
+ this.parent = parent;
6
+ this.addEventListener();
7
+ }
8
+ Export.prototype.destroy = function () {
9
+ if (this.parent.isDestroyed) {
10
+ return;
11
+ }
12
+ this.removeEventListener();
13
+ };
14
+ Export.prototype.addEventListener = function () {
15
+ this.parent.on('export', this.export, this);
16
+ this.parent.on('destroyed', this.destroy, this);
17
+ };
18
+ Export.prototype.removeEventListener = function () {
19
+ this.parent.off('export', this.export);
20
+ this.parent.off('destroyed', this.destroy);
21
+ };
22
+ Export.prototype.export = function (args) {
23
+ if (isBlazor()) {
24
+ var obj = { shape: '' };
25
+ this.parent.notify('selection', { prop: 'getCurrentDrawingShape', onPropertyChange: false, value: { obj: obj } });
26
+ if (obj['shape'] !== '') {
27
+ this.parent.notify('selection', { prop: 'setCurrentDrawingShape', onPropertyChange: false, value: { value: '' } });
28
+ this.parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
29
+ }
30
+ }
31
+ else {
32
+ this.parent.notify('toolbar', { prop: 'refreshShapeDrawing', onPropertyChange: false });
33
+ }
34
+ this.updatePvtVar();
35
+ switch (args.prop) {
36
+ case 'export':
37
+ this.exportImg(args.value['type'], args.value['fileName']);
38
+ break;
39
+ case 'exportToCanvas':
40
+ this.exportToCanvas(args.value['object']);
41
+ break;
42
+ }
43
+ };
44
+ Export.prototype.getModuleName = function () {
45
+ return 'export';
46
+ };
47
+ Export.prototype.updatePvtVar = function () {
48
+ var parent = this.parent;
49
+ if (parent.lowerCanvas) {
50
+ this.lowerContext = parent.lowerCanvas.getContext('2d');
51
+ }
52
+ };
53
+ Export.prototype.exportImg = function (type, fileName) {
54
+ var _this = this;
55
+ var parent = this.parent;
56
+ var obj = { fileName: '' };
57
+ parent.notify('draw', { prop: 'getFileName', onPropertyChange: false, value: { obj: obj } });
58
+ var imageName = obj['fileName'];
59
+ if (!parent.disabled && parent.isImageLoaded) {
60
+ var dummyObj = { bool: false };
61
+ parent.notify('selection', { prop: 'getFreehandDrawEditing', onPropertyChange: false, value: { obj: dummyObj } });
62
+ if (dummyObj['bool']) {
63
+ parent.notify('freehand-draw', { prop: 'applyFhd', onPropertyChange: false });
64
+ }
65
+ if (parent.togglePen) {
66
+ parent.currObjType.isZoomed = true;
67
+ parent.notify('shape', { prop: 'apply', onPropertyChange: false, value: { shape: null, obj: null, canvas: null } });
68
+ }
69
+ if (parent.textArea.style.display === 'block') {
70
+ parent.notify('shape', { prop: 'redrawActObj', onPropertyChange: false,
71
+ value: { x: null, y: null, isMouseDown: null } });
72
+ }
73
+ parent.notify('shape', { prop: 'applyActObj', onPropertyChange: false, value: { isMouseDown: null } });
74
+ var obj_1 = { canvasFilter: this.parent.canvasFilter };
75
+ this.lowerContext.filter = obj_1['canvasFilter'];
76
+ type = type ? type : 'Png';
77
+ parent.notify('shape', { prop: 'redrawActObj', onPropertyChange: false,
78
+ value: { x: null, y: null, isMouseDown: null } });
79
+ var beforeSave = { cancel: false, fileName: fileName ? fileName : imageName,
80
+ fileType: type };
81
+ if (isBlazor() && parent.events && parent.events.saving.hasDelegate === true) {
82
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
83
+ parent.dotNetRef.invokeMethodAsync('BeforeSaveEventAsync', 'BeforeSave', beforeSave).then(function (beforeSave) {
84
+ _this.beforeSaveEvent(beforeSave, type, fileName, imageName);
85
+ });
86
+ }
87
+ else {
88
+ parent.trigger('beforeSave', beforeSave);
89
+ this.beforeSaveEvent(beforeSave, type, fileName, imageName);
90
+ }
91
+ }
92
+ };
93
+ Export.prototype.beforeSaveEvent = function (observableSaveArgs, type, fileName, imageName) {
94
+ var parent = this.parent;
95
+ if (!observableSaveArgs.cancel) {
96
+ parent.currObjType.isSave = true;
97
+ fileName = observableSaveArgs.fileName ? observableSaveArgs.fileName : fileName;
98
+ var lowerCaseType = type.toLowerCase();
99
+ fileName = fileName || imageName;
100
+ if (lowerCaseType === 'svg') {
101
+ this.toSVGImg(fileName);
102
+ }
103
+ else {
104
+ this.toBlobFn(fileName, lowerCaseType);
105
+ }
106
+ var saved = { fileName: fileName ? fileName : imageName, fileType: type };
107
+ parent.trigger('saved', saved);
108
+ if (!isBlazor()) {
109
+ parent.notify('toolbar', { prop: 'refresh-main-toolbar', onPropertyChange: false });
110
+ }
111
+ parent.lowerCanvas.style.left = parent.upperCanvas.style.left = '';
112
+ parent.lowerCanvas.style.top = parent.upperCanvas.style.top = '';
113
+ parent.lowerCanvas.style.maxWidth = parent.upperCanvas.style.maxWidth = '';
114
+ parent.lowerCanvas.style.maxHeight = parent.upperCanvas.style.maxHeight = '';
115
+ }
116
+ };
117
+ Export.prototype.toSVGImg = function (fileName) {
118
+ var parent = this.parent;
119
+ showSpinner(parent.element);
120
+ parent.element.style.opacity = '0.5';
121
+ var tempCanvas = this.exportToCanvas();
122
+ var dataUrl = tempCanvas.toDataURL();
123
+ hideSpinner(parent.element);
124
+ parent.element.style.opacity = '1';
125
+ var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
126
+ svg.setAttribute('width', tempCanvas.style.maxWidth);
127
+ svg.setAttribute('height', tempCanvas.style.maxHeight);
128
+ var XLinkNS = 'http://www.w3.org/1999/xlink';
129
+ var img = document.createElementNS('http://www.w3.org/2000/svg', 'image');
130
+ img.setAttributeNS(null, 'height', tempCanvas.height.toString());
131
+ img.setAttributeNS(null, 'width', tempCanvas.width.toString());
132
+ img.setAttributeNS(XLinkNS, 'xlink:href', dataUrl);
133
+ svg.appendChild(img);
134
+ var prefix = 'data:image/svg+xml;base64,';
135
+ var header = '<svg' + ' xmlns="http://www.w3.org/2000/svg"' + ' xmlns:xlink="http://www.w3.org/1999/xlink"'
136
+ + (" width=\"" + tempCanvas.width + "\"") + (" height=\"" + tempCanvas.height + "\"") + '>';
137
+ var footer = '</svg>';
138
+ var body = svg.innerHTML;
139
+ var data = header + body + footer;
140
+ var svgDataUrl = prefix + btoa(data);
141
+ if (fileName === null) {
142
+ return svgDataUrl;
143
+ }
144
+ else {
145
+ this.downloadImg(svgDataUrl, fileName + '.' + 'svg');
146
+ return null;
147
+ }
148
+ };
149
+ Export.prototype.toBlobFn = function (fileName, type) {
150
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
151
+ var proxy = this;
152
+ var parent = this.parent;
153
+ showSpinner(parent.element);
154
+ parent.element.style.opacity = '0.5';
155
+ var tempCanvas = this.exportToCanvas();
156
+ // eslint-disable-next-line @typescript-eslint/tslint/config
157
+ tempCanvas.toBlob(function (blob) {
158
+ var blobUrl = URL.createObjectURL(blob);
159
+ proxy.downloadImg(blobUrl, fileName + '.' + type);
160
+ hideSpinner(parent.element);
161
+ parent.element.style.opacity = '1';
162
+ }, 'image/png');
163
+ };
164
+ Export.prototype.exportToCanvas = function (object) {
165
+ var parent = this.parent;
166
+ var obj = { width: 0, height: 0 };
167
+ parent.notify('crop', { prop: 'calcRatio', onPropertyChange: false, value: { obj: obj } });
168
+ var ratio = obj;
169
+ var tempContextFilter = this.lowerContext.filter;
170
+ // Manipulating blur value
171
+ if (this.lowerContext.filter !== 'none') {
172
+ var splitWords = this.lowerContext.filter.split(' ');
173
+ var value = parseFloat(splitWords[5].split('(')[1]);
174
+ value *= ((ratio.width + ratio.height) / 2);
175
+ splitWords[5] = 'blur(' + value + 'px)';
176
+ this.lowerContext.filter = splitWords.join(' ');
177
+ }
178
+ var maxDimension;
179
+ var tempCanvas = parent.createElement('canvas', {
180
+ id: parent.element.id + '_tempCanvas', attrs: { name: 'canvasImage' }
181
+ });
182
+ var tempContext = tempCanvas.getContext('2d');
183
+ tempContext.filter = this.lowerContext.filter;
184
+ if (parent.currSelectionPoint) {
185
+ tempCanvas.width = parent.img.destWidth;
186
+ tempCanvas.height = parent.img.destHeight;
187
+ tempContext.filter = this.lowerContext.filter;
188
+ var temp = this.lowerContext.filter;
189
+ parent.notify('filter', { prop: 'updateBrightFilter', onPropertyChange: false });
190
+ tempContext.drawImage(parent.baseImg, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, 0, 0, parent.img.destWidth, parent.img.destHeight);
191
+ this.lowerContext.filter = temp;
192
+ }
193
+ else {
194
+ tempCanvas.width = parent.baseImg.width;
195
+ tempCanvas.height = parent.baseImg.height;
196
+ var obj_2 = { width: 0, height: 0 };
197
+ parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
198
+ value: { width: parent.baseImg.width, height: parent.baseImg.height, obj: obj_2 } });
199
+ maxDimension = obj_2;
200
+ tempCanvas.style.maxWidth = maxDimension.width + 'px';
201
+ tempCanvas.style.maxHeight = maxDimension.height + 'px';
202
+ tempContext.filter = this.lowerContext.filter;
203
+ var temp = this.lowerContext.filter;
204
+ parent.notify('filter', { prop: 'updateBrightFilter', onPropertyChange: false });
205
+ tempContext.drawImage(parent.baseImg, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, 0, 0, parent.baseImg.width, parent.baseImg.height);
206
+ this.lowerContext.filter = temp;
207
+ }
208
+ if (parent.transform.degree !== 0 || parent.transform.currFlipState !== '') {
209
+ this.updateSaveContext(tempContext);
210
+ this.exportTransformedImage(tempContext);
211
+ }
212
+ if (parent.objColl.length > 0) {
213
+ var temp = tempContext.filter;
214
+ tempContext.filter = 'none';
215
+ var tempObjColl = extend([], parent.objColl, [], true);
216
+ for (var i = 0, len = parent.objColl.length; i < len; i++) {
217
+ var activePoint = parent.objColl[i].activePoint;
218
+ // Subtracting destination left and top points
219
+ activePoint.startX -= parent.img.destLeft;
220
+ activePoint.startY -= parent.img.destTop;
221
+ activePoint.endX -= parent.img.destLeft;
222
+ activePoint.endY -= parent.img.destTop;
223
+ activePoint.width = activePoint.endX - activePoint.startX;
224
+ activePoint.height = activePoint.endY - activePoint.startY;
225
+ // Manipulating points
226
+ if (isNullOrUndefined(parent.currSelectionPoint)) {
227
+ activePoint.startX *= ratio.width;
228
+ activePoint.startY *= ratio.height;
229
+ activePoint.endX *= ratio.width;
230
+ activePoint.endY *= ratio.height;
231
+ activePoint.width = activePoint.endX - activePoint.startX;
232
+ activePoint.height = activePoint.endY - activePoint.startY;
233
+ parent.objColl[i].strokeSettings.strokeWidth *= ((ratio.width + ratio.height) / 2);
234
+ if (parent.objColl[i].shape === 'text') {
235
+ parent.objColl[i].textSettings.fontSize *= ((ratio.width + ratio.height) / 2);
236
+ }
237
+ }
238
+ parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'saveContext', obj: parent.objColl[i], isCropRatio: null,
239
+ points: null, isPreventDrag: true, saveContext: tempContext, isPreventSelection: null } });
240
+ }
241
+ tempContext.filter = temp;
242
+ parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
243
+ parent.objColl = tempObjColl;
244
+ }
245
+ if (parent.freehandCounter > 0) {
246
+ // eslint-disable-next-line
247
+ var tempPointColl = extend({}, parent.pointColl, {}, true);
248
+ for (var n = 0; n < parent.freehandCounter; n++) {
249
+ parent.points = extend([], parent.pointColl[n].points, []);
250
+ parent.notify('freehand-draw', { prop: 'setPointCounter', onPropertyChange: false, value: { value: 0 } });
251
+ var len = parent.points.length;
252
+ if (parent.currSelectionPoint) {
253
+ for (var l = 0; l < len; l++) {
254
+ parent.points[l].x -= parent.img.destLeft;
255
+ parent.points[l].y -= parent.img.destTop;
256
+ }
257
+ }
258
+ else {
259
+ parent.pointColl[n].strokeWidth *= ((ratio.width + ratio.height) / 2);
260
+ for (var l = 0; l < len; l++) {
261
+ parent.points[l].x = (parent.points[l].x - parent.img.destLeft) * ratio.width;
262
+ parent.points[l].y = (parent.points[l].y - parent.img.destTop) * ratio.height;
263
+ }
264
+ }
265
+ }
266
+ parent.notify('freehand-draw', { prop: 'freehandRedraw', onPropertyChange: false,
267
+ value: { context: tempContext, points: null } });
268
+ parent.pointColl = tempPointColl;
269
+ }
270
+ if (parent.isCircleCrop) {
271
+ parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
272
+ value: { context: tempContext, isSave: true, isFlip: null } });
273
+ }
274
+ this.lowerContext.filter = tempContextFilter;
275
+ if (object) {
276
+ object['canvas'] = tempCanvas;
277
+ }
278
+ return tempCanvas;
279
+ };
280
+ Export.prototype.downloadImg = function (blob, fileName) {
281
+ var a = document.createElement('a');
282
+ a.href = blob;
283
+ a.target = '_parent';
284
+ a.download = fileName;
285
+ (document.body || document.documentElement).appendChild(a);
286
+ a.click();
287
+ a.parentNode.removeChild(a);
288
+ };
289
+ Export.prototype.exportTransformedImage = function (tempContext) {
290
+ var parent = this.parent;
291
+ var degree = parent.transform.degree;
292
+ for (var i = 0, len = parent.rotateFlipColl.length; i < len; i++) {
293
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
294
+ var flip = parent.rotateFlipColl[i];
295
+ if (typeof flip === 'number') {
296
+ this.exportRotate(tempContext, flip);
297
+ }
298
+ else if (flip === 'horizontal') {
299
+ this.exportFlip(tempContext, true, false);
300
+ }
301
+ else if (flip === 'vertical') {
302
+ this.exportFlip(tempContext, false, true);
303
+ }
304
+ }
305
+ parent.transform.degree = degree;
306
+ };
307
+ Export.prototype.exportRotate = function (tempContext, degree) {
308
+ var parent = this.parent;
309
+ if (isNullOrUndefined(parent.currSelectionPoint)) {
310
+ this.setMaxDim(parent.transform.degree, tempContext.canvas);
311
+ tempContext.translate(tempContext.canvas.width / 2, tempContext.canvas.height / 2);
312
+ tempContext.rotate(Math.PI / 180 * degree);
313
+ tempContext.drawImage(parent.inMemoryCanvas, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, -tempContext.canvas.height / 2, -tempContext.canvas.width / 2, tempContext.canvas.height, tempContext.canvas.width);
314
+ }
315
+ else {
316
+ tempContext.translate(tempContext.canvas.width / 2, tempContext.canvas.height / 2);
317
+ tempContext.rotate(Math.PI / 180 * degree);
318
+ tempContext.drawImage(parent.inMemoryCanvas, -tempContext.canvas.height / 2, -tempContext.canvas.width / 2, tempContext.canvas.height, tempContext.canvas.width);
319
+ }
320
+ this.updateSaveContext(tempContext);
321
+ };
322
+ Export.prototype.exportFlip = function (tempContext, flipHorizontal, flipVertical) {
323
+ if (flipHorizontal) {
324
+ tempContext.translate(tempContext.canvas.width, 0);
325
+ tempContext.scale(-1, 1);
326
+ }
327
+ if (flipVertical) {
328
+ tempContext.translate(0, tempContext.canvas.height);
329
+ tempContext.scale(1, -1);
330
+ }
331
+ tempContext.drawImage(this.parent.inMemoryCanvas, 0, 0);
332
+ this.updateSaveContext(tempContext);
333
+ };
334
+ Export.prototype.updateSaveContext = function (tempContext) {
335
+ var inMemoryContext = this.parent.inMemoryCanvas.getContext('2d');
336
+ tempContext.setTransform(1, 0, 0, 1, 0, 0);
337
+ var imageData = tempContext.getImageData(0, 0, tempContext.canvas.width, tempContext.canvas.height);
338
+ this.parent.inMemoryCanvas.width = imageData.width;
339
+ this.parent.inMemoryCanvas.height = imageData.height;
340
+ inMemoryContext.putImageData(imageData, 0, 0);
341
+ };
342
+ Export.prototype.setMaxDim = function (degree, tempCanvas) {
343
+ var newWidth;
344
+ var newHeight;
345
+ if (degree % 90 === 0 && degree % 180 !== 0) {
346
+ newWidth = this.parent.baseImg.height;
347
+ newHeight = this.parent.baseImg.width;
348
+ }
349
+ else if (degree % 180 === 0 || degree === 0) {
350
+ newWidth = this.parent.baseImg.width;
351
+ newHeight = this.parent.baseImg.height;
352
+ }
353
+ tempCanvas.width = newWidth;
354
+ tempCanvas.height = newHeight;
355
+ var obj = { width: 0, height: 0 };
356
+ this.parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
357
+ value: { width: newWidth, height: newHeight, obj: obj } });
358
+ var maxDimension = obj;
359
+ tempCanvas.style.maxWidth = maxDimension.width + 'px';
360
+ tempCanvas.style.maxHeight = maxDimension.height + 'px';
361
+ };
362
+ return Export;
363
+ }());
364
+ export { Export };
@@ -0,0 +1,35 @@
1
+ import { ImageEditor } from '../index';
2
+ export declare class Filter {
3
+ private parent;
4
+ private lowerContext;
5
+ private adjustmentLevel;
6
+ private tempAdjustmentLevel;
7
+ private adjustmentValue;
8
+ private isBrightnessAdjusted;
9
+ private appliedFilter;
10
+ constructor(parent: ImageEditor);
11
+ destroy(): void;
12
+ private addEventListener;
13
+ private removeEventListener;
14
+ private filter;
15
+ private updatePrivateVariables;
16
+ getModuleName(): string;
17
+ private updateBrightFilter;
18
+ private reset;
19
+ private updateFinetunes;
20
+ private initFilter;
21
+ private updateAdj;
22
+ private setTempFilterValue;
23
+ private getDefaultCurrentFilter;
24
+ private getFilterValue;
25
+ private getSaturationFilterValue;
26
+ private setFilterAdj;
27
+ private setFilter;
28
+ private setAdjustment;
29
+ private setFilterValue;
30
+ private setSaturationFilterValue;
31
+ private updateFilter;
32
+ private finetuneImage;
33
+ private setCurrAdjValue;
34
+ private getCurrentObj;
35
+ }