@syncfusion/ej2-image-editor 21.2.10 → 22.1.34
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 +1 -0
- package/CHANGELOG.md +6 -38
- 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 +19163 -12410
- package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
- package/dist/es6/ej2-image-editor.es5.js +19198 -12414
- package/dist/es6/ej2-image-editor.es5.js.map +1 -1
- package/dist/global/ej2-image-editor.min.js +2 -2
- package/dist/global/ej2-image-editor.min.js.map +1 -1
- package/dist/global/index.d.ts +1 -1
- package/package.json +11 -11
- package/src/image-editor/action/crop.d.ts +35 -0
- package/src/image-editor/action/crop.js +818 -0
- package/src/image-editor/action/draw.d.ts +122 -0
- package/src/image-editor/action/draw.js +3253 -0
- package/src/image-editor/action/export.d.ts +23 -0
- package/src/image-editor/action/export.js +364 -0
- package/src/image-editor/action/filter.d.ts +35 -0
- package/src/image-editor/action/filter.js +699 -0
- package/src/image-editor/action/freehand-draw.d.ts +61 -0
- package/src/image-editor/action/freehand-draw.js +1015 -0
- package/src/image-editor/action/index.d.ts +9 -0
- package/src/image-editor/action/index.js +9 -0
- package/src/image-editor/action/selection.d.ts +140 -0
- package/src/image-editor/action/selection.js +4689 -0
- package/src/image-editor/action/shape.d.ts +93 -0
- package/src/image-editor/action/shape.js +2657 -0
- package/src/image-editor/action/transform.d.ts +67 -0
- package/src/image-editor/action/transform.js +1670 -0
- package/src/image-editor/action/undo-redo.d.ts +43 -0
- package/src/image-editor/action/undo-redo.js +800 -0
- package/src/image-editor/base/enum.d.ts +189 -0
- package/src/image-editor/base/enum.js +198 -0
- package/src/image-editor/{image-editor-model.d.ts → base/image-editor-model.d.ts} +131 -43
- package/src/image-editor/{image-editor.d.ts → base/image-editor.d.ts} +425 -1108
- package/src/image-editor/base/image-editor.js +2458 -0
- package/src/image-editor/base/index.d.ts +4 -0
- package/src/image-editor/base/index.js +2 -0
- package/src/image-editor/base/interface.d.ts +1120 -0
- package/src/image-editor/base/interface.js +1 -0
- package/src/image-editor/index.d.ts +3 -5
- package/src/image-editor/index.js +3 -4
- package/src/image-editor/renderer/index.d.ts +1 -0
- package/src/image-editor/renderer/index.js +1 -0
- package/src/image-editor/renderer/toolbar.d.ts +105 -0
- package/src/image-editor/renderer/toolbar.js +3019 -0
- package/styles/bootstrap-dark.css +69 -3
- package/styles/bootstrap.css +69 -3
- package/styles/bootstrap4.css +69 -3
- package/styles/bootstrap5-dark.css +69 -3
- package/styles/bootstrap5.css +69 -3
- package/styles/fabric-dark.css +69 -3
- package/styles/fabric.css +69 -3
- package/styles/fluent-dark.css +69 -3
- package/styles/fluent.css +69 -3
- package/styles/highcontrast-light.css +69 -3
- package/styles/highcontrast.css +69 -7
- package/styles/image-editor/_layout.scss +21 -7
- package/styles/image-editor/_material3-dark-definition.scss +1 -0
- package/styles/image-editor/_material3-definition.scss +11 -0
- package/styles/image-editor/_theme.scss +9 -2
- package/styles/image-editor/bootstrap-dark.css +69 -3
- package/styles/image-editor/bootstrap.css +69 -3
- package/styles/image-editor/bootstrap4.css +69 -3
- package/styles/image-editor/bootstrap5-dark.css +69 -3
- package/styles/image-editor/bootstrap5.css +69 -3
- package/styles/image-editor/fabric-dark.css +69 -3
- package/styles/image-editor/fabric.css +69 -3
- package/styles/image-editor/fluent-dark.css +69 -3
- package/styles/image-editor/fluent.css +69 -3
- package/styles/image-editor/highcontrast-light.css +69 -3
- package/styles/image-editor/highcontrast.css +69 -7
- package/styles/image-editor/icons/_bootstrap-dark.scss +132 -0
- package/styles/image-editor/icons/_bootstrap.scss +132 -0
- package/styles/image-editor/icons/_bootstrap4.scss +132 -0
- package/styles/image-editor/icons/_bootstrap5.scss +132 -0
- package/styles/image-editor/icons/_fabric-dark.scss +132 -0
- package/styles/image-editor/icons/_fabric.scss +132 -0
- package/styles/image-editor/icons/_fluent.scss +132 -0
- package/styles/image-editor/icons/_fusionnew.scss +132 -0
- package/styles/image-editor/icons/_highcontrast-light.scss +132 -0
- package/styles/image-editor/icons/_highcontrast.scss +132 -0
- package/styles/image-editor/icons/_material-dark.scss +132 -0
- package/styles/image-editor/icons/_material.scss +132 -0
- package/styles/image-editor/icons/_material3-dark.scss +1 -0
- package/styles/image-editor/icons/_material3.scss +133 -1
- package/styles/image-editor/icons/_tailwind.scss +132 -0
- package/styles/image-editor/material-dark.css +69 -3
- package/styles/image-editor/material.css +69 -3
- package/styles/image-editor/material3-dark.css +453 -0
- package/styles/image-editor/material3-dark.scss +14 -0
- package/styles/image-editor/material3.css +509 -0
- package/styles/image-editor/material3.scss +14 -0
- package/styles/image-editor/tailwind-dark.css +69 -3
- package/styles/image-editor/tailwind.css +69 -3
- package/styles/material-dark.css +69 -3
- package/styles/material.css +69 -3
- package/styles/material3-dark.css +453 -0
- package/styles/material3-dark.scss +3 -0
- package/styles/material3.css +509 -0
- package/styles/material3.scss +3 -0
- package/styles/tailwind-dark.css +69 -3
- package/styles/tailwind.css +69 -3
- package/src/image-editor/image-editor.js +0 -14827
|
@@ -0,0 +1,2657 @@
|
|
|
1
|
+
import { EventHandler, extend, isBlazor, isNullOrUndefined } from '@syncfusion/ej2-base';
|
|
2
|
+
import { ShapeType } from '../index';
|
|
3
|
+
var Shape = /** @class */ (function () {
|
|
4
|
+
function Shape(parent) {
|
|
5
|
+
this.textSettings = { text: 'Enter Text', fontFamily: 'Arial', fontSize: null, fontRatio: null, bold: false, italic: false, underline: false };
|
|
6
|
+
this.strokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null };
|
|
7
|
+
this.keyHistory = ''; // text history
|
|
8
|
+
this.parent = parent;
|
|
9
|
+
this.addEventListener();
|
|
10
|
+
}
|
|
11
|
+
Shape.prototype.destroy = function () {
|
|
12
|
+
if (this.parent.isDestroyed) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
this.removeEventListener();
|
|
16
|
+
};
|
|
17
|
+
Shape.prototype.addEventListener = function () {
|
|
18
|
+
this.parent.on('shape', this.shape, this);
|
|
19
|
+
this.parent.on('destroyed', this.destroy, this);
|
|
20
|
+
};
|
|
21
|
+
Shape.prototype.removeEventListener = function () {
|
|
22
|
+
this.parent.off('shape', this.shape);
|
|
23
|
+
this.parent.off('destroyed', this.destroy);
|
|
24
|
+
};
|
|
25
|
+
Shape.prototype.shape = function (args) {
|
|
26
|
+
this.initShapePvtProps();
|
|
27
|
+
switch (args.prop) {
|
|
28
|
+
case 'drawEllipse':
|
|
29
|
+
this.drawEllipse(args.value['x'], args.value['y'], args.value['radiusX'], args.value['radiusY'], args.value['strokeWidth'], args.value['strokeColor'], args.value['fillColor']);
|
|
30
|
+
break;
|
|
31
|
+
case 'drawLine':
|
|
32
|
+
this.drawLine(args.value['startX'], args.value['startY'], args.value['endX'], args.value['endY'], args.value['strokeWidth'], args.value['strokeColor']);
|
|
33
|
+
break;
|
|
34
|
+
case 'drawArrow':
|
|
35
|
+
this.drawArrow(args.value['startX'], args.value['startY'], args.value['endX'], args.value['endY'], args.value['strokeWidth'], args.value['strokeColor'], args.value['arrowStart'], args.value['arrowEnd']);
|
|
36
|
+
break;
|
|
37
|
+
case 'drawPath':
|
|
38
|
+
this.drawPath(args.value['pointColl'], args.value['strokeWidth'], args.value['strokeColor']);
|
|
39
|
+
break;
|
|
40
|
+
case 'drawRectangle':
|
|
41
|
+
this.drawRectangle(args.value['x'], args.value['y'], args.value['width'], args.value['height'], args.value['strokeWidt'], args.value['strokeColor'], args.value['fillColor']);
|
|
42
|
+
break;
|
|
43
|
+
case 'drawText':
|
|
44
|
+
this.drawText(args.value['x'], args.value['y'], args.value['text'], args.value['fontFamily'], args.value['fontSize'], args.value['bold'], args.value['italic'], args.value['color']);
|
|
45
|
+
break;
|
|
46
|
+
case 'redrawActObj':
|
|
47
|
+
this.redrawActObj(args.value['x'], args.value['y'], args.value['isMouseDown']);
|
|
48
|
+
break;
|
|
49
|
+
case 'apply':
|
|
50
|
+
this.apply(args.value['shape'], args.value['obj'], args.value['canvas']);
|
|
51
|
+
break;
|
|
52
|
+
case 'updateShapeChangeEventArgs':
|
|
53
|
+
this.updateShapeChangeEventArgs(args.value['shapeSettings']);
|
|
54
|
+
break;
|
|
55
|
+
case 'updSelChangeEventArgs':
|
|
56
|
+
this.updSelChangeEventArgs(args.value['selectionSettings']);
|
|
57
|
+
break;
|
|
58
|
+
case 'iterateObjColl':
|
|
59
|
+
this.iterateObjColl();
|
|
60
|
+
break;
|
|
61
|
+
case 'updImgRatioForActObj':
|
|
62
|
+
this.updImgRatioForActObj();
|
|
63
|
+
break;
|
|
64
|
+
case 'zoomObjColl':
|
|
65
|
+
this.zoomObjColl(args.value['isPreventApply']);
|
|
66
|
+
break;
|
|
67
|
+
case 'redrawObj':
|
|
68
|
+
this.redrawObj(args.value['degree']);
|
|
69
|
+
break;
|
|
70
|
+
case 'rotateObjColl':
|
|
71
|
+
this.rotateObjColl();
|
|
72
|
+
break;
|
|
73
|
+
case 'draw-shape-text':
|
|
74
|
+
this.drawShapeText();
|
|
75
|
+
break;
|
|
76
|
+
case 'redraw-text':
|
|
77
|
+
this.redrawText();
|
|
78
|
+
break;
|
|
79
|
+
case 'draw-shape':
|
|
80
|
+
this.drawShape(args.value['obj'], args.value['strokeWidth'], args.value['strokeColor'], args.value['fillColor'], args.value['start'], args.value['width'], args.value['height']);
|
|
81
|
+
break;
|
|
82
|
+
case 'renderTextArea':
|
|
83
|
+
this.renderTextArea(args.value['x'], args.value['y'], args.value['actObj']);
|
|
84
|
+
break;
|
|
85
|
+
case 'setTextBoxWidth':
|
|
86
|
+
this.setTextBoxWidth(args.value['e']);
|
|
87
|
+
break;
|
|
88
|
+
case 'findTextTarget':
|
|
89
|
+
this.findTextTarget(args.value['e']);
|
|
90
|
+
break;
|
|
91
|
+
case 'panObjColl':
|
|
92
|
+
this.panObjColl(args.value['xDiff'], args.value['yDiff'], args.value['panRegion']);
|
|
93
|
+
break;
|
|
94
|
+
case 'updateFontStyles':
|
|
95
|
+
this.updateFontStyles(args.value['isTextBox']);
|
|
96
|
+
break;
|
|
97
|
+
case 'applyFontStyle':
|
|
98
|
+
this.applyFontStyle(args.value['item']);
|
|
99
|
+
break;
|
|
100
|
+
case 'updateFontRatio':
|
|
101
|
+
this.updateFontRatio(args.value['obj'], args.value['isTextArea']);
|
|
102
|
+
break;
|
|
103
|
+
case 'updateFontSize':
|
|
104
|
+
this.updateFontSize(args.value['obj']);
|
|
105
|
+
break;
|
|
106
|
+
case 'updateObjColl':
|
|
107
|
+
this.updateObjColl(args.value['item'], args.value['objColl']);
|
|
108
|
+
break;
|
|
109
|
+
case 'pushActItemIntoObj':
|
|
110
|
+
this.pushActItemIntoObj();
|
|
111
|
+
break;
|
|
112
|
+
case 'clearActObj':
|
|
113
|
+
this.clearActObj();
|
|
114
|
+
break;
|
|
115
|
+
case 'refreshActiveObj':
|
|
116
|
+
this.refreshActiveObj();
|
|
117
|
+
break;
|
|
118
|
+
case 'applyActObj':
|
|
119
|
+
this.applyActObj(args.value['isMouseDown']);
|
|
120
|
+
break;
|
|
121
|
+
case 'wireEvent':
|
|
122
|
+
EventHandler.add(this.parent.upperCanvas, 'dblclick', this.findTextTarget, this);
|
|
123
|
+
EventHandler.add(this.parent.textArea, 'mousedown', this.findTextTarget, this);
|
|
124
|
+
break;
|
|
125
|
+
case 'unWireEvent':
|
|
126
|
+
EventHandler.remove(this.parent.upperCanvas, 'dblclick', this.findTextTarget);
|
|
127
|
+
EventHandler.remove(this.parent.textArea, 'mousedown', this.findTextTarget);
|
|
128
|
+
break;
|
|
129
|
+
case 'getShapeSetting':
|
|
130
|
+
this.getShapeSetting(args.value['id'], args.value['obj']);
|
|
131
|
+
break;
|
|
132
|
+
case 'getShapeSettings':
|
|
133
|
+
this.getShapeSettings(args.value['obj']);
|
|
134
|
+
break;
|
|
135
|
+
case 'isPointsInRange':
|
|
136
|
+
this.isPointsInRange(args.value['x'], args.value['y'], args.value['obj']);
|
|
137
|
+
break;
|
|
138
|
+
case 'alignRotateFlipColl':
|
|
139
|
+
this.alignRotateFlipColl(args.value['collection'], args.value['isRotateFlipCollection'], args.value['obj']);
|
|
140
|
+
break;
|
|
141
|
+
case 'selectShape':
|
|
142
|
+
this.selectShape(args.value['id'], args.value['obj']);
|
|
143
|
+
break;
|
|
144
|
+
case 'deleteShape':
|
|
145
|
+
this.deleteShape(args.value['id']);
|
|
146
|
+
break;
|
|
147
|
+
case 'getMaxText':
|
|
148
|
+
this.getMaxText(args.value['isTextBox'], args.value['text'], args.value['obj']);
|
|
149
|
+
break;
|
|
150
|
+
case 'setPointCollForLineArrow':
|
|
151
|
+
args.value['obj'].pointColl = this.getLinePoints(args.value['obj'].activePoint.startX, args.value['obj'].activePoint.startY, args.value['obj'].activePoint.endX, args.value['obj'].activePoint.endY);
|
|
152
|
+
break;
|
|
153
|
+
case 'setPointCollForShapeRotation':
|
|
154
|
+
this.setPointCollForShapeRotation(args.value['obj']);
|
|
155
|
+
break;
|
|
156
|
+
case 'setTextSettings':
|
|
157
|
+
if (args.value['textSettings']) {
|
|
158
|
+
this.textSettings = args.value['textSettings'];
|
|
159
|
+
}
|
|
160
|
+
else if (args.value['fontFamily']) {
|
|
161
|
+
this.textSettings.fontFamily = args.value['fontFamily'];
|
|
162
|
+
}
|
|
163
|
+
else if (args.value['fontSize']) {
|
|
164
|
+
this.textSettings.fontSize = args.value['fontSize'];
|
|
165
|
+
}
|
|
166
|
+
break;
|
|
167
|
+
case 'setStrokeSettings':
|
|
168
|
+
if (args.value['strokeSettings']) {
|
|
169
|
+
this.strokeSettings = args.value['strokeSettings'];
|
|
170
|
+
}
|
|
171
|
+
else if (args.value['strokeColor']) {
|
|
172
|
+
this.strokeSettings.strokeColor = args.value['strokeColor'];
|
|
173
|
+
}
|
|
174
|
+
else if (args.value['fillColor']) {
|
|
175
|
+
this.strokeSettings.fillColor = args.value['fillColor'];
|
|
176
|
+
}
|
|
177
|
+
else if (args.value['strokeWidth']) {
|
|
178
|
+
this.strokeSettings.strokeWidth = args.value['strokeWidth'];
|
|
179
|
+
}
|
|
180
|
+
break;
|
|
181
|
+
case 'getStrokeSettings':
|
|
182
|
+
args.value['obj']['strokeSettings'] = this.strokeSettings;
|
|
183
|
+
break;
|
|
184
|
+
case 'setKeyHistory':
|
|
185
|
+
this.keyHistory = args.value['keyHistory'];
|
|
186
|
+
break;
|
|
187
|
+
case 'getKeyHistory':
|
|
188
|
+
args.value['obj']['keyHistory'] = this.keyHistory;
|
|
189
|
+
break;
|
|
190
|
+
case 'setTextBoxPos':
|
|
191
|
+
this.setTextBoxPos(args.value['actObj'], args.value['degree'], args.value['flip'], args.value['x'], args.value['y']);
|
|
192
|
+
break;
|
|
193
|
+
case 'setTextBoxPoints':
|
|
194
|
+
this.setTextBoxPoints(args.value['actObj'], args.value['degree'], args.value['flip'], args.value['x'], args.value['y']);
|
|
195
|
+
break;
|
|
196
|
+
case 'alignTextAreaIntoCanvas':
|
|
197
|
+
this.alignTextAreaIntoCanvas();
|
|
198
|
+
break;
|
|
199
|
+
case 'initializeTextShape':
|
|
200
|
+
this.initializeTextShape(args.value['text'], args.value['fontFamily'], args.value['fontSize'], args.value['bold'], args.value['italic'], args.value['strokeColor']);
|
|
201
|
+
break;
|
|
202
|
+
case 'stopPathDrawing':
|
|
203
|
+
this.stopPathDrawing(args.value['e']);
|
|
204
|
+
break;
|
|
205
|
+
case 'updateArrowRatio':
|
|
206
|
+
this.updateArrowRatio(args.value['obj']);
|
|
207
|
+
break;
|
|
208
|
+
case 'reset':
|
|
209
|
+
this.reset();
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
Shape.prototype.getModuleName = function () {
|
|
214
|
+
return 'shape';
|
|
215
|
+
};
|
|
216
|
+
Shape.prototype.initShapePvtProps = function () {
|
|
217
|
+
if (this.parent.lowerCanvas) {
|
|
218
|
+
this.lowerContext = this.parent.lowerCanvas.getContext('2d');
|
|
219
|
+
}
|
|
220
|
+
if (this.parent.upperCanvas) {
|
|
221
|
+
this.upperContext = this.parent.upperCanvas.getContext('2d');
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
Shape.prototype.reset = function () {
|
|
225
|
+
this.textSettings =
|
|
226
|
+
{ text: 'Enter Text', fontFamily: 'Arial', fontSize: null, fontRatio: null, bold: false, italic: false, underline: false };
|
|
227
|
+
this.strokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null };
|
|
228
|
+
};
|
|
229
|
+
Shape.prototype.drawEllipse = function (x, y, radiusX, radiusY, strokeWidth, strokeColor, fillColor) {
|
|
230
|
+
this.initializeShape('ellipse');
|
|
231
|
+
var start = { x: x, y: y };
|
|
232
|
+
this.drawShape('ellipse', strokeWidth, strokeColor, fillColor, start, radiusX, radiusY);
|
|
233
|
+
};
|
|
234
|
+
Shape.prototype.drawLine = function (startX, startY, endX, endY, strokeWidth, strokeColor) {
|
|
235
|
+
this.initializeShape('line');
|
|
236
|
+
var start = { x: startX, y: startY };
|
|
237
|
+
var width = endX - startX;
|
|
238
|
+
var height = endY - startY;
|
|
239
|
+
this.drawShape('line', strokeWidth, strokeColor, null, start, width, height);
|
|
240
|
+
};
|
|
241
|
+
Shape.prototype.drawPath = function (pointColl, strokeWidth, strokeColor) {
|
|
242
|
+
this.initializeShape('path');
|
|
243
|
+
this.drawShape('path', strokeWidth, strokeColor, null, null, null, null, pointColl);
|
|
244
|
+
};
|
|
245
|
+
Shape.prototype.drawArrow = function (startX, startY, endX, endY, strokeWidth, strokeColor, arrowStart, arrowEnd) {
|
|
246
|
+
this.initializeShape('arrow');
|
|
247
|
+
var start = { x: startX, y: startY };
|
|
248
|
+
var width = endX - startX;
|
|
249
|
+
var height = endY - startY;
|
|
250
|
+
this.drawShape('arrow', strokeWidth, strokeColor, null, start, width, height, null, arrowStart, arrowEnd);
|
|
251
|
+
};
|
|
252
|
+
Shape.prototype.drawRectangle = function (x, y, width, height, strokeWidth, strokeColor, fillColor) {
|
|
253
|
+
this.initializeShape('rectangle');
|
|
254
|
+
var start = { x: x, y: y };
|
|
255
|
+
this.drawShape('rectangle', strokeWidth, strokeColor, fillColor, start, width, height);
|
|
256
|
+
};
|
|
257
|
+
Shape.prototype.drawText = function (x, y, text, fontFamily, fontSize, bold, italic, color) {
|
|
258
|
+
this.drawShapeText(text, fontFamily, fontSize, bold, italic, color, x, y);
|
|
259
|
+
};
|
|
260
|
+
Shape.prototype.initializeShape = function (type) {
|
|
261
|
+
this.redrawActObj();
|
|
262
|
+
this.parent.activeObj.shape = type;
|
|
263
|
+
if (this.parent.currObjType.shape === 'freehanddraw') {
|
|
264
|
+
this.apply();
|
|
265
|
+
this.parent.upperCanvas.style.cursor = this.parent.cursor = 'default';
|
|
266
|
+
this.parent.currObjType.shape = '';
|
|
267
|
+
}
|
|
268
|
+
this.parent.currObjType.isCustomCrop = false;
|
|
269
|
+
};
|
|
270
|
+
Shape.prototype.updateWidthHeight = function (obj) {
|
|
271
|
+
obj.activePoint.width = obj.activePoint.endX - obj.activePoint.startX;
|
|
272
|
+
obj.activePoint.height = obj.activePoint.endY - obj.activePoint.startY;
|
|
273
|
+
return obj;
|
|
274
|
+
};
|
|
275
|
+
Shape.prototype.setDimension = function (width, height) {
|
|
276
|
+
if (width && height) {
|
|
277
|
+
this.parent.activeObj.activePoint.width = width;
|
|
278
|
+
this.parent.activeObj.activePoint.height = height;
|
|
279
|
+
if (this.parent.currObjType.shape.toLowerCase() === 'ellipse') {
|
|
280
|
+
this.parent.activeObj.activePoint.width = 2 * width;
|
|
281
|
+
this.parent.activeObj.activePoint.height = 2 * height;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
Shape.prototype.getArrowType = function (type) {
|
|
286
|
+
var arrowType = type;
|
|
287
|
+
if (type) {
|
|
288
|
+
var typeToArrowType = { 'None': 'none', 'Arrow': 'arrow', 'SolidArrow': 'arrowSolid',
|
|
289
|
+
'Circle': 'circle', 'SolidCircle': 'circleSolid', 'Square': 'square', 'SolidSquare': 'squareSolid', 'Bar': 'bar' };
|
|
290
|
+
arrowType = typeToArrowType["" + type];
|
|
291
|
+
}
|
|
292
|
+
return arrowType;
|
|
293
|
+
};
|
|
294
|
+
Shape.prototype.drawShape = function (type, strokeWidth, strokeColor, fillColor, start, width, height, pointColl, arrowStart, arrowEnd) {
|
|
295
|
+
var _this = this;
|
|
296
|
+
var parent = this.parent;
|
|
297
|
+
if (!parent.disabled && parent.isImageLoaded) {
|
|
298
|
+
parent.notify('draw', { prop: 'setImageEdited', onPropertyChange: false });
|
|
299
|
+
this.redrawActObj();
|
|
300
|
+
var objColl_1 = extend([], parent.objColl, [], true);
|
|
301
|
+
parent.togglePen = false;
|
|
302
|
+
this.keyHistory = '';
|
|
303
|
+
this.parent.upperCanvas.style.display = 'block';
|
|
304
|
+
this.refreshActiveObj();
|
|
305
|
+
parent.currObjType.shape = type;
|
|
306
|
+
if (parent.currObjType.shape.toLowerCase() === 'path' && isNullOrUndefined(pointColl)) {
|
|
307
|
+
parent.activeObj.shape = parent.currObjType.shape.toLowerCase();
|
|
308
|
+
parent.activeObj.pointColl = [];
|
|
309
|
+
parent.upperCanvas.style.cursor = this.parent.cursor = 'crosshair';
|
|
310
|
+
parent.notify('selection', { prop: 'setCurrentDrawingShape', onPropertyChange: false, value: { value: 'path' } });
|
|
311
|
+
if (!isBlazor()) {
|
|
312
|
+
parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'shapes',
|
|
313
|
+
isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
|
|
314
|
+
parent.notify('toolbar', { prop: 'update-toolbar-items', onPropertyChange: false });
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
if (parent.currObjType.shape.toLowerCase() !== 'freehanddraw' && parent.currObjType.shape.toLowerCase() !== '') {
|
|
319
|
+
parent.activeObj.shape = parent.currObjType.shape.toLowerCase();
|
|
320
|
+
this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
|
|
321
|
+
if (isNullOrUndefined(parent.activeObj.strokeSettings)) {
|
|
322
|
+
parent.activeObj.strokeSettings = this.strokeSettings;
|
|
323
|
+
}
|
|
324
|
+
if (parent.currObjType.shape.toLowerCase() === 'path' && pointColl) {
|
|
325
|
+
parent.activeObj.pointColl = pointColl;
|
|
326
|
+
}
|
|
327
|
+
parent.activeObj.strokeSettings.strokeWidth = strokeWidth ? strokeWidth : parent.activeObj.strokeSettings.strokeWidth;
|
|
328
|
+
parent.activeObj.strokeSettings.strokeColor = strokeColor ? strokeColor : parent.activeObj.strokeSettings.strokeColor;
|
|
329
|
+
parent.activeObj.strokeSettings.fillColor = fillColor ? fillColor : parent.activeObj.strokeSettings.fillColor;
|
|
330
|
+
var tempWidth = parent.img.destWidth > 100 ? 100 : parent.img.destWidth / 2;
|
|
331
|
+
var tempHeight = parent.img.destHeight > 100 ? 100 : parent.img.destHeight / 2;
|
|
332
|
+
parent.activeObj.activePoint.width = tempWidth;
|
|
333
|
+
parent.activeObj.activePoint.height = tempHeight;
|
|
334
|
+
if (parent.currObjType.shape.toLowerCase() === 'line' || parent.currObjType.shape.toLowerCase() === 'arrow') {
|
|
335
|
+
parent.activeObj.lineDraw = 'horizontal';
|
|
336
|
+
parent.activeObj.activePoint.height = 0;
|
|
337
|
+
if (parent.currObjType.shape.toLowerCase() === 'arrow') {
|
|
338
|
+
parent.activeObj.activePoint.width += 50;
|
|
339
|
+
parent.activeObj.start = this.getArrowType(arrowStart);
|
|
340
|
+
parent.activeObj.end = this.getArrowType(arrowEnd);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
else if (parent.currObjType.shape.toLowerCase() === 'rectangle') {
|
|
344
|
+
parent.activeObj.activePoint.width += parent.activeObj.activePoint.width / 2;
|
|
345
|
+
}
|
|
346
|
+
this.setDimension(width, height);
|
|
347
|
+
if (start) {
|
|
348
|
+
parent.activeObj.activePoint.startX = start.x;
|
|
349
|
+
parent.activeObj.activePoint.startY = start.y;
|
|
350
|
+
parent.activeObj.activePoint.endX = parent.activeObj.activePoint.startX +
|
|
351
|
+
parent.activeObj.activePoint.width;
|
|
352
|
+
parent.activeObj.activePoint.endY = parent.activeObj.activePoint.startY +
|
|
353
|
+
parent.activeObj.activePoint.height;
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
this.setCenterPoints();
|
|
357
|
+
}
|
|
358
|
+
this.setPointCollForLineAndArrow();
|
|
359
|
+
if (parent.currObjType.shape.toLowerCase() === 'arrow') {
|
|
360
|
+
parent.activeObj.triangleDirection = 'right';
|
|
361
|
+
}
|
|
362
|
+
parent.currObjType.isDragging = parent.currObjType.isCustomCrop = false;
|
|
363
|
+
parent.activeObj.shapeDegree = parent.transform.degree;
|
|
364
|
+
parent.activeObj.shapeFlip = parent.transform.currFlipState;
|
|
365
|
+
parent.activeObj.textFlip = parent.transform.currFlipState;
|
|
366
|
+
parent.activeObj.flipObjColl = [];
|
|
367
|
+
var obj = { shapeSettingsObj: {} };
|
|
368
|
+
parent.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: obj } });
|
|
369
|
+
var shapeSettings = obj['shapeSettingsObj'];
|
|
370
|
+
var shapeChangingArgs = { action: 'insert', previousShapeSettings: shapeSettings,
|
|
371
|
+
currentShapeSettings: shapeSettings };
|
|
372
|
+
if (isBlazor() && parent.events && parent.events.shapeChanging.hasDelegate === true) {
|
|
373
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
374
|
+
this.parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShape', shapeChangingArgs).then(function (shapeChangingArgs) {
|
|
375
|
+
_this.updateShapeChangeEventArgs(shapeChangingArgs.currentShapeSettings);
|
|
376
|
+
_this.setDimension(width, height);
|
|
377
|
+
parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate' } });
|
|
378
|
+
parent.updateToolbar(parent.element, 'quickAccessToolbar', 'shape');
|
|
379
|
+
parent.notify('selection', { prop: 'isShapeInserted', onPropertyChange: false, value: { bool: true } });
|
|
380
|
+
parent.notify('undo-redo', { prop: 'updateUrObj', onPropertyChange: false, value: { objColl: objColl_1 } });
|
|
381
|
+
if (parent.isPublicMethod) {
|
|
382
|
+
parent.notify('undo-redo', { prop: 'updateUndoRedo', onPropertyChange: false });
|
|
383
|
+
}
|
|
384
|
+
parent.isPublicMethod = false;
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
parent.trigger('shapeChanging', shapeChangingArgs);
|
|
389
|
+
this.updateShapeChangeEventArgs(shapeChangingArgs.currentShapeSettings);
|
|
390
|
+
this.setDimension(width, height);
|
|
391
|
+
parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate' } });
|
|
392
|
+
if (!isBlazor()) {
|
|
393
|
+
parent.notify('toolbar', { prop: 'renderQAT', onPropertyChange: false, value: { isPenEdit: null } });
|
|
394
|
+
}
|
|
395
|
+
else {
|
|
396
|
+
parent.updateToolbar(parent.element, 'quickAccessToolbar', 'shape');
|
|
397
|
+
}
|
|
398
|
+
parent.notify('selection', { prop: 'isShapeInserted', onPropertyChange: false, value: { bool: true } });
|
|
399
|
+
parent.notify('undo-redo', { prop: 'updateUrObj', onPropertyChange: false, value: { objColl: objColl_1 } });
|
|
400
|
+
parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'shapes',
|
|
401
|
+
isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
|
|
402
|
+
parent.notify('toolbar', { prop: 'update-toolbar-items', onPropertyChange: false });
|
|
403
|
+
if (parent.isPublicMethod) {
|
|
404
|
+
parent.notify('undo-redo', { prop: 'updateUndoRedo', onPropertyChange: false });
|
|
405
|
+
}
|
|
406
|
+
parent.isPublicMethod = false;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
Shape.prototype.setPointCollForLineAndArrow = function () {
|
|
413
|
+
var parent = this.parent;
|
|
414
|
+
if (parent.activeObj.shape === 'line' || parent.activeObj.shape === 'arrow') {
|
|
415
|
+
parent.activeObj.pointColl = this.getLinePoints(parent.activeObj.activePoint.startX, parent.activeObj.activePoint.startY, parent.activeObj.activePoint.endX, parent.activeObj.activePoint.endY);
|
|
416
|
+
if (!isNullOrUndefined(parent.activeObj.pointColl)) {
|
|
417
|
+
for (var i = 0, len = parent.activeObj.pointColl.length; i < len; i++) {
|
|
418
|
+
parent.activeObj.pointColl[i].ratioX = (parent.activeObj.pointColl[i].x -
|
|
419
|
+
parent.img.destLeft) / parent.img.destWidth;
|
|
420
|
+
parent.activeObj.pointColl[i].ratioY = (parent.activeObj.pointColl[i].y -
|
|
421
|
+
parent.img.destTop) / parent.img.destHeight;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
Shape.prototype.drawShapeText = function (text, fontFamily, fontSize, bold, italic, strokeColor, x, y) {
|
|
427
|
+
var _this = this;
|
|
428
|
+
var parent = this.parent;
|
|
429
|
+
if (!parent.disabled && parent.isImageLoaded) {
|
|
430
|
+
if (parent.currObjType.shape === 'freehanddraw') {
|
|
431
|
+
this.apply();
|
|
432
|
+
parent.upperCanvas.style.cursor = parent.cursor = 'default';
|
|
433
|
+
parent.currObjType.shape = '';
|
|
434
|
+
}
|
|
435
|
+
parent.notify('draw', { prop: 'setImageEdited', onPropertyChange: false });
|
|
436
|
+
parent.togglePen = false;
|
|
437
|
+
this.redrawActObj();
|
|
438
|
+
var object = { currObj: {} };
|
|
439
|
+
parent.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
|
|
440
|
+
this.prevObj = object['currObj'];
|
|
441
|
+
this.prevObj.objColl = extend([], parent.objColl, [], true);
|
|
442
|
+
this.prevObj.pointColl = extend([], parent.pointColl, [], true);
|
|
443
|
+
this.prevObj.afterCropActions = extend([], parent.afterCropActions, [], true);
|
|
444
|
+
var selPointCollObj = { selPointColl: null };
|
|
445
|
+
parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
|
|
446
|
+
value: { obj: selPointCollObj } });
|
|
447
|
+
this.prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
|
|
448
|
+
this.refreshActiveObj();
|
|
449
|
+
parent.activeObj.shape = parent.currObjType.shape = 'text';
|
|
450
|
+
parent.currObjType.isCustomCrop = false;
|
|
451
|
+
this.initializeTextShape(text, fontFamily, fontSize, bold, italic, strokeColor);
|
|
452
|
+
parent.currObjType.isText = parent.currObjType.isInitialText = true;
|
|
453
|
+
if (isNullOrUndefined(parent.activeObj.textSettings.fontSize)) {
|
|
454
|
+
if (parent.img.destWidth > parent.img.destHeight) {
|
|
455
|
+
parent.activeObj.textSettings.fontSize = (parent.img.destWidth / 15);
|
|
456
|
+
}
|
|
457
|
+
else {
|
|
458
|
+
parent.activeObj.textSettings.fontSize = (parent.img.destHeight / 15);
|
|
459
|
+
}
|
|
460
|
+
if (parent.activeObj.textSettings.fontSize < 20) {
|
|
461
|
+
parent.activeObj.textSettings.fontSize = 20;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
if (parent.img.destWidth < 100) {
|
|
465
|
+
parent.activeObj.textSettings.fontSize = Math.floor((parent.img.destWidth / 20));
|
|
466
|
+
}
|
|
467
|
+
else if (parent.img.destHeight < 100) {
|
|
468
|
+
parent.activeObj.textSettings.fontSize = Math.floor((parent.img.destHeight / 20));
|
|
469
|
+
}
|
|
470
|
+
parent.activeObj.shapeDegree = parent.transform.degree;
|
|
471
|
+
parent.activeObj.shapeFlip = parent.transform.currFlipState;
|
|
472
|
+
parent.activeObj.flipObjColl = [];
|
|
473
|
+
this.updateFontStyles();
|
|
474
|
+
var width = this.upperContext.measureText(parent.activeObj.textSettings.text).width +
|
|
475
|
+
parent.activeObj.textSettings.fontSize * 0.5;
|
|
476
|
+
var height = parent.activeObj.textSettings.fontSize + parent.activeObj.textSettings.fontSize * 0.25;
|
|
477
|
+
if (!isNullOrUndefined(x) && !isNullOrUndefined(y)) {
|
|
478
|
+
parent.activeObj.activePoint.startX = x;
|
|
479
|
+
parent.activeObj.activePoint.startY = y;
|
|
480
|
+
parent.activeObj.activePoint.endX = parent.activeObj.activePoint.startX + width;
|
|
481
|
+
parent.activeObj.activePoint.endY = parent.activeObj.activePoint.startY + height;
|
|
482
|
+
}
|
|
483
|
+
else {
|
|
484
|
+
this.setCenterPoints(true, width, height);
|
|
485
|
+
}
|
|
486
|
+
var obj = { shapeSettingsObj: {} };
|
|
487
|
+
parent.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: obj } });
|
|
488
|
+
var shapeSettings = obj['shapeSettingsObj'];
|
|
489
|
+
var shapeChangingArgs = { action: 'insert', previousShapeSettings: shapeSettings,
|
|
490
|
+
currentShapeSettings: shapeSettings };
|
|
491
|
+
if (isBlazor() && parent.events && parent.events.shapeChanging.hasDelegate === true) {
|
|
492
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
493
|
+
parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShape', shapeChangingArgs).then(function (shapeChangingArgs) {
|
|
494
|
+
_this.drawShapeTextEvent(shapeChangingArgs);
|
|
495
|
+
if (parent.isPublicMethod) {
|
|
496
|
+
parent.notify('undo-redo', { prop: 'updateUndoRedo', onPropertyChange: false });
|
|
497
|
+
}
|
|
498
|
+
parent.isPublicMethod = false;
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
else {
|
|
502
|
+
parent.trigger('shapeChanging', shapeChangingArgs);
|
|
503
|
+
this.drawShapeTextEvent(shapeChangingArgs);
|
|
504
|
+
if (parent.isPublicMethod) {
|
|
505
|
+
parent.notify('undo-redo', { prop: 'updateUndoRedo', onPropertyChange: false });
|
|
506
|
+
}
|
|
507
|
+
parent.isPublicMethod = false;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
Shape.prototype.drawShapeTextEvent = function (shapeChangingArgs) {
|
|
512
|
+
var parent = this.parent;
|
|
513
|
+
this.updateShapeChangeEventArgs(shapeChangingArgs.currentShapeSettings);
|
|
514
|
+
this.addLetter(parent.activeObj.textSettings.text);
|
|
515
|
+
parent.activeObj.textFlip = parent.transform.currFlipState;
|
|
516
|
+
this.updateFontRatio(parent.activeObj);
|
|
517
|
+
parent.objColl.push(parent.activeObj);
|
|
518
|
+
var prevCropObj = extend({}, parent.cropObj, {}, true);
|
|
519
|
+
parent.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
|
|
520
|
+
value: { operation: 'shapeTransform', previousObj: this.prevObj, previousObjColl: this.prevObj.objColl,
|
|
521
|
+
previousPointColl: this.prevObj.pointColl, previousSelPointColl: this.prevObj.selPointColl,
|
|
522
|
+
previousCropObj: prevCropObj, previousText: null,
|
|
523
|
+
currentText: null, previousFilter: null, isCircleCrop: null } });
|
|
524
|
+
parent.notify('selection', { prop: 'redrawShape', onPropertyChange: false,
|
|
525
|
+
value: { obj: parent.objColl[parent.objColl.length - 1] } });
|
|
526
|
+
if (!isBlazor()) {
|
|
527
|
+
parent.notify('toolbar', { prop: 'renderQAT', onPropertyChange: false, value: { isPenEdit: null } });
|
|
528
|
+
}
|
|
529
|
+
else {
|
|
530
|
+
parent.updateToolbar(parent.element, 'quickAccessToolbar', 'text');
|
|
531
|
+
}
|
|
532
|
+
parent.notify('selection', { prop: 'isShapeInserted', onPropertyChange: false, value: { bool: true } });
|
|
533
|
+
if (!isBlazor()) {
|
|
534
|
+
parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'text',
|
|
535
|
+
isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
|
|
536
|
+
parent.notify('toolbar', { prop: 'update-toolbar-items', onPropertyChange: false });
|
|
537
|
+
}
|
|
538
|
+
};
|
|
539
|
+
Shape.prototype.initializeTextShape = function (text, fontFamily, fontSize, bold, italic, strokeColor) {
|
|
540
|
+
var parent = this.parent;
|
|
541
|
+
this.keyHistory = '';
|
|
542
|
+
parent.upperCanvas.style.display = 'block';
|
|
543
|
+
if (isNullOrUndefined(parent.activeObj.textSettings)) {
|
|
544
|
+
parent.activeObj.textSettings = this.textSettings;
|
|
545
|
+
}
|
|
546
|
+
if (isNullOrUndefined(parent.activeObj.strokeSettings)) {
|
|
547
|
+
parent.activeObj.strokeSettings = this.strokeSettings;
|
|
548
|
+
}
|
|
549
|
+
parent.activeObj.strokeSettings.strokeColor = strokeColor || parent.activeObj.strokeSettings.strokeColor;
|
|
550
|
+
parent.activeObj.textSettings.text = text || parent.activeObj.textSettings.text;
|
|
551
|
+
parent.activeObj.textSettings.fontFamily = fontFamily || parent.activeObj.textSettings.fontFamily;
|
|
552
|
+
parent.activeObj.textSettings.fontSize = fontSize || parent.activeObj.textSettings.fontSize;
|
|
553
|
+
parent.activeObj.textSettings.bold = bold || parent.activeObj.textSettings.bold;
|
|
554
|
+
parent.activeObj.textSettings.italic = italic || parent.activeObj.textSettings.italic;
|
|
555
|
+
};
|
|
556
|
+
Shape.prototype.redrawActObj = function (x, y, isMouseDown) {
|
|
557
|
+
var splitWords;
|
|
558
|
+
var parent = this.parent;
|
|
559
|
+
if (parent.activeObj.shape) {
|
|
560
|
+
splitWords = parent.activeObj.shape.split('-');
|
|
561
|
+
}
|
|
562
|
+
if (parent.activeObj.horTopLine && (parent.activeObj.shape && splitWords[0] !== 'crop')) {
|
|
563
|
+
if (parent.textArea.style.display === 'block') {
|
|
564
|
+
parent.notify('selection', { prop: 'setTextBoxStylesToActObj', onPropertyChange: false });
|
|
565
|
+
this.updateFontRatio(parent.activeObj, true);
|
|
566
|
+
if (x && y) {
|
|
567
|
+
if ((x !== parent.activeObj.activePoint.startX) && (y !== parent.activeObj.activePoint.startY)) {
|
|
568
|
+
this.updateTextFromTextArea();
|
|
569
|
+
this.applyActObj();
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
else {
|
|
573
|
+
this.updateTextFromTextArea();
|
|
574
|
+
this.apply(parent.activeObj.shape, parent.activeObj);
|
|
575
|
+
parent.objColl.push(parent.activeObj);
|
|
576
|
+
this.refreshActiveObj();
|
|
577
|
+
parent.textArea.style.transform = '';
|
|
578
|
+
parent.notify('toolbar', { prop: 'refresh-main-toolbar', onPropertyChange: false });
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
else {
|
|
582
|
+
this.applyActObj(isMouseDown);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
};
|
|
586
|
+
Shape.prototype.apply = function (shape, obj, canvas) {
|
|
587
|
+
var parent = this.parent;
|
|
588
|
+
if (!parent.disabled) {
|
|
589
|
+
if (parent.togglePen && !parent.currObjType.isCustomCrop) {
|
|
590
|
+
var destLeft = parent.img.destLeft;
|
|
591
|
+
var destTop = parent.img.destTop;
|
|
592
|
+
var destWidth = parent.img.destWidth;
|
|
593
|
+
var destHeight = parent.img.destHeight;
|
|
594
|
+
parent.notify('draw', { prop: 'callUpdateCurrTransState', onPropertyChange: false });
|
|
595
|
+
var temp = this.lowerContext.filter;
|
|
596
|
+
this.lowerContext.filter = 'none';
|
|
597
|
+
parent.togglePen = false;
|
|
598
|
+
this.iterateObjColl();
|
|
599
|
+
parent.notify('freehandDraw', { prop: 'freehandRedraw', onPropertyChange: false,
|
|
600
|
+
value: { context: this.lowerContext, points: null } });
|
|
601
|
+
parent.togglePen = false;
|
|
602
|
+
if (parent.isCircleCrop || (parent.currSelectionPoint &&
|
|
603
|
+
parent.currSelectionPoint.shape === 'crop-circle')) {
|
|
604
|
+
parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
|
|
605
|
+
value: { context: this.lowerContext, isSave: null, isFlip: null } });
|
|
606
|
+
}
|
|
607
|
+
parent.img.destLeft = destLeft;
|
|
608
|
+
parent.img.destTop = destTop;
|
|
609
|
+
parent.img.destWidth = destWidth;
|
|
610
|
+
parent.img.destHeight = destHeight;
|
|
611
|
+
this.lowerContext.filter = temp;
|
|
612
|
+
}
|
|
613
|
+
else {
|
|
614
|
+
canvas = canvas ? canvas : 'original';
|
|
615
|
+
if (isNullOrUndefined(parent.activeObj.shape) && isNullOrUndefined(shape)) {
|
|
616
|
+
parent.currObjType.shape = '';
|
|
617
|
+
}
|
|
618
|
+
else {
|
|
619
|
+
parent.currObjType.shape = shape || parent.currObjType.shape;
|
|
620
|
+
}
|
|
621
|
+
if (parent.currObjType.shape !== '') {
|
|
622
|
+
this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
|
|
623
|
+
if (parent.activeObj.shape === 'text') {
|
|
624
|
+
parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: canvas, obj: obj, isCropRatio: null,
|
|
625
|
+
points: null, isPreventDrag: true, saveContext: null, isPreventSelection: null } });
|
|
626
|
+
parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
|
|
627
|
+
}
|
|
628
|
+
else {
|
|
629
|
+
parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: canvas, obj: obj } });
|
|
630
|
+
}
|
|
631
|
+
parent.activeObj.shape = parent.currObjType.shape.toLowerCase();
|
|
632
|
+
if (!shape && parent.currObjType.shape !== '' && !parent.currObjType.isCustomCrop) {
|
|
633
|
+
parent.objColl.push(extend({}, parent.activeObj, {}, true));
|
|
634
|
+
}
|
|
635
|
+
this.keyHistory = '';
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
Shape.prototype.setCenterPoints = function (text, width, height) {
|
|
641
|
+
var parent = this.parent;
|
|
642
|
+
var renderWidth;
|
|
643
|
+
var renderHeight;
|
|
644
|
+
if (text && width && height) {
|
|
645
|
+
renderWidth = width;
|
|
646
|
+
renderHeight = height;
|
|
647
|
+
}
|
|
648
|
+
else {
|
|
649
|
+
renderWidth = parent.activeObj.activePoint.width;
|
|
650
|
+
renderHeight = parent.activeObj.activePoint.height;
|
|
651
|
+
}
|
|
652
|
+
parent.activeObj.activePoint.startX = (parent.lowerCanvas.width / 2) - renderWidth / 2;
|
|
653
|
+
parent.activeObj.activePoint.startY = (parent.lowerCanvas.height / 2) - renderHeight / 2;
|
|
654
|
+
parent.activeObj.activePoint.endX = (parent.lowerCanvas.width / 2) + renderWidth / 2;
|
|
655
|
+
parent.activeObj.activePoint.endY = (parent.lowerCanvas.height / 2) + renderHeight / 2;
|
|
656
|
+
};
|
|
657
|
+
Shape.prototype.updSelChangeEventArgs = function (selectionSettings) {
|
|
658
|
+
var parent = this.parent;
|
|
659
|
+
parent.activeObj.activePoint.startX = selectionSettings.startX;
|
|
660
|
+
parent.activeObj.activePoint.startY = selectionSettings.startY;
|
|
661
|
+
parent.activeObj.activePoint.width = selectionSettings.width;
|
|
662
|
+
parent.activeObj.activePoint.height = selectionSettings.height;
|
|
663
|
+
parent.activeObj.activePoint.endX = parent.activeObj.activePoint.startX + parent.activeObj.activePoint.width;
|
|
664
|
+
parent.activeObj.activePoint.endY = parent.activeObj.activePoint.startY + parent.activeObj.activePoint.height;
|
|
665
|
+
};
|
|
666
|
+
Shape.prototype.updateShapeChangeEventArgs = function (shapeSettings) {
|
|
667
|
+
var parent = this.parent;
|
|
668
|
+
parent.activeObj.currIndex = shapeSettings.id;
|
|
669
|
+
parent.activeObj.activePoint.startX = shapeSettings.startX;
|
|
670
|
+
parent.activeObj.activePoint.startY = shapeSettings.startY;
|
|
671
|
+
parent.activeObj.activePoint.width = shapeSettings.width;
|
|
672
|
+
parent.activeObj.activePoint.height = shapeSettings.height;
|
|
673
|
+
parent.activeObj.activePoint.endX = parent.activeObj.activePoint.startX + parent.activeObj.activePoint.width;
|
|
674
|
+
parent.activeObj.activePoint.endY = parent.activeObj.activePoint.startY + parent.activeObj.activePoint.height;
|
|
675
|
+
parent.activeObj.strokeSettings.strokeColor = shapeSettings.strokeColor;
|
|
676
|
+
parent.activeObj.strokeSettings.fillColor = shapeSettings.fillColor;
|
|
677
|
+
switch (parent.activeObj.shape) {
|
|
678
|
+
case 'ellipse':
|
|
679
|
+
parent.activeObj.activePoint.width = shapeSettings.radius / 2;
|
|
680
|
+
break;
|
|
681
|
+
case 'line':
|
|
682
|
+
case 'arrow':
|
|
683
|
+
parent.activeObj.activePoint.width = shapeSettings.length;
|
|
684
|
+
break;
|
|
685
|
+
case 'text':
|
|
686
|
+
parent.activeObj.keyHistory = shapeSettings.text;
|
|
687
|
+
parent.activeObj.textSettings.fontSize = shapeSettings.fontSize;
|
|
688
|
+
parent.activeObj.strokeSettings.strokeColor = shapeSettings.color;
|
|
689
|
+
break;
|
|
690
|
+
}
|
|
691
|
+
if (parent.activeObj.shape === 'text' && parent.activeObj.textSettings) {
|
|
692
|
+
for (var i = 0; i < shapeSettings.fontStyle.length; i++) {
|
|
693
|
+
switch (shapeSettings.fontStyle[i]) {
|
|
694
|
+
case 'bold':
|
|
695
|
+
parent.activeObj.textSettings.bold = true;
|
|
696
|
+
break;
|
|
697
|
+
case 'italic':
|
|
698
|
+
parent.activeObj.textSettings.italic = true;
|
|
699
|
+
break;
|
|
700
|
+
case 'underline':
|
|
701
|
+
parent.activeObj.textSettings.underline = true;
|
|
702
|
+
break;
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
};
|
|
707
|
+
Shape.prototype.addLetter = function (letter) {
|
|
708
|
+
var parent = this.parent;
|
|
709
|
+
if (parent.textArea.style.display === 'none' && (parent.currObjType.isText || parent.activeObj.shape === 'text')) {
|
|
710
|
+
if (letter === 'Backspace') {
|
|
711
|
+
this.keyHistory = this.keyHistory.slice(0, -1);
|
|
712
|
+
}
|
|
713
|
+
else {
|
|
714
|
+
this.keyHistory += letter;
|
|
715
|
+
}
|
|
716
|
+
this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
|
|
717
|
+
this.updateFontStyles();
|
|
718
|
+
var width = this.upperContext.measureText(this.keyHistory).width
|
|
719
|
+
+ parent.activeObj.textSettings.fontSize * 0.5;
|
|
720
|
+
var height = parent.activeObj.textSettings.fontSize + parent.activeObj.textSettings.fontSize * 0.25;
|
|
721
|
+
this.upperContext.fillText(this.keyHistory, parent.activeObj.activePoint.startX, parent.activeObj.activePoint.startY +
|
|
722
|
+
parent.activeObj.textSettings.fontSize);
|
|
723
|
+
this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
|
|
724
|
+
parent.currObjType.isText = true;
|
|
725
|
+
parent.notify('selection', { prop: 'setActivePoint', onPropertyChange: false,
|
|
726
|
+
value: { startX: width, startY: height } });
|
|
727
|
+
}
|
|
728
|
+
};
|
|
729
|
+
Shape.prototype.redrawText = function () {
|
|
730
|
+
var parent = this.parent;
|
|
731
|
+
var fontStyle = '';
|
|
732
|
+
if (parent.activeObj.textSettings.bold) {
|
|
733
|
+
fontStyle += 'bold ';
|
|
734
|
+
}
|
|
735
|
+
if (parent.activeObj.textSettings.italic) {
|
|
736
|
+
fontStyle += 'italic ';
|
|
737
|
+
}
|
|
738
|
+
this.upperContext.font = fontStyle + parent.activeObj.textSettings.fontSize + 'px ' + parent.activeObj.textSettings.fontFamily;
|
|
739
|
+
var rows = parent.activeObj.keyHistory.split('\n');
|
|
740
|
+
var text = parent.textArea.style.display === 'block' ? this.getMaxText(true) : this.getMaxText();
|
|
741
|
+
var width = this.upperContext.measureText(text).width + parent.activeObj.textSettings.fontSize * 0.5;
|
|
742
|
+
var height = rows.length * (parent.activeObj.textSettings.fontSize + parent.activeObj.textSettings.fontSize * 0.25);
|
|
743
|
+
parent.notify('selection', { prop: 'setTextSelection', onPropertyChange: false,
|
|
744
|
+
value: { width: width, height: height } });
|
|
745
|
+
parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: parent.activeObj.activePoint, obj: parent.activeObj,
|
|
746
|
+
isMouseMove: null, x: null, y: null } });
|
|
747
|
+
parent.notify('selection', { prop: 'redrawShape', onPropertyChange: false,
|
|
748
|
+
value: { obj: parent.activeObj } });
|
|
749
|
+
};
|
|
750
|
+
Shape.prototype.updateTextFromTextArea = function () {
|
|
751
|
+
var parent = this.parent;
|
|
752
|
+
if (parent.activeObj.keyHistory !== parent.textArea.value) {
|
|
753
|
+
var prevCropObj = extend({}, parent.cropObj, {}, true);
|
|
754
|
+
var object = { currObj: {} };
|
|
755
|
+
parent.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
|
|
756
|
+
var prevObj = object['currObj'];
|
|
757
|
+
prevObj.objColl = extend([], parent.objColl, [], true);
|
|
758
|
+
prevObj.pointColl = extend([], parent.pointColl, [], true);
|
|
759
|
+
prevObj.afterCropActions = extend([], this.parent.afterCropActions, [], true);
|
|
760
|
+
var selPointCollObj = { selPointColl: null };
|
|
761
|
+
parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
|
|
762
|
+
value: { obj: selPointCollObj } });
|
|
763
|
+
prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
|
|
764
|
+
parent.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
|
|
765
|
+
value: { operation: 'text', previousObj: prevObj, previousObjColl: prevObj.objColl,
|
|
766
|
+
previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
|
|
767
|
+
previousCropObj: prevCropObj, previousText: parent.activeObj.keyHistory,
|
|
768
|
+
currentText: parent.textArea.value, previousFilter: null, isCircleCrop: null } });
|
|
769
|
+
}
|
|
770
|
+
parent.activeObj.keyHistory = parent.textArea.value;
|
|
771
|
+
parent.textArea.style.display = 'none';
|
|
772
|
+
parent.textArea.value = '';
|
|
773
|
+
this.updateFontStyles();
|
|
774
|
+
var width = this.upperContext.measureText(parent.activeObj.keyHistory).width +
|
|
775
|
+
parent.activeObj.textSettings.fontSize * 0.5;
|
|
776
|
+
var height = parent.activeObj.textSettings.fontSize + this.parent.activeObj.textSettings.fontSize * 0.25;
|
|
777
|
+
var rows = parent.activeObj.keyHistory.split('\n');
|
|
778
|
+
if (rows.length > 1) {
|
|
779
|
+
height *= rows.length;
|
|
780
|
+
var widthColl = [];
|
|
781
|
+
for (var i = 0, len = rows.length; i < len; i++) {
|
|
782
|
+
widthColl.push(this.upperContext.measureText(rows[i]).width +
|
|
783
|
+
parent.activeObj.textSettings.fontSize * 0.5);
|
|
784
|
+
}
|
|
785
|
+
width = Math.max.apply(Math, widthColl);
|
|
786
|
+
}
|
|
787
|
+
parent.notify('selection', { prop: 'setTextSelection', onPropertyChange: false,
|
|
788
|
+
value: { width: width, height: height } });
|
|
789
|
+
parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: parent.activeObj.activePoint, obj: parent.activeObj,
|
|
790
|
+
isMouseMove: null, x: null, y: null } });
|
|
791
|
+
this.updImgRatioForActObj();
|
|
792
|
+
};
|
|
793
|
+
Shape.prototype.iterateObjColl = function () {
|
|
794
|
+
var parent = this.parent;
|
|
795
|
+
for (var i = 0, len = parent.objColl.length; i < len; i++) {
|
|
796
|
+
this.apply(parent.objColl[i].shape, parent.objColl[i]);
|
|
797
|
+
this.refreshActiveObj();
|
|
798
|
+
}
|
|
799
|
+
};
|
|
800
|
+
Shape.prototype.updImgRatioForActObj = function () {
|
|
801
|
+
var parent = this.parent;
|
|
802
|
+
parent.activeObj.imageRatio = { startX: ((parent.activeObj.activePoint.startX - parent.img.destLeft) /
|
|
803
|
+
parent.img.destWidth),
|
|
804
|
+
startY: ((parent.activeObj.activePoint.startY - parent.img.destTop) / parent.img.destHeight),
|
|
805
|
+
endX: ((parent.activeObj.activePoint.endX - parent.img.destLeft) / parent.img.destWidth),
|
|
806
|
+
endY: ((parent.activeObj.activePoint.endY - parent.img.destTop) / parent.img.destHeight),
|
|
807
|
+
width: parent.img.destWidth / parent.activeObj.activePoint.width, height: parent.img.destHeight /
|
|
808
|
+
parent.activeObj.activePoint.height };
|
|
809
|
+
if (parent.activeObj.rotationCirclePointColl) {
|
|
810
|
+
parent.activeObj.rotationCirclePointColl.ratioX = (parent.activeObj.rotationCirclePointColl.x -
|
|
811
|
+
parent.img.destLeft) / parent.img.destWidth;
|
|
812
|
+
parent.activeObj.rotationCirclePointColl.ratioY = (parent.activeObj.rotationCirclePointColl.y -
|
|
813
|
+
parent.img.destTop) / parent.img.destHeight;
|
|
814
|
+
}
|
|
815
|
+
if (parent.activeObj.shape === 'path') {
|
|
816
|
+
this.updatePathRatio(parent.activeObj);
|
|
817
|
+
}
|
|
818
|
+
else if (parent.activeObj.shape === 'arrow') {
|
|
819
|
+
this.updateArrowRatio(parent.activeObj);
|
|
820
|
+
}
|
|
821
|
+
};
|
|
822
|
+
Shape.prototype.zoomObjColl = function (preventApply) {
|
|
823
|
+
var parent = this.parent;
|
|
824
|
+
for (var i = 0, len = parent.objColl.length; i < len; i++) {
|
|
825
|
+
var currObj = parent.objColl[i];
|
|
826
|
+
currObj.activePoint.startX = (currObj.imageRatio.startX * parent.img.destWidth) + parent.img.destLeft;
|
|
827
|
+
currObj.activePoint.startY = (currObj.imageRatio.startY * parent.img.destHeight) + parent.img.destTop;
|
|
828
|
+
currObj.activePoint.endX = (currObj.imageRatio.endX * parent.img.destWidth) + parent.img.destLeft;
|
|
829
|
+
currObj.activePoint.endY = (currObj.imageRatio.endY * parent.img.destHeight) + parent.img.destTop;
|
|
830
|
+
currObj = this.updateWidthHeight(currObj);
|
|
831
|
+
if (currObj.shape === 'text') {
|
|
832
|
+
this.updateFontSize(currObj);
|
|
833
|
+
}
|
|
834
|
+
else if (currObj.shape === 'line' || currObj.shape === 'arrow') {
|
|
835
|
+
currObj.pointColl = this.getLinePoints(currObj.activePoint.startX, currObj.activePoint.startY, currObj.activePoint.endX, currObj.activePoint.endY);
|
|
836
|
+
for (var n = 0, len_1 = currObj.pointColl.length; n < len_1; n++) {
|
|
837
|
+
currObj.pointColl[n].ratioX =
|
|
838
|
+
(currObj.pointColl[n].x - parent.img.destLeft) / parent.img.destWidth;
|
|
839
|
+
currObj.pointColl[n].ratioY =
|
|
840
|
+
(currObj.pointColl[n].y - parent.img.destTop) / parent.img.destHeight;
|
|
841
|
+
}
|
|
842
|
+
if (currObj.shape === 'arrow') {
|
|
843
|
+
this.updateArrowSize(currObj);
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
else if (currObj.shape === 'path') {
|
|
847
|
+
for (var l = 0, len_2 = currObj.pointColl.length; l < len_2; l++) {
|
|
848
|
+
currObj.pointColl[l].x = (currObj.pointColl[l].ratioX * parent.img.destWidth)
|
|
849
|
+
+ parent.img.destLeft;
|
|
850
|
+
currObj.pointColl[l].y = (currObj.pointColl[l].ratioY * parent.img.destHeight) +
|
|
851
|
+
parent.img.destTop;
|
|
852
|
+
}
|
|
853
|
+
this.updatePathRatio(currObj);
|
|
854
|
+
}
|
|
855
|
+
parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint,
|
|
856
|
+
obj: currObj } });
|
|
857
|
+
if (isNullOrUndefined(preventApply)) {
|
|
858
|
+
var temp = this.lowerContext.filter;
|
|
859
|
+
this.lowerContext.filter = 'none';
|
|
860
|
+
this.apply(currObj.shape, currObj);
|
|
861
|
+
this.refreshActiveObj();
|
|
862
|
+
this.lowerContext.filter = temp;
|
|
863
|
+
}
|
|
864
|
+
if (currObj.shape !== 'line' && currObj.shape !== 'arrow' && currObj.shape !== 'path' && currObj.rotatedAngle !== 0) {
|
|
865
|
+
this.setPointCollForShapeRotation(currObj);
|
|
866
|
+
currObj.rotationCirclePoint.x =
|
|
867
|
+
(currObj.rotationCirclePoint.ratioX * parent.img.destWidth) + parent.img.destLeft;
|
|
868
|
+
currObj.rotationCirclePoint.y =
|
|
869
|
+
(currObj.rotationCirclePoint.ratioY * parent.img.destHeight) + parent.img.destTop;
|
|
870
|
+
currObj.rotationCirclePointColl.x =
|
|
871
|
+
(currObj.rotationCirclePointColl.ratioX * parent.img.destWidth) +
|
|
872
|
+
parent.img.destLeft;
|
|
873
|
+
currObj.rotationCirclePointColl.y =
|
|
874
|
+
(currObj.rotationCirclePointColl.ratioY * parent.img.destHeight) +
|
|
875
|
+
parent.img.destTop;
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
};
|
|
879
|
+
Shape.prototype.redrawObj = function (degree) {
|
|
880
|
+
var parent = this.parent;
|
|
881
|
+
if (this.parent.objColl.length > 0) {
|
|
882
|
+
if (degree === 'horizontal' || degree === 'vertical' || degree === 'Horizontal' || degree === 'Vertical' ||
|
|
883
|
+
degree === 'horizontalVertical' || degree === 'verticalHorizontal') {
|
|
884
|
+
this.updateCurrentActiveObjPoint(degree.toLowerCase());
|
|
885
|
+
}
|
|
886
|
+
else if (typeof (degree) === 'number') {
|
|
887
|
+
this.updateCurrentActiveObjPoint(degree);
|
|
888
|
+
var tempFilter = this.lowerContext.filter;
|
|
889
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
890
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
891
|
+
for (var i = 0, len = parent.objColl.length; i < len; i++) {
|
|
892
|
+
var splitWords = parent.objColl[i].shape.split('-');
|
|
893
|
+
if (splitWords[0] !== 'crop') {
|
|
894
|
+
this.apply(parent.objColl[i].shape, parent.objColl[i]);
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
this.lowerContext.filter = tempFilter;
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
};
|
|
901
|
+
Shape.prototype.updateCurrentActiveObjPoint = function (degree) {
|
|
902
|
+
var parent = this.parent;
|
|
903
|
+
var currActObjIndex;
|
|
904
|
+
for (var index = 0, len = parent.objColl.length; index < len; index++) {
|
|
905
|
+
var currObj = parent.objColl[index];
|
|
906
|
+
if (parent.activeObj.shape === currObj.shape &&
|
|
907
|
+
parent.activeObj.activePoint.startX === currObj.activePoint.startX &&
|
|
908
|
+
parent.activeObj.activePoint.startY === currObj.activePoint.startY &&
|
|
909
|
+
parent.activeObj.activePoint.endX === currObj.activePoint.endX &&
|
|
910
|
+
parent.activeObj.activePoint.endY === currObj.activePoint.endY &&
|
|
911
|
+
parent.activeObj.currIndex === currObj.currIndex) {
|
|
912
|
+
currActObjIndex = index;
|
|
913
|
+
break;
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
if (degree === 'horizontal' || degree === 'vertical' || degree === 'Horizontal' || degree === 'Vertical' ||
|
|
917
|
+
degree === 'horizontalvertical' || degree === 'verticalhorizontal') {
|
|
918
|
+
if (degree === 'horizontal' || degree === 'Horizontal') {
|
|
919
|
+
for (var i = 0, len = parent.objColl.length; i < len; i++) {
|
|
920
|
+
var currObj = parent.objColl[i];
|
|
921
|
+
if (currObj.shapeFlip !== parent.transform.currFlipState) {
|
|
922
|
+
if (currObj.activePoint.startX <= parent.img.destLeft + (parent.img.destWidth / 2)) {
|
|
923
|
+
currObj.activePoint.endX = (parent.img.destLeft + parent.img.destWidth) - (currObj.activePoint.startX -
|
|
924
|
+
parent.img.destLeft);
|
|
925
|
+
currObj.activePoint.startX = currObj.activePoint.endX - currObj.activePoint.width;
|
|
926
|
+
parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint, obj: currObj } });
|
|
927
|
+
}
|
|
928
|
+
else if (currObj.activePoint.startX >= parent.img.destLeft + (parent.img.destWidth / 2)) {
|
|
929
|
+
currObj.activePoint.startX = parent.img.destLeft + (parent.img.destLeft + parent.img.destWidth -
|
|
930
|
+
currObj.activePoint.endX);
|
|
931
|
+
currObj.activePoint.endX = currObj.activePoint.startX + currObj.activePoint.width;
|
|
932
|
+
parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint,
|
|
933
|
+
obj: currObj } });
|
|
934
|
+
}
|
|
935
|
+
if (currObj.shape === 'line' || currObj.shape === 'arrow' || currObj.shape === 'path') {
|
|
936
|
+
this.flipLineArrowObj(currObj, 'horizontal');
|
|
937
|
+
}
|
|
938
|
+
else if (currObj.rotatedAngle !== 0) {
|
|
939
|
+
currObj.rotatedAngle = currObj.rotatedAngle + (Math.PI - currObj.rotatedAngle) * 2;
|
|
940
|
+
if (currObj.rotationCirclePointColl.x <= parent.img.destLeft + (parent.img.destWidth / 2)) {
|
|
941
|
+
currObj.rotationCirclePointColl.x = (parent.img.destLeft + parent.img.destWidth) -
|
|
942
|
+
(currObj.rotationCirclePointColl.x - parent.img.destLeft);
|
|
943
|
+
}
|
|
944
|
+
else if (currObj.rotationCirclePointColl.x >= parent.img.destLeft + (parent.img.destWidth / 2)) {
|
|
945
|
+
currObj.rotationCirclePointColl.x = parent.img.destLeft +
|
|
946
|
+
(parent.img.destLeft + parent.img.destWidth - currObj.rotationCirclePointColl.x);
|
|
947
|
+
}
|
|
948
|
+
currObj.rotationCirclePointColl.ratioX =
|
|
949
|
+
(currObj.rotationCirclePointColl.x - parent.img.destLeft) / parent.img.destWidth;
|
|
950
|
+
}
|
|
951
|
+
currObj.shapeFlip = parent.transform.currFlipState;
|
|
952
|
+
currObj.imageRatio = { startX: ((currObj.activePoint.startX - parent.img.destLeft) / parent.img.destWidth),
|
|
953
|
+
startY: ((currObj.activePoint.startY - parent.img.destTop) / parent.img.destHeight),
|
|
954
|
+
endX: ((currObj.activePoint.endX - parent.img.destLeft) / parent.img.destWidth),
|
|
955
|
+
endY: ((currObj.activePoint.endY - parent.img.destTop) / parent.img.destHeight),
|
|
956
|
+
width: parent.img.destWidth / currObj.activePoint.width,
|
|
957
|
+
height: parent.img.destHeight / currObj.activePoint.height };
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
else if (degree === 'vertical' || degree === 'Vertical') {
|
|
962
|
+
for (var i = 0; i < parent.objColl.length; i++) {
|
|
963
|
+
var currObj = parent.objColl[i];
|
|
964
|
+
if (currObj.shapeFlip !== parent.transform.currFlipState) {
|
|
965
|
+
if (currObj.activePoint.startY <= parent.img.destTop + (parent.img.destHeight / 2)) {
|
|
966
|
+
currObj.activePoint.endY = (parent.img.destTop + parent.img.destHeight) -
|
|
967
|
+
(currObj.activePoint.startY - parent.img.destTop);
|
|
968
|
+
currObj.activePoint.startY = currObj.activePoint.endY - currObj.activePoint.height;
|
|
969
|
+
parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint,
|
|
970
|
+
obj: currObj } });
|
|
971
|
+
}
|
|
972
|
+
else if (currObj.activePoint.startY >= this.parent.lowerCanvas.height / 2) {
|
|
973
|
+
currObj.activePoint.startY = parent.img.destTop + (parent.img.destTop +
|
|
974
|
+
parent.img.destHeight - currObj.activePoint.endY);
|
|
975
|
+
currObj.activePoint.endY = currObj.activePoint.startY +
|
|
976
|
+
currObj.activePoint.height;
|
|
977
|
+
parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint,
|
|
978
|
+
obj: currObj } });
|
|
979
|
+
}
|
|
980
|
+
if (currObj.shape === 'line' || currObj.shape === 'arrow' ||
|
|
981
|
+
currObj.shape === 'path') {
|
|
982
|
+
this.flipLineArrowObj(currObj, 'vertical');
|
|
983
|
+
}
|
|
984
|
+
else if (currObj.rotatedAngle !== 0) {
|
|
985
|
+
currObj.rotatedAngle = -currObj.rotatedAngle;
|
|
986
|
+
if (currObj.rotationCirclePointColl.y <= parent.img.destTop + (parent.img.destHeight / 2)) {
|
|
987
|
+
currObj.rotationCirclePointColl.y = (parent.img.destTop + parent.img.destHeight) -
|
|
988
|
+
(currObj.rotationCirclePointColl.y - parent.img.destTop);
|
|
989
|
+
}
|
|
990
|
+
else if (currObj.rotationCirclePointColl.y >= parent.img.destTop +
|
|
991
|
+
(parent.img.destHeight / 2)) {
|
|
992
|
+
currObj.rotationCirclePointColl.y = parent.img.destTop + (parent.img.destTop +
|
|
993
|
+
parent.img.destHeight - currObj.rotationCirclePointColl.y);
|
|
994
|
+
}
|
|
995
|
+
currObj.rotationCirclePointColl.ratioY =
|
|
996
|
+
(currObj.rotationCirclePointColl.y - parent.img.destTop) / parent.img.destHeight;
|
|
997
|
+
}
|
|
998
|
+
currObj.shapeFlip = parent.transform.currFlipState;
|
|
999
|
+
currObj.imageRatio = { startX: ((currObj.activePoint.startX - parent.img.destLeft) / parent.img.destWidth),
|
|
1000
|
+
startY: ((currObj.activePoint.startY - parent.img.destTop) / parent.img.destHeight),
|
|
1001
|
+
endX: ((currObj.activePoint.endX - parent.img.destLeft) / parent.img.destWidth),
|
|
1002
|
+
endY: ((currObj.activePoint.endY - parent.img.destTop) / parent.img.destHeight),
|
|
1003
|
+
width: parent.img.destWidth / currObj.activePoint.width,
|
|
1004
|
+
height: parent.img.destHeight / currObj.activePoint.height };
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
else if (degree === 'verticalhorizontal' || degree === 'horizontalvertical') {
|
|
1009
|
+
for (var i = 0, len = parent.objColl.length; i < len; i++) {
|
|
1010
|
+
var currObj = parent.objColl[i];
|
|
1011
|
+
if (currObj.shapeFlip !== parent.transform.currFlipState) {
|
|
1012
|
+
if (currObj.activePoint.startX <= parent.img.destLeft + (parent.img.destWidth / 2)) {
|
|
1013
|
+
currObj.activePoint.endX = (parent.img.destLeft + parent.img.destWidth) - (currObj.activePoint.startX -
|
|
1014
|
+
parent.img.destLeft);
|
|
1015
|
+
currObj.activePoint.startX = currObj.activePoint.endX - currObj.activePoint.width;
|
|
1016
|
+
parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint, obj: currObj } });
|
|
1017
|
+
}
|
|
1018
|
+
else if (currObj.activePoint.startX >= parent.img.destLeft + (parent.img.destWidth / 2)) {
|
|
1019
|
+
currObj.activePoint.startX = parent.img.destLeft + (parent.img.destLeft +
|
|
1020
|
+
parent.img.destWidth - currObj.activePoint.endX);
|
|
1021
|
+
currObj.activePoint.endX = currObj.activePoint.startX + currObj.activePoint.width;
|
|
1022
|
+
parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint, obj: currObj } });
|
|
1023
|
+
}
|
|
1024
|
+
if (currObj.activePoint.startY <= parent.img.destTop + (parent.img.destHeight / 2)) {
|
|
1025
|
+
currObj.activePoint.endY = (parent.img.destTop + parent.img.destHeight) -
|
|
1026
|
+
(currObj.activePoint.startY - parent.img.destTop);
|
|
1027
|
+
currObj.activePoint.startY = currObj.activePoint.endY -
|
|
1028
|
+
currObj.activePoint.height;
|
|
1029
|
+
parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint, obj: currObj } });
|
|
1030
|
+
}
|
|
1031
|
+
else if (currObj.activePoint.startY >= this.parent.lowerCanvas.height / 2) {
|
|
1032
|
+
currObj.activePoint.startY = parent.img.destTop + (parent.img.destTop +
|
|
1033
|
+
parent.img.destHeight - currObj.activePoint.endY);
|
|
1034
|
+
currObj.activePoint.endY = currObj.activePoint.startY +
|
|
1035
|
+
currObj.activePoint.height;
|
|
1036
|
+
parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint, obj: currObj } });
|
|
1037
|
+
}
|
|
1038
|
+
if (currObj.shape === 'line' || currObj.shape === 'arrow' || currObj.shape === 'path') {
|
|
1039
|
+
this.flipLineArrowObj(currObj, degree);
|
|
1040
|
+
}
|
|
1041
|
+
currObj.shapeFlip = parent.transform.currFlipState;
|
|
1042
|
+
currObj.imageRatio = { startX: ((currObj.activePoint.startX - parent.img.destLeft) / parent.img.destWidth),
|
|
1043
|
+
startY: ((currObj.activePoint.startY - parent.img.destTop) / parent.img.destHeight),
|
|
1044
|
+
endX: ((currObj.activePoint.endX - parent.img.destLeft) / parent.img.destWidth),
|
|
1045
|
+
endY: ((currObj.activePoint.endY - parent.img.destTop) / parent.img.destHeight),
|
|
1046
|
+
width: parent.img.destWidth / currObj.activePoint.width,
|
|
1047
|
+
height: parent.img.destHeight / currObj.activePoint.height };
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
if (currActObjIndex !== undefined) {
|
|
1052
|
+
parent.activeObj = extend({}, parent.objColl[currActObjIndex], {}, true);
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
else if (degree === 90) {
|
|
1056
|
+
this.rotateObjColl();
|
|
1057
|
+
}
|
|
1058
|
+
else if (degree === -90) {
|
|
1059
|
+
for (var i = 0; i < 3; i++) {
|
|
1060
|
+
this.rotateObjColl();
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
else if (typeof (degree) === 'number') {
|
|
1064
|
+
if (degree > 0) {
|
|
1065
|
+
this.rotateObjColl();
|
|
1066
|
+
}
|
|
1067
|
+
else {
|
|
1068
|
+
for (var i = 0; i < 3; i++) {
|
|
1069
|
+
this.rotateObjColl();
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
};
|
|
1074
|
+
Shape.prototype.rotateObjColl = function () {
|
|
1075
|
+
var parent = this.parent;
|
|
1076
|
+
for (var i = 0, len = parent.objColl.length; i < len; i++) {
|
|
1077
|
+
var currObj = parent.objColl[i];
|
|
1078
|
+
currObj.activePoint.startY = parent.img.destTop + (parent.img.destHeight * currObj.imageRatio.startX);
|
|
1079
|
+
currObj.activePoint.endY = parent.img.destTop + (parent.img.destHeight * currObj.imageRatio.endX);
|
|
1080
|
+
currObj.activePoint.startX = (parent.img.destLeft + parent.img.destWidth) -
|
|
1081
|
+
(parent.img.destWidth * currObj.imageRatio.endY);
|
|
1082
|
+
currObj.activePoint.endX = (parent.img.destLeft + parent.img.destWidth) -
|
|
1083
|
+
(parent.img.destWidth * currObj.imageRatio.startY);
|
|
1084
|
+
currObj = this.updateWidthHeight(parent.objColl[i]);
|
|
1085
|
+
this.updateFontSize(currObj);
|
|
1086
|
+
if (currObj.shape === 'line' || currObj.shape === 'arrow' ||
|
|
1087
|
+
currObj.shape === 'path') {
|
|
1088
|
+
this.rotateLineArrowObj(currObj);
|
|
1089
|
+
if (currObj.shape === 'arrow') {
|
|
1090
|
+
this.updateArrowSize(currObj);
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
else if (currObj.rotatedAngle !== 0) {
|
|
1094
|
+
currObj.rotationCirclePointColl.y = parent.img.destTop + (parent.img.destHeight * currObj.rotationCirclePointColl.ratioX);
|
|
1095
|
+
currObj.rotationCirclePointColl.x = (parent.img.destLeft + parent.img.destWidth) -
|
|
1096
|
+
(parent.img.destWidth * currObj.rotationCirclePointColl.ratioY);
|
|
1097
|
+
currObj.rotationCirclePointColl.ratioX = (currObj.rotationCirclePointColl.x
|
|
1098
|
+
- parent.img.destLeft) / parent.img.destWidth;
|
|
1099
|
+
currObj.rotationCirclePointColl.ratioY = (currObj.rotationCirclePointColl.y
|
|
1100
|
+
- parent.img.destTop) / parent.img.destHeight;
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
for (var i = 0, len = parent.objColl.length; i < len; i++) {
|
|
1104
|
+
parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: parent.objColl[i].activePoint, obj: parent.objColl[i] } });
|
|
1105
|
+
}
|
|
1106
|
+
// Update current image ratio for all objects
|
|
1107
|
+
for (var i = 0, len = parent.objColl.length; i < len; i++) {
|
|
1108
|
+
var currObj = parent.objColl[i];
|
|
1109
|
+
currObj.imageRatio = { startX: ((currObj.activePoint.startX - parent.img.destLeft) / parent.img.destWidth),
|
|
1110
|
+
startY: ((currObj.activePoint.startY - parent.img.destTop) / parent.img.destHeight),
|
|
1111
|
+
endX: ((currObj.activePoint.endX - parent.img.destLeft) / parent.img.destWidth),
|
|
1112
|
+
endY: ((currObj.activePoint.endY - parent.img.destTop) / parent.img.destHeight),
|
|
1113
|
+
width: parent.img.destWidth / currObj.activePoint.width,
|
|
1114
|
+
height: parent.img.destHeight / currObj.activePoint.height };
|
|
1115
|
+
}
|
|
1116
|
+
};
|
|
1117
|
+
Shape.prototype.rotateLineArrowObj = function (obj) {
|
|
1118
|
+
if (isNullOrUndefined(obj.pointColl)) {
|
|
1119
|
+
return;
|
|
1120
|
+
}
|
|
1121
|
+
var parent = this.parent;
|
|
1122
|
+
if (obj.pointColl.length > 0) {
|
|
1123
|
+
for (var n = 0; n < obj.pointColl.length; n++) {
|
|
1124
|
+
obj.pointColl[n].y = parent.img.destTop + (parent.img.destHeight * obj.pointColl[n].ratioX);
|
|
1125
|
+
obj.pointColl[n].x = (parent.img.destLeft + parent.img.destWidth) - (parent.img.destWidth *
|
|
1126
|
+
obj.pointColl[n].ratioY);
|
|
1127
|
+
}
|
|
1128
|
+
for (var n = 0; n < obj.pointColl.length; n++) {
|
|
1129
|
+
obj.pointColl[n].ratioX = (obj.pointColl[n].x - parent.img.destLeft) / parent.img.destWidth;
|
|
1130
|
+
obj.pointColl[n].ratioY = (obj.pointColl[n].y - parent.img.destTop) / parent.img.destHeight;
|
|
1131
|
+
}
|
|
1132
|
+
var prevPoint = void 0;
|
|
1133
|
+
if (isNullOrUndefined(obj.pointColl[obj.pointColl.length - 2])) {
|
|
1134
|
+
prevPoint = { x: 0, y: 0 };
|
|
1135
|
+
}
|
|
1136
|
+
else {
|
|
1137
|
+
prevPoint = { x: obj.pointColl[obj.pointColl.length - 2].x, y: obj.pointColl[obj.pointColl.length - 2].y };
|
|
1138
|
+
}
|
|
1139
|
+
var diffX = obj.pointColl[obj.pointColl.length - 1].x - prevPoint.x;
|
|
1140
|
+
var diffY = obj.pointColl[obj.pointColl.length - 1].y - prevPoint.y;
|
|
1141
|
+
obj.activePoint.startX = obj.pointColl[0].x;
|
|
1142
|
+
obj.activePoint.startY = obj.pointColl[0].y;
|
|
1143
|
+
obj.activePoint.endX = obj.pointColl[obj.pointColl.length - 1].x + (diffX / 2);
|
|
1144
|
+
obj.activePoint.endY = obj.pointColl[obj.pointColl.length - 1].y + (diffY / 2);
|
|
1145
|
+
obj = this.updateWidthHeight(obj);
|
|
1146
|
+
}
|
|
1147
|
+
};
|
|
1148
|
+
Shape.prototype.flipLineArrowObj = function (obj, value) {
|
|
1149
|
+
if (isNullOrUndefined(obj.pointColl)) {
|
|
1150
|
+
return;
|
|
1151
|
+
}
|
|
1152
|
+
if (value.toLowerCase() === 'horizontal') {
|
|
1153
|
+
this.lineArrowHorizontalFlip(obj);
|
|
1154
|
+
}
|
|
1155
|
+
else if (value.toLowerCase() === 'vertical') {
|
|
1156
|
+
this.lineArrowVerticalFlip(obj);
|
|
1157
|
+
}
|
|
1158
|
+
else {
|
|
1159
|
+
this.lineArrowHorizontalFlip(obj);
|
|
1160
|
+
obj.shapeFlip = '';
|
|
1161
|
+
this.lineArrowVerticalFlip(obj);
|
|
1162
|
+
}
|
|
1163
|
+
obj.activePoint.startX = obj.pointColl[0].x;
|
|
1164
|
+
obj.activePoint.startY = obj.pointColl[0].y;
|
|
1165
|
+
obj.activePoint.endX = obj.pointColl[obj.pointColl.length - 1].x;
|
|
1166
|
+
obj.activePoint.endY = obj.pointColl[obj.pointColl.length - 1].y;
|
|
1167
|
+
if (obj.activePoint.startX > obj.activePoint.endX) {
|
|
1168
|
+
var temp = obj.activePoint.startX;
|
|
1169
|
+
obj.activePoint.startX = obj.activePoint.endX;
|
|
1170
|
+
obj.activePoint.endX = temp;
|
|
1171
|
+
temp = obj.activePoint.startY;
|
|
1172
|
+
obj.activePoint.startY = obj.activePoint.endY;
|
|
1173
|
+
obj.activePoint.endY = temp;
|
|
1174
|
+
}
|
|
1175
|
+
};
|
|
1176
|
+
Shape.prototype.lineArrowHorizontalFlip = function (obj) {
|
|
1177
|
+
var parent = this.parent;
|
|
1178
|
+
// Update flip value for point collection
|
|
1179
|
+
if (obj.shapeFlip !== parent.transform.currFlipState) {
|
|
1180
|
+
for (var l = 0, len = obj.pointColl.length; l < len; l++) {
|
|
1181
|
+
var currPoint = obj.pointColl[l];
|
|
1182
|
+
if (currPoint.x <= parent.img.destLeft + (parent.img.destWidth / 2)) {
|
|
1183
|
+
currPoint.x = (parent.img.destLeft + parent.img.destWidth) - (currPoint.x
|
|
1184
|
+
- parent.img.destLeft);
|
|
1185
|
+
}
|
|
1186
|
+
else if (currPoint.x >= parent.img.destLeft + (parent.img.destWidth / 2)) {
|
|
1187
|
+
currPoint.x = parent.img.destLeft + (parent.img.destLeft + parent.img.destWidth -
|
|
1188
|
+
currPoint.x);
|
|
1189
|
+
}
|
|
1190
|
+
currPoint.ratioX = (currPoint.x - parent.img.destLeft) / parent.img.destWidth;
|
|
1191
|
+
currPoint.ratioY = (currPoint.y - parent.img.destTop) / parent.img.destHeight;
|
|
1192
|
+
}
|
|
1193
|
+
if (obj.shape === 'arrow') {
|
|
1194
|
+
var value = obj.start;
|
|
1195
|
+
obj.start = obj.end;
|
|
1196
|
+
obj.end = value;
|
|
1197
|
+
}
|
|
1198
|
+
obj.shapeFlip = parent.transform.currFlipState;
|
|
1199
|
+
}
|
|
1200
|
+
};
|
|
1201
|
+
Shape.prototype.lineArrowVerticalFlip = function (obj) {
|
|
1202
|
+
var parent = this.parent;
|
|
1203
|
+
// Update flip value for point collection
|
|
1204
|
+
if (obj.shapeFlip !== parent.transform.currFlipState) {
|
|
1205
|
+
for (var l = 0, len = obj.pointColl.length; l < len; l++) {
|
|
1206
|
+
var currPoint = obj.pointColl[l];
|
|
1207
|
+
if (currPoint.y <= parent.img.destTop + (parent.img.destHeight / 2)) {
|
|
1208
|
+
currPoint.y = (parent.img.destTop + parent.img.destHeight) -
|
|
1209
|
+
(currPoint.y - parent.img.destTop);
|
|
1210
|
+
}
|
|
1211
|
+
else if (currPoint.y >= parent.img.destTop + (parent.img.destHeight / 2)) {
|
|
1212
|
+
currPoint.y = parent.img.destTop + (parent.img.destTop + parent.img.destHeight -
|
|
1213
|
+
currPoint.y);
|
|
1214
|
+
}
|
|
1215
|
+
currPoint.ratioX = (currPoint.x - parent.img.destLeft) / parent.img.destWidth;
|
|
1216
|
+
currPoint.ratioY = (currPoint.y - parent.img.destTop) / parent.img.destHeight;
|
|
1217
|
+
}
|
|
1218
|
+
obj.shapeFlip = parent.transform.currFlipState;
|
|
1219
|
+
}
|
|
1220
|
+
};
|
|
1221
|
+
Shape.prototype.getRotDegOfShape = function (obj) {
|
|
1222
|
+
var degree;
|
|
1223
|
+
if (obj.shapeDegree === 0) {
|
|
1224
|
+
degree = this.parent.transform.degree;
|
|
1225
|
+
}
|
|
1226
|
+
else {
|
|
1227
|
+
degree = this.parent.transform.degree - obj.shapeDegree;
|
|
1228
|
+
}
|
|
1229
|
+
if (degree < 0) {
|
|
1230
|
+
degree = 360 + degree;
|
|
1231
|
+
}
|
|
1232
|
+
return degree;
|
|
1233
|
+
};
|
|
1234
|
+
Shape.prototype.renderTextArea = function (x, y, actObj) {
|
|
1235
|
+
var parent = this.parent;
|
|
1236
|
+
var degree = this.getRotDegOfShape(parent.activeObj);
|
|
1237
|
+
this.transformTextArea();
|
|
1238
|
+
if (!isBlazor()) {
|
|
1239
|
+
parent.notify('toolbar', { prop: 'destroy-qa-toolbar', onPropertyChange: false });
|
|
1240
|
+
}
|
|
1241
|
+
else {
|
|
1242
|
+
parent.updateToolbar(parent.element, 'destroyQuickAccessToolbar');
|
|
1243
|
+
}
|
|
1244
|
+
if (parent.element.querySelector('#' + parent.element.id + '_duplicate')) {
|
|
1245
|
+
parent.element.querySelector('#' + parent.element.id + '_duplicate').classList.add('e-disabled');
|
|
1246
|
+
}
|
|
1247
|
+
if (parent.element.querySelector('#' + parent.element.id + '_remove')) {
|
|
1248
|
+
parent.element.querySelector('#' + parent.element.id + '_remove').classList.add('e-disabled');
|
|
1249
|
+
}
|
|
1250
|
+
if (parent.element.querySelector('#' + parent.element.id + '_editText')) {
|
|
1251
|
+
parent.element.querySelector('#' + parent.element.id + '_editText').classList.add('e-disabled');
|
|
1252
|
+
}
|
|
1253
|
+
parent.textArea.style.display = 'block';
|
|
1254
|
+
parent.textArea.style.left = x + 'px';
|
|
1255
|
+
parent.textArea.style.top = y + 'px';
|
|
1256
|
+
parent.textArea.style.fontFamily = actObj.textSettings.fontFamily;
|
|
1257
|
+
parent.textArea.style.fontSize = actObj.textSettings.fontSize + 'px';
|
|
1258
|
+
parent.textArea.style.color = actObj.strokeSettings.strokeColor;
|
|
1259
|
+
parent.textArea.style.fontWeight = actObj.textSettings.bold ? 'bold' : 'normal';
|
|
1260
|
+
parent.textArea.style.fontStyle = actObj.textSettings.italic ? 'italic' : 'normal';
|
|
1261
|
+
parent.textArea.style.border = '2px solid ' + parent.themeColl[parent.theme]['primaryColor'];
|
|
1262
|
+
parent.textArea.value = actObj.keyHistory;
|
|
1263
|
+
parent.textArea.style.overflow = 'hidden';
|
|
1264
|
+
parent.textArea.style.width = 'auto';
|
|
1265
|
+
parent.textArea.style.height = 'auto';
|
|
1266
|
+
parent.textArea.focus();
|
|
1267
|
+
var zoomFactor = parent.transform.zoomFactor;
|
|
1268
|
+
var _a = actObj.activePoint, width = _a.width, height = _a.height;
|
|
1269
|
+
if (degree % 90 === 0 && degree % 180 !== 0 && degree !== 0) {
|
|
1270
|
+
parent.textArea.style.width = (zoomFactor === 0 ? height : height) + 'px';
|
|
1271
|
+
parent.textArea.style.height = (zoomFactor === 0 ? width : width) + 'px';
|
|
1272
|
+
}
|
|
1273
|
+
else {
|
|
1274
|
+
parent.textArea.style.width = (zoomFactor === 0 ? width : width) + 'px';
|
|
1275
|
+
parent.textArea.style.height = (zoomFactor === 0 ? height : height) + 'px';
|
|
1276
|
+
}
|
|
1277
|
+
this.setTextBoxWidth();
|
|
1278
|
+
var obj = { flipColl: null };
|
|
1279
|
+
parent.notify('transform', { prop: 'getFlipColl', onPropertyChange: false, value: { obj: obj } });
|
|
1280
|
+
if (obj['flipColl'].length <= 1) {
|
|
1281
|
+
this.setTextBoxHeight();
|
|
1282
|
+
}
|
|
1283
|
+
if (degree % 90 === 0 && degree % 180 !== 0) {
|
|
1284
|
+
if (parseFloat(parent.textArea.style.left) + parseFloat(parent.textArea.style.width) > parent.img.destTop +
|
|
1285
|
+
parent.img.destHeight) {
|
|
1286
|
+
this.alignTextAreaIntoCanvas();
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
else {
|
|
1290
|
+
if (parseFloat(parent.textArea.style.left) + parseFloat(parent.textArea.style.width) > parent.img.destLeft +
|
|
1291
|
+
parent.img.destWidth) {
|
|
1292
|
+
this.alignTextAreaIntoCanvas();
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
parent.notify('selection', { prop: 'clearUpperCanvas', onPropertyChange: false });
|
|
1296
|
+
};
|
|
1297
|
+
Shape.prototype.setTextBoxWidth = function (e) {
|
|
1298
|
+
var parent = this.parent;
|
|
1299
|
+
var text = this.getMaxText(true);
|
|
1300
|
+
if (parent.textArea.style.display === 'block') {
|
|
1301
|
+
this.updateFontStyles(true);
|
|
1302
|
+
}
|
|
1303
|
+
else {
|
|
1304
|
+
this.updateFontStyles();
|
|
1305
|
+
}
|
|
1306
|
+
var textAreaWidth = (this.upperContext.measureText(text).width + (parseFloat(parent.textArea.style.fontSize) / 2));
|
|
1307
|
+
var letterWidth = e ? this.upperContext.measureText(String.fromCharCode(e.which)).width : 0;
|
|
1308
|
+
var actObj = extend({}, parent.activeObj, {}, true);
|
|
1309
|
+
var flip = '';
|
|
1310
|
+
var degree = this.getRotDegOfShape(actObj);
|
|
1311
|
+
if (actObj.shapeFlip !== parent.transform.currFlipState) {
|
|
1312
|
+
flip = '';
|
|
1313
|
+
}
|
|
1314
|
+
else {
|
|
1315
|
+
flip = parent.transform.currFlipState;
|
|
1316
|
+
}
|
|
1317
|
+
if ((e && parseFloat(parent.textArea.style.width) < (textAreaWidth + letterWidth)) || isNullOrUndefined(e)) {
|
|
1318
|
+
if (degree === 0) {
|
|
1319
|
+
if (flip.toLowerCase() === 'horizontal') {
|
|
1320
|
+
if ((parseFloat(parent.textArea.style.left) - parent.img.destLeft) - textAreaWidth - letterWidth > 0) {
|
|
1321
|
+
parent.textArea.style.width = (textAreaWidth + letterWidth) + 'px';
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
else if ((parent.img.destWidth - (parseFloat(parent.textArea.style.left) -
|
|
1325
|
+
parent.img.destLeft)) > (textAreaWidth + letterWidth)) {
|
|
1326
|
+
parent.textArea.style.width = (textAreaWidth + letterWidth) + 'px';
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
else if (degree === 90) {
|
|
1330
|
+
if (flip.toLowerCase() === 'vertical') {
|
|
1331
|
+
if ((parseFloat(parent.textArea.style.top) - parent.img.destTop) - textAreaWidth - letterWidth > 0) {
|
|
1332
|
+
parent.textArea.style.width = (textAreaWidth + letterWidth) + 'px';
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
else if ((parent.img.destHeight - (parseFloat(parent.textArea.style.top) -
|
|
1336
|
+
parent.img.destTop)) > (textAreaWidth + letterWidth)) {
|
|
1337
|
+
parent.textArea.style.width = (textAreaWidth + letterWidth) + 'px';
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
else if (degree === 180) {
|
|
1341
|
+
var textAreaLeft = parseFloat(parent.textArea.style.left);
|
|
1342
|
+
var destLeft = parent.img.destLeft;
|
|
1343
|
+
if (flip.toLowerCase() === 'horizontal') {
|
|
1344
|
+
var remainingWidth = parent.img.destWidth - (textAreaLeft - destLeft);
|
|
1345
|
+
if (remainingWidth > textAreaWidth + letterWidth) {
|
|
1346
|
+
parent.textArea.style.width = (textAreaWidth + letterWidth) + 'px';
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
else {
|
|
1350
|
+
var distanceToLeft = textAreaLeft - destLeft;
|
|
1351
|
+
if (distanceToLeft - textAreaWidth - letterWidth > 0) {
|
|
1352
|
+
parent.textArea.style.width = (textAreaWidth + letterWidth) + 'px';
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
else if (degree === 270) {
|
|
1357
|
+
var textAreaTop = parseFloat(parent.textArea.style.top);
|
|
1358
|
+
var destTop = parent.img.destTop;
|
|
1359
|
+
if (flip.toLowerCase() === 'vertical') {
|
|
1360
|
+
var remainingHeight = parent.img.destHeight - (textAreaTop - destTop);
|
|
1361
|
+
if (remainingHeight > textAreaWidth + letterWidth) {
|
|
1362
|
+
parent.textArea.style.width = (textAreaWidth + letterWidth) + 'px';
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
else {
|
|
1366
|
+
var distanceToTop = textAreaTop - destTop;
|
|
1367
|
+
if (distanceToTop - textAreaWidth - letterWidth > 0) {
|
|
1368
|
+
parent.textArea.style.width = (textAreaWidth + letterWidth) + 'px';
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
};
|
|
1374
|
+
Shape.prototype.setTextBoxHeight = function () {
|
|
1375
|
+
var parent = this.parent;
|
|
1376
|
+
var textAreaTop;
|
|
1377
|
+
var actObj = extend({}, parent.activeObj, {}, true);
|
|
1378
|
+
var flip = '';
|
|
1379
|
+
var degree = this.getRotDegOfShape(actObj);
|
|
1380
|
+
if (actObj.textFlip === parent.transform.currFlipState) {
|
|
1381
|
+
flip = '';
|
|
1382
|
+
}
|
|
1383
|
+
else if (actObj.textFlip === '') {
|
|
1384
|
+
flip = parent.transform.currFlipState;
|
|
1385
|
+
}
|
|
1386
|
+
else {
|
|
1387
|
+
flip = actObj.textFlip;
|
|
1388
|
+
}
|
|
1389
|
+
switch (degree) {
|
|
1390
|
+
case 0:
|
|
1391
|
+
if (flip.toLowerCase() === 'vertical') {
|
|
1392
|
+
parent.textArea.style.maxHeight = (parent.img.destHeight - (parent.img.destHeight -
|
|
1393
|
+
parseFloat(parent.textArea.style.top))) + 'px';
|
|
1394
|
+
}
|
|
1395
|
+
else {
|
|
1396
|
+
textAreaTop = parseFloat(parent.textArea.style.top) - parent.img.destTop;
|
|
1397
|
+
parent.textArea.style.maxHeight = (parent.img.destHeight - textAreaTop) + 'px';
|
|
1398
|
+
}
|
|
1399
|
+
break;
|
|
1400
|
+
case 90:
|
|
1401
|
+
if (flip.toLowerCase() === 'horizontal') {
|
|
1402
|
+
parent.textArea.style.maxHeight = (parent.img.destWidth - (parseFloat(parent.textArea.style.left) -
|
|
1403
|
+
parent.img.destLeft)) + 'px';
|
|
1404
|
+
}
|
|
1405
|
+
else {
|
|
1406
|
+
parent.textArea.style.maxHeight = (parseFloat(parent.textArea.style.left) - parent.img.destLeft) + 'px';
|
|
1407
|
+
}
|
|
1408
|
+
break;
|
|
1409
|
+
case 180:
|
|
1410
|
+
if (flip.toLowerCase() === 'vertical') {
|
|
1411
|
+
textAreaTop = parseFloat(parent.textArea.style.top) - parent.img.destTop;
|
|
1412
|
+
parent.textArea.style.maxHeight = (parent.img.destHeight - textAreaTop) + 'px';
|
|
1413
|
+
}
|
|
1414
|
+
else {
|
|
1415
|
+
parent.textArea.style.maxHeight = (parseFloat(parent.textArea.style.top) - parent.img.destTop) + 'px';
|
|
1416
|
+
}
|
|
1417
|
+
break;
|
|
1418
|
+
case 270:
|
|
1419
|
+
if (flip.toLowerCase() === 'horizontal') {
|
|
1420
|
+
parent.textArea.style.maxHeight = (parseFloat(parent.textArea.style.left) - parent.img.destLeft) + 'px';
|
|
1421
|
+
}
|
|
1422
|
+
else {
|
|
1423
|
+
parent.textArea.style.maxHeight = parent.img.destWidth - (parseFloat(parent.textArea.style.left)
|
|
1424
|
+
- parent.img.destLeft) + 'px';
|
|
1425
|
+
}
|
|
1426
|
+
break;
|
|
1427
|
+
}
|
|
1428
|
+
};
|
|
1429
|
+
Shape.prototype.updatePathRatio = function (obj) {
|
|
1430
|
+
var parent = this.parent;
|
|
1431
|
+
for (var i = 0, len = obj.pointColl.length; i < len; i++) {
|
|
1432
|
+
var currPoint = obj.pointColl[i];
|
|
1433
|
+
currPoint.ratioX = (currPoint.x - parent.img.destLeft) / parent.img.destWidth;
|
|
1434
|
+
currPoint.ratioY = (currPoint.y - parent.img.destTop) / parent.img.destHeight;
|
|
1435
|
+
}
|
|
1436
|
+
};
|
|
1437
|
+
Shape.prototype.stopPathDrawing = function (e) {
|
|
1438
|
+
var parent = this.parent;
|
|
1439
|
+
if (parent.activeObj.shape === 'path') {
|
|
1440
|
+
var obj = { shape: null };
|
|
1441
|
+
parent.notify('selection', { prop: 'getCurrentDrawingShape', value: { obj: obj } });
|
|
1442
|
+
if (obj['shape'] === 'path') {
|
|
1443
|
+
var prevCropObj = extend({}, this.parent.cropObj, {}, true);
|
|
1444
|
+
var object = { currObj: {} };
|
|
1445
|
+
this.parent.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
|
|
1446
|
+
var prevObj = object['currObj'];
|
|
1447
|
+
prevObj.objColl = extend([], this.parent.objColl, [], true);
|
|
1448
|
+
prevObj.pointColl = extend([], this.parent.pointColl, [], true);
|
|
1449
|
+
prevObj.afterCropActions = extend([], this.parent.afterCropActions, [], true);
|
|
1450
|
+
var selPointCollObj = { selPointColl: null };
|
|
1451
|
+
this.parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
|
|
1452
|
+
value: { obj: selPointCollObj } });
|
|
1453
|
+
prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
|
|
1454
|
+
parent.notify('selection', { prop: 'setCurrentDrawingShape', value: { value: '' } });
|
|
1455
|
+
parent.currObjType.isDragging = false;
|
|
1456
|
+
if (e.type !== 'touchstart') {
|
|
1457
|
+
parent.activeObj.pointColl.pop();
|
|
1458
|
+
}
|
|
1459
|
+
this.updatePathRatio(parent.activeObj);
|
|
1460
|
+
parent.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
|
|
1461
|
+
value: { operation: 'shapeTransform', previousObj: prevObj, previousObjColl: prevObj.objColl,
|
|
1462
|
+
previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
|
|
1463
|
+
previousCropObj: prevCropObj, previousText: null,
|
|
1464
|
+
currentText: null, previousFilter: null, isCircleCrop: null } });
|
|
1465
|
+
parent.notify('selection', { prop: 'mouseUpEventHandler', value: { e: e } });
|
|
1466
|
+
parent.notify('draw', { prop: 'setNewPath', value: { bool: true } });
|
|
1467
|
+
if (parent.objColl[parent.objColl.length - 1]) {
|
|
1468
|
+
parent.selectShape(parent.objColl[parent.objColl.length - 1].currIndex);
|
|
1469
|
+
}
|
|
1470
|
+
if (!isBlazor()) {
|
|
1471
|
+
parent.notify('toolbar', { prop: 'renderQAT', onPropertyChange: false, value: { isPenEdit: null } });
|
|
1472
|
+
}
|
|
1473
|
+
else {
|
|
1474
|
+
parent.updateToolbar(parent.element, 'quickAccessToolbar', parent.activeObj.shape);
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
};
|
|
1479
|
+
Shape.prototype.findTextTarget = function (e) {
|
|
1480
|
+
var parent = this.parent;
|
|
1481
|
+
if (parent.activeObj.shape !== 'text') {
|
|
1482
|
+
this.stopPathDrawing(e);
|
|
1483
|
+
return;
|
|
1484
|
+
}
|
|
1485
|
+
var x;
|
|
1486
|
+
var y;
|
|
1487
|
+
if (e.type === 'dblclick') {
|
|
1488
|
+
x = e.clientX;
|
|
1489
|
+
y = e.clientY;
|
|
1490
|
+
}
|
|
1491
|
+
else if (e.type === 'touchstart') {
|
|
1492
|
+
x = e.touches[0].clientX;
|
|
1493
|
+
y = e.touches[0].clientY;
|
|
1494
|
+
parent.notify('selection', { prop: 'setTouchEndPoint', onPropertyChange: false,
|
|
1495
|
+
value: { x: e.touches[0].clientX, y: e.touches[0].clientY } });
|
|
1496
|
+
}
|
|
1497
|
+
parent.notify('toolbar', { prop: 'setPreventZoomBtn', onPropertyChange: false, value: { isPrevent: true } });
|
|
1498
|
+
parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'text',
|
|
1499
|
+
isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
|
|
1500
|
+
parent.notify('toolbar', { prop: 'setPreventZoomBtn', onPropertyChange: false, value: { isPrevent: false } });
|
|
1501
|
+
parent.notify('toolbar', { prop: 'update-toolbar-items', onPropertyChange: false });
|
|
1502
|
+
if (!isNullOrUndefined(x) && !isNullOrUndefined(y)) {
|
|
1503
|
+
var bbox = this.parent.lowerCanvas.getBoundingClientRect();
|
|
1504
|
+
x -= bbox.left;
|
|
1505
|
+
y -= bbox.top;
|
|
1506
|
+
var flip = '';
|
|
1507
|
+
var degree = this.getRotDegOfShape(parent.activeObj);
|
|
1508
|
+
if (parent.activeObj.textFlip === '') {
|
|
1509
|
+
if (parent.activeObj.textFlip === parent.transform.currFlipState) {
|
|
1510
|
+
flip = '';
|
|
1511
|
+
}
|
|
1512
|
+
else {
|
|
1513
|
+
flip = parent.transform.currFlipState;
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
else {
|
|
1517
|
+
if (parent.activeObj.textFlip === parent.transform.currFlipState) {
|
|
1518
|
+
flip = '';
|
|
1519
|
+
}
|
|
1520
|
+
else if (parent.transform.currFlipState === '') {
|
|
1521
|
+
flip = parent.activeObj.textFlip;
|
|
1522
|
+
}
|
|
1523
|
+
else {
|
|
1524
|
+
flip = parent.transform.currFlipState;
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
var temp = void 0;
|
|
1528
|
+
if (parent.textArea.style.display === 'none') {
|
|
1529
|
+
temp = extend({}, parent.activeObj, {}, true);
|
|
1530
|
+
for (var i = 0; i < parent.objColl.length; i++) {
|
|
1531
|
+
if (JSON.stringify(parent.activeObj) === JSON.stringify(parent.objColl[i])) {
|
|
1532
|
+
parent.objColl.splice(i, 1);
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
this.refreshActiveObj();
|
|
1536
|
+
this.upperContext.clearRect(0, 0, this.parent.upperCanvas.width, this.parent.upperCanvas.height);
|
|
1537
|
+
this.lowerContext.clearRect(0, 0, this.parent.upperCanvas.width, this.parent.upperCanvas.height);
|
|
1538
|
+
parent.notify('draw', { prop: 'redrawImgWithObj', onPropertyChange: false });
|
|
1539
|
+
if ((!isNullOrUndefined(parent.currSelectionPoint) && parent.currSelectionPoint.shape === 'crop-circle') || parent.isCircleCrop) {
|
|
1540
|
+
parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
|
|
1541
|
+
value: { context: this.lowerContext, isSave: null, isFlip: null } });
|
|
1542
|
+
}
|
|
1543
|
+
parent.activeObj = temp;
|
|
1544
|
+
this.updateFontStyles();
|
|
1545
|
+
var actObj = extend({}, parent.activeObj, {}, true);
|
|
1546
|
+
if (x >= (actObj.activePoint.startX - (actObj.topLeftCircle.radius * 2)) &&
|
|
1547
|
+
x <= (actObj.activePoint.endX + (actObj.topLeftCircle.radius * 2)) &&
|
|
1548
|
+
y >= (actObj.activePoint.startY - (actObj.topLeftCircle.radius * 2)) &&
|
|
1549
|
+
y <= (actObj.activePoint.endY + (actObj.topLeftCircle.radius * 2))) {
|
|
1550
|
+
this.upperContext.clearRect(0, 0, this.parent.upperCanvas.width, this.parent.upperCanvas.height);
|
|
1551
|
+
if (actObj.flipObjColl.length === 4) {
|
|
1552
|
+
actObj.flipObjColl = [];
|
|
1553
|
+
flip = '';
|
|
1554
|
+
}
|
|
1555
|
+
if (flip === '' && actObj.flipObjColl.length > 1) {
|
|
1556
|
+
flip = actObj.flipObjColl[actObj.flipObjColl.length - 1];
|
|
1557
|
+
}
|
|
1558
|
+
if (actObj.flipObjColl.length <= 1) {
|
|
1559
|
+
var points = this.setTextBoxPos(actObj, degree, flip, x, y);
|
|
1560
|
+
x = points.x;
|
|
1561
|
+
y = points.y;
|
|
1562
|
+
}
|
|
1563
|
+
else {
|
|
1564
|
+
var points = this.setTextBoxPoints(actObj, degree, flip, x, y);
|
|
1565
|
+
x = points.x;
|
|
1566
|
+
y = points.y;
|
|
1567
|
+
}
|
|
1568
|
+
if (parent.activeObj.rotatedAngle !== 0) {
|
|
1569
|
+
x = parent.activeObj.horTopLinePointColl[0].x;
|
|
1570
|
+
y = parent.activeObj.horTopLinePointColl[0].y;
|
|
1571
|
+
}
|
|
1572
|
+
this.renderTextArea(x, y, actObj);
|
|
1573
|
+
}
|
|
1574
|
+
else {
|
|
1575
|
+
this.applyActObj();
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
else if (parent.textArea.style.display === 'block' && this.selectedText() !== '' && e.type === 'mousedown') {
|
|
1580
|
+
var temp = parent.textArea.value;
|
|
1581
|
+
parent.textArea.value += 'a';
|
|
1582
|
+
parent.textArea.value = temp;
|
|
1583
|
+
}
|
|
1584
|
+
else if (parent.textArea.style.display === 'none') {
|
|
1585
|
+
parent.textArea.style.display = 'block';
|
|
1586
|
+
}
|
|
1587
|
+
};
|
|
1588
|
+
Shape.prototype.setTextBoxPos = function (actObj, degree, flip, x, y) {
|
|
1589
|
+
var point = { x: x, y: y };
|
|
1590
|
+
switch (degree) {
|
|
1591
|
+
case 0:
|
|
1592
|
+
if (flip.toLowerCase() === 'horizontal') {
|
|
1593
|
+
point.x = actObj.activePoint.endX;
|
|
1594
|
+
point.y = actObj.activePoint.startY;
|
|
1595
|
+
}
|
|
1596
|
+
else if (flip.toLowerCase() === 'vertical') {
|
|
1597
|
+
point.x = actObj.activePoint.startX;
|
|
1598
|
+
point.y = actObj.activePoint.endY;
|
|
1599
|
+
}
|
|
1600
|
+
else {
|
|
1601
|
+
point.x = actObj.activePoint.startX;
|
|
1602
|
+
point.y = actObj.activePoint.startY;
|
|
1603
|
+
}
|
|
1604
|
+
break;
|
|
1605
|
+
case 90:
|
|
1606
|
+
if (flip.toLowerCase() === 'horizontal') {
|
|
1607
|
+
point.x = actObj.activePoint.startX;
|
|
1608
|
+
point.y = actObj.activePoint.startY;
|
|
1609
|
+
}
|
|
1610
|
+
else if (flip.toLowerCase() === 'vertical') {
|
|
1611
|
+
point.x = actObj.activePoint.endX;
|
|
1612
|
+
point.y = actObj.activePoint.endY;
|
|
1613
|
+
}
|
|
1614
|
+
else {
|
|
1615
|
+
point.x = actObj.activePoint.endX;
|
|
1616
|
+
point.y = actObj.activePoint.startY;
|
|
1617
|
+
}
|
|
1618
|
+
break;
|
|
1619
|
+
case 180:
|
|
1620
|
+
if (flip.toLowerCase() === 'horizontal') {
|
|
1621
|
+
point.x = actObj.activePoint.startX;
|
|
1622
|
+
point.y = actObj.activePoint.endY;
|
|
1623
|
+
}
|
|
1624
|
+
else if (flip.toLowerCase() === 'vertical') {
|
|
1625
|
+
point.x = actObj.activePoint.endX;
|
|
1626
|
+
point.y = actObj.activePoint.startY;
|
|
1627
|
+
}
|
|
1628
|
+
else {
|
|
1629
|
+
point.x = actObj.activePoint.endX;
|
|
1630
|
+
point.y = actObj.activePoint.endY;
|
|
1631
|
+
}
|
|
1632
|
+
break;
|
|
1633
|
+
case 270:
|
|
1634
|
+
if (flip.toLowerCase() === 'horizontal') {
|
|
1635
|
+
point.x = actObj.activePoint.endX;
|
|
1636
|
+
point.y = actObj.activePoint.endY;
|
|
1637
|
+
}
|
|
1638
|
+
else if (flip.toLowerCase() === 'vertical') {
|
|
1639
|
+
point.x = actObj.activePoint.startX;
|
|
1640
|
+
point.y = actObj.activePoint.startY;
|
|
1641
|
+
}
|
|
1642
|
+
else {
|
|
1643
|
+
point.x = actObj.activePoint.startX;
|
|
1644
|
+
point.y = actObj.activePoint.endY;
|
|
1645
|
+
}
|
|
1646
|
+
break;
|
|
1647
|
+
}
|
|
1648
|
+
return point;
|
|
1649
|
+
};
|
|
1650
|
+
Shape.prototype.setTextBoxPoints = function (actObj, degree, flip, x, y) {
|
|
1651
|
+
var point = { x: x, y: y };
|
|
1652
|
+
switch (degree) {
|
|
1653
|
+
case 0:
|
|
1654
|
+
if (actObj.flipObjColl[0] && actObj.flipObjColl[0].toLowerCase() === 'horizontal') {
|
|
1655
|
+
if (flip.toLowerCase() === 'horizontal') {
|
|
1656
|
+
point.x = (actObj.activePoint.startX);
|
|
1657
|
+
point.y = (actObj.activePoint.startY);
|
|
1658
|
+
}
|
|
1659
|
+
else if (flip.toLowerCase() === 'vertical') {
|
|
1660
|
+
point.x = (actObj.activePoint.endX);
|
|
1661
|
+
point.y = (actObj.activePoint.endY);
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
else {
|
|
1665
|
+
if (flip.toLowerCase() === 'horizontal') {
|
|
1666
|
+
point.x = (actObj.activePoint.endX);
|
|
1667
|
+
point.y = (actObj.activePoint.endY);
|
|
1668
|
+
}
|
|
1669
|
+
else if (flip.toLowerCase() === 'vertical') {
|
|
1670
|
+
point.x = (actObj.activePoint.endX);
|
|
1671
|
+
point.y = (actObj.activePoint.startY);
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
break;
|
|
1675
|
+
case 90:
|
|
1676
|
+
if (actObj.flipObjColl[0] && actObj.flipObjColl[0].toLowerCase() === 'horizontal') {
|
|
1677
|
+
if (flip.toLowerCase() === 'horizontal') {
|
|
1678
|
+
point.x = (actObj.activePoint.endX);
|
|
1679
|
+
point.y = (actObj.activePoint.endY);
|
|
1680
|
+
}
|
|
1681
|
+
else if (flip.toLowerCase() === 'vertical') {
|
|
1682
|
+
point.x = (actObj.activePoint.startX);
|
|
1683
|
+
point.y = (actObj.activePoint.endY);
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
else {
|
|
1687
|
+
if (flip.toLowerCase() === 'horizontal') {
|
|
1688
|
+
point.x = (actObj.activePoint.startX);
|
|
1689
|
+
point.y = (actObj.activePoint.endY);
|
|
1690
|
+
}
|
|
1691
|
+
else if (flip.toLowerCase() === 'vertical') {
|
|
1692
|
+
point.x = (actObj.activePoint.startX);
|
|
1693
|
+
point.y = (actObj.activePoint.startY);
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
break;
|
|
1697
|
+
case 180:
|
|
1698
|
+
if (actObj.flipObjColl[0] && actObj.flipObjColl[0].toLowerCase() === 'horizontal') {
|
|
1699
|
+
if (flip.toLowerCase() === 'horizontal') {
|
|
1700
|
+
point.x = (actObj.activePoint.startX);
|
|
1701
|
+
point.y = (actObj.activePoint.startY);
|
|
1702
|
+
}
|
|
1703
|
+
else if (flip.toLowerCase() === 'vertical') {
|
|
1704
|
+
point.x = (actObj.activePoint.startX);
|
|
1705
|
+
point.y = (actObj.activePoint.startY);
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1708
|
+
else {
|
|
1709
|
+
if (flip.toLowerCase() === 'horizontal') {
|
|
1710
|
+
point.x = (actObj.activePoint.startX);
|
|
1711
|
+
point.y = (actObj.activePoint.startY);
|
|
1712
|
+
}
|
|
1713
|
+
else if (flip.toLowerCase() === 'vertical') {
|
|
1714
|
+
point.x = (actObj.activePoint.startX);
|
|
1715
|
+
point.y = (actObj.activePoint.endY);
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
break;
|
|
1719
|
+
case 270:
|
|
1720
|
+
if (actObj.flipObjColl[0] && actObj.flipObjColl[0].toLowerCase() === 'horizontal') {
|
|
1721
|
+
if (flip.toLowerCase() === 'horizontal') {
|
|
1722
|
+
point.x = (actObj.activePoint.startX);
|
|
1723
|
+
point.y = (actObj.activePoint.startY);
|
|
1724
|
+
}
|
|
1725
|
+
else if (flip.toLowerCase() === 'vertical') {
|
|
1726
|
+
point.x = (actObj.activePoint.endX);
|
|
1727
|
+
point.y = (actObj.activePoint.startY);
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
else {
|
|
1731
|
+
if (flip.toLowerCase() === 'horizontal') {
|
|
1732
|
+
point.x = (actObj.activePoint.endX);
|
|
1733
|
+
point.y = (actObj.activePoint.startY);
|
|
1734
|
+
}
|
|
1735
|
+
else if (flip.toLowerCase() === 'vertical') {
|
|
1736
|
+
point.x = (actObj.activePoint.endX);
|
|
1737
|
+
point.y = (actObj.activePoint.endY);
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
break;
|
|
1741
|
+
}
|
|
1742
|
+
return point;
|
|
1743
|
+
};
|
|
1744
|
+
Shape.prototype.selectedText = function () {
|
|
1745
|
+
var start = this.parent.textArea.selectionStart;
|
|
1746
|
+
var finish = this.parent.textArea.selectionEnd;
|
|
1747
|
+
return this.parent.textArea.value.substring(start, finish);
|
|
1748
|
+
};
|
|
1749
|
+
Shape.prototype.panObjColl = function (xDiff, yDiff, panRegion) {
|
|
1750
|
+
var parent = this.parent;
|
|
1751
|
+
for (var i = 0, len = parent.objColl.length; i < len; i++) {
|
|
1752
|
+
var currObj = parent.objColl[i];
|
|
1753
|
+
if (panRegion === '' || panRegion === 'vertical') {
|
|
1754
|
+
currObj.activePoint.startX += xDiff;
|
|
1755
|
+
currObj.activePoint.endX += xDiff;
|
|
1756
|
+
if (currObj.rotationCirclePointColl) {
|
|
1757
|
+
currObj.rotationCirclePointColl.x += xDiff;
|
|
1758
|
+
}
|
|
1759
|
+
if (currObj.shape === 'path') {
|
|
1760
|
+
for (var l = 0, len_3 = currObj.pointColl.length; l < len_3; l++) {
|
|
1761
|
+
currObj.pointColl[l].x += xDiff;
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
else {
|
|
1766
|
+
currObj.activePoint.startX -= xDiff;
|
|
1767
|
+
currObj.activePoint.endX -= xDiff;
|
|
1768
|
+
if (currObj.rotationCirclePointColl) {
|
|
1769
|
+
currObj.rotationCirclePointColl.x -= xDiff;
|
|
1770
|
+
}
|
|
1771
|
+
if (currObj.shape === 'path') {
|
|
1772
|
+
for (var l = 0, len_4 = currObj.pointColl.length; l < len_4; l++) {
|
|
1773
|
+
currObj.pointColl[l].x -= xDiff;
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
if (panRegion === '' || panRegion === 'horizontal') {
|
|
1778
|
+
currObj.activePoint.startY += yDiff;
|
|
1779
|
+
currObj.activePoint.endY += yDiff;
|
|
1780
|
+
if (currObj.rotationCirclePointColl) {
|
|
1781
|
+
currObj.rotationCirclePointColl.y += yDiff;
|
|
1782
|
+
}
|
|
1783
|
+
if (currObj.shape === 'path') {
|
|
1784
|
+
for (var l = 0; l < currObj.pointColl.length; l++) {
|
|
1785
|
+
currObj.pointColl[l].y += yDiff;
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
else {
|
|
1790
|
+
currObj.activePoint.startY -= yDiff;
|
|
1791
|
+
currObj.activePoint.endY -= yDiff;
|
|
1792
|
+
if (currObj.rotationCirclePointColl) {
|
|
1793
|
+
currObj.rotationCirclePointColl.y -= yDiff;
|
|
1794
|
+
}
|
|
1795
|
+
if (currObj.shape === 'path') {
|
|
1796
|
+
for (var l = 0; l < currObj.pointColl.length; l++) {
|
|
1797
|
+
currObj.pointColl[l].y -= yDiff;
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
currObj = this.updateWidthHeight(currObj);
|
|
1802
|
+
parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint,
|
|
1803
|
+
obj: currObj } });
|
|
1804
|
+
if (currObj.shape === 'line' || currObj.shape === 'arrow') {
|
|
1805
|
+
currObj.pointColl = this.getLinePoints(currObj.activePoint.startX, currObj.activePoint.startY, currObj.activePoint.endX, currObj.activePoint.endY);
|
|
1806
|
+
for (var j = 0, len_5 = currObj.pointColl.length; j < len_5; j++) {
|
|
1807
|
+
currObj.pointColl[j].ratioX =
|
|
1808
|
+
(currObj.pointColl[j].x - parent.img.destLeft) / parent.img.destWidth;
|
|
1809
|
+
currObj.pointColl[j].ratioY =
|
|
1810
|
+
(currObj.pointColl[j].y - parent.img.destTop) / parent.img.destHeight;
|
|
1811
|
+
}
|
|
1812
|
+
}
|
|
1813
|
+
var temp = this.lowerContext.filter;
|
|
1814
|
+
this.lowerContext.filter = 'none';
|
|
1815
|
+
this.apply(currObj.shape, currObj);
|
|
1816
|
+
this.lowerContext.filter = temp;
|
|
1817
|
+
this.refreshActiveObj();
|
|
1818
|
+
}
|
|
1819
|
+
};
|
|
1820
|
+
Shape.prototype.updateFontStyles = function (isTextBox) {
|
|
1821
|
+
var parent = this.parent;
|
|
1822
|
+
this.upperContext.strokeStyle = parent.activeObj.strokeSettings.strokeColor;
|
|
1823
|
+
this.upperContext.fillStyle = parent.activeObj.strokeSettings.strokeColor;
|
|
1824
|
+
var textStyle = '';
|
|
1825
|
+
if (parent.activeObj.textSettings.bold) {
|
|
1826
|
+
textStyle = 'bold ';
|
|
1827
|
+
}
|
|
1828
|
+
if (parent.activeObj.textSettings.italic) {
|
|
1829
|
+
textStyle = 'italic ';
|
|
1830
|
+
}
|
|
1831
|
+
if (parent.activeObj.textSettings.bold && parent.activeObj.textSettings.italic) {
|
|
1832
|
+
textStyle = 'italic bold ';
|
|
1833
|
+
}
|
|
1834
|
+
var fontSize = isTextBox ? parseFloat(parent.textArea.style.fontSize) : parent.activeObj.textSettings.fontSize;
|
|
1835
|
+
var fontFamily = parent.textArea.style.display === 'block' ? parent.textArea.style.fontFamily : parent.activeObj.textSettings.fontFamily;
|
|
1836
|
+
this.upperContext.font = textStyle + fontSize + 'px' + ' ' + fontFamily;
|
|
1837
|
+
};
|
|
1838
|
+
Shape.prototype.applyFontStyle = function (item) {
|
|
1839
|
+
var parent = this.parent;
|
|
1840
|
+
this.pushActItemIntoObj();
|
|
1841
|
+
var objColl = extend([], parent.objColl, [], true);
|
|
1842
|
+
parent.objColl.pop();
|
|
1843
|
+
if (parent.textArea.style.display === 'none') {
|
|
1844
|
+
this.updateFontRatio(parent.activeObj);
|
|
1845
|
+
}
|
|
1846
|
+
else {
|
|
1847
|
+
this.updateFontRatio(parent.activeObj, true);
|
|
1848
|
+
}
|
|
1849
|
+
switch (item) {
|
|
1850
|
+
case 'default':
|
|
1851
|
+
this.updateFontStyle(item, objColl, 'normal', 'normal');
|
|
1852
|
+
break;
|
|
1853
|
+
case 'bold':
|
|
1854
|
+
this.updateFontStyle(item, objColl, 'bold', 'normal');
|
|
1855
|
+
break;
|
|
1856
|
+
case 'italic':
|
|
1857
|
+
this.updateFontStyle(item, objColl, 'normal', 'italic');
|
|
1858
|
+
break;
|
|
1859
|
+
case 'bolditalic':
|
|
1860
|
+
this.updateFontStyle(item, objColl, 'bold', 'italic');
|
|
1861
|
+
break;
|
|
1862
|
+
}
|
|
1863
|
+
};
|
|
1864
|
+
Shape.prototype.updateFontStyle = function (item, objColl, fontWeight, fontStyle) {
|
|
1865
|
+
var parent = this.parent;
|
|
1866
|
+
if (parent.textArea.style.display === 'block') {
|
|
1867
|
+
var width = this.getTextAreaWidth(item);
|
|
1868
|
+
parent.textArea.style.width = width + 'px';
|
|
1869
|
+
parent.textArea.style.fontWeight = fontWeight;
|
|
1870
|
+
parent.textArea.style.fontStyle = fontStyle;
|
|
1871
|
+
this.updateObjColl(item, objColl);
|
|
1872
|
+
}
|
|
1873
|
+
else {
|
|
1874
|
+
this.textSettings.bold = parent.activeObj.textSettings.bold = fontWeight === 'normal' ? false : true;
|
|
1875
|
+
this.textSettings.italic = parent.activeObj.textSettings.italic = fontStyle === 'normal' ? false : true;
|
|
1876
|
+
this.redrawText();
|
|
1877
|
+
parent.notify('undo-redo', { prop: 'updateUrObj', onPropertyChange: false, value: { objColl: objColl } });
|
|
1878
|
+
}
|
|
1879
|
+
};
|
|
1880
|
+
Shape.prototype.updateArrowRatio = function (obj) {
|
|
1881
|
+
var parent = this.parent;
|
|
1882
|
+
var object = { arrowDimension: null };
|
|
1883
|
+
parent.notify('draw', { prop: 'getArrowDimension', onPropertyChange: false, value: { obj: object } });
|
|
1884
|
+
var length;
|
|
1885
|
+
var degree = this.getRotDegOfShape(obj);
|
|
1886
|
+
if (degree === 0 || degree === 180 || degree === -180) {
|
|
1887
|
+
length = Math.abs(obj.activePoint.width);
|
|
1888
|
+
}
|
|
1889
|
+
else {
|
|
1890
|
+
length = Math.abs(obj.activePoint.height);
|
|
1891
|
+
}
|
|
1892
|
+
var dimension;
|
|
1893
|
+
var dimensions = ['bar', 'arrow', 'arrowSolid', 'circle', 'square'];
|
|
1894
|
+
for (var _i = 0, dimensions_1 = dimensions; _i < dimensions_1.length; _i++) {
|
|
1895
|
+
dimension = dimensions_1[_i];
|
|
1896
|
+
var ratioX = length / object['arrowDimension'][dimension]['width'];
|
|
1897
|
+
var ratioY = length / object['arrowDimension'][dimension]['height'];
|
|
1898
|
+
object['arrowDimension'][dimension]['ratioX'] = ratioX;
|
|
1899
|
+
object['arrowDimension'][dimension]['ratioY'] = ratioY;
|
|
1900
|
+
}
|
|
1901
|
+
};
|
|
1902
|
+
Shape.prototype.updateArrowSize = function (obj) {
|
|
1903
|
+
var object = { arrowDimension: null };
|
|
1904
|
+
this.parent.notify('draw', { prop: 'getArrowDimension', onPropertyChange: false, value: { obj: object } });
|
|
1905
|
+
var length;
|
|
1906
|
+
var degree = this.getRotDegOfShape(obj);
|
|
1907
|
+
if (degree === 0 || degree === 180 || degree === -180) {
|
|
1908
|
+
length = Math.abs(obj.activePoint.width);
|
|
1909
|
+
}
|
|
1910
|
+
else {
|
|
1911
|
+
length = Math.abs(obj.activePoint.height);
|
|
1912
|
+
}
|
|
1913
|
+
var dimension;
|
|
1914
|
+
var dimensions = ['bar', 'arrow', 'arrowSolid', 'circle', 'square'];
|
|
1915
|
+
for (var _i = 0, dimensions_2 = dimensions; _i < dimensions_2.length; _i++) {
|
|
1916
|
+
dimension = dimensions_2[_i];
|
|
1917
|
+
var ratioX = object['arrowDimension'][dimension]['ratioX'];
|
|
1918
|
+
var ratioY = object['arrowDimension'][dimension]['ratioY'];
|
|
1919
|
+
object['arrowDimension'][dimension]['width'] = length / ratioX;
|
|
1920
|
+
object['arrowDimension'][dimension]['height'] = length / ratioY;
|
|
1921
|
+
}
|
|
1922
|
+
};
|
|
1923
|
+
Shape.prototype.updateFontRatio = function (obj, isTextArea) {
|
|
1924
|
+
var parent = this.parent;
|
|
1925
|
+
var text = this.getMaxText(isTextArea);
|
|
1926
|
+
var width = this.upperContext.measureText(text).width +
|
|
1927
|
+
parent.activeObj.textSettings.fontSize * 0.5;
|
|
1928
|
+
var height = (parent.activeObj.textSettings.fontSize + parent.activeObj.textSettings.fontSize * 0.25);
|
|
1929
|
+
var degree = this.getRotDegOfShape(obj);
|
|
1930
|
+
if (isNullOrUndefined(isTextArea)) {
|
|
1931
|
+
if (degree === 0 || Math.abs(degree) === 180) {
|
|
1932
|
+
obj.textSettings.fontRatio = width / obj.textSettings.fontSize;
|
|
1933
|
+
}
|
|
1934
|
+
else {
|
|
1935
|
+
obj.textSettings.fontRatio = height / obj.textSettings.fontSize;
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
else if (isTextArea) {
|
|
1939
|
+
obj.textSettings.fontRatio = width / parseFloat(parent.textArea.style.fontSize);
|
|
1940
|
+
}
|
|
1941
|
+
};
|
|
1942
|
+
Shape.prototype.updateFontSize = function (obj) {
|
|
1943
|
+
var degree = this.getRotDegOfShape(obj);
|
|
1944
|
+
if (degree === 0 || Math.abs(degree) === 180) {
|
|
1945
|
+
obj.textSettings.fontSize = (obj.activePoint.width / obj.textSettings.fontRatio);
|
|
1946
|
+
}
|
|
1947
|
+
else {
|
|
1948
|
+
obj.textSettings.fontSize = (obj.activePoint.height / obj.textSettings.fontRatio);
|
|
1949
|
+
}
|
|
1950
|
+
};
|
|
1951
|
+
Shape.prototype.updateObjColl = function (item, objColl) {
|
|
1952
|
+
var parent = this.parent;
|
|
1953
|
+
var prevCropObj = extend({}, parent.cropObj, {}, true);
|
|
1954
|
+
var object = { currObj: {} };
|
|
1955
|
+
parent.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
|
|
1956
|
+
var prevObj = object['currObj'];
|
|
1957
|
+
prevObj.objColl = objColl;
|
|
1958
|
+
prevObj.pointColl = extend([], parent.pointColl, [], true);
|
|
1959
|
+
prevObj.afterCropActions = extend([], parent.afterCropActions, [], true);
|
|
1960
|
+
var selPointCollObj = { selPointColl: null };
|
|
1961
|
+
parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
|
|
1962
|
+
value: { obj: selPointCollObj } });
|
|
1963
|
+
prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
|
|
1964
|
+
var tempBold = parent.activeObj.textSettings.bold;
|
|
1965
|
+
var tempItalic = parent.activeObj.textSettings.italic;
|
|
1966
|
+
switch (item) {
|
|
1967
|
+
case 'default':
|
|
1968
|
+
parent.activeObj.textSettings.bold = false;
|
|
1969
|
+
parent.activeObj.textSettings.italic = false;
|
|
1970
|
+
break;
|
|
1971
|
+
case 'bold':
|
|
1972
|
+
parent.activeObj.textSettings.bold = true;
|
|
1973
|
+
parent.activeObj.textSettings.italic = false;
|
|
1974
|
+
break;
|
|
1975
|
+
case 'italic':
|
|
1976
|
+
parent.activeObj.textSettings.bold = false;
|
|
1977
|
+
parent.activeObj.textSettings.italic = true;
|
|
1978
|
+
break;
|
|
1979
|
+
case 'bolditalic':
|
|
1980
|
+
parent.activeObj.textSettings.bold = true;
|
|
1981
|
+
parent.activeObj.textSettings.italic = true;
|
|
1982
|
+
break;
|
|
1983
|
+
}
|
|
1984
|
+
parent.objColl.push(parent.activeObj);
|
|
1985
|
+
parent.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
|
|
1986
|
+
value: { operation: 'textAreaCustomization', previousObj: prevObj, previousObjColl: prevObj.objColl,
|
|
1987
|
+
previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
|
|
1988
|
+
previousCropObj: prevCropObj, previousText: null,
|
|
1989
|
+
currentText: null, previousFilter: null, isCircleCrop: null } });
|
|
1990
|
+
parent.objColl.pop();
|
|
1991
|
+
parent.activeObj.textSettings.bold = tempBold;
|
|
1992
|
+
parent.activeObj.textSettings.italic = tempItalic;
|
|
1993
|
+
};
|
|
1994
|
+
Shape.prototype.pushActItemIntoObj = function () {
|
|
1995
|
+
if (this.parent.textArea.style.display === 'none') {
|
|
1996
|
+
this.parent.objColl.push(this.parent.activeObj);
|
|
1997
|
+
}
|
|
1998
|
+
else {
|
|
1999
|
+
var temp = extend({}, this.parent.activeObj, {}, true);
|
|
2000
|
+
this.parent.notify('selection', { prop: 'setTextBoxStylesToActObj', onPropertyChange: false });
|
|
2001
|
+
this.parent.objColl.push(this.parent.activeObj);
|
|
2002
|
+
this.parent.activeObj = temp;
|
|
2003
|
+
}
|
|
2004
|
+
};
|
|
2005
|
+
Shape.prototype.clearActObj = function () {
|
|
2006
|
+
if (this.parent.textArea.style.display === 'none') {
|
|
2007
|
+
this.refreshActiveObj();
|
|
2008
|
+
this.applyActObj();
|
|
2009
|
+
this.refreshActiveObj();
|
|
2010
|
+
this.parent.currObjType.isCustomCrop = false;
|
|
2011
|
+
}
|
|
2012
|
+
};
|
|
2013
|
+
Shape.prototype.refreshActiveObj = function () {
|
|
2014
|
+
this.parent.activeObj = {};
|
|
2015
|
+
this.parent.activeObj.activePoint = { startX: 0, startY: 0, endX: 0, endY: 0, width: 0, height: 0 };
|
|
2016
|
+
this.parent.activeObj.triangle = [];
|
|
2017
|
+
this.parent.activeObj.triangleRatio = [];
|
|
2018
|
+
this.parent.activeObj.flipObjColl = [];
|
|
2019
|
+
this.parent.activeObj.strokeSettings = this.strokeSettings;
|
|
2020
|
+
this.parent.activeObj.textSettings = this.textSettings;
|
|
2021
|
+
this.parent.activeObj.rotatedAngle = 0;
|
|
2022
|
+
};
|
|
2023
|
+
Shape.prototype.applyActObj = function (isMouseDown) {
|
|
2024
|
+
var isActObj = false;
|
|
2025
|
+
if (this.parent.activeObj.shape !== undefined && this.parent.activeObj.shape === 'text' && this.parent.activeObj.keyHistory === '') {
|
|
2026
|
+
this.refreshActiveObj();
|
|
2027
|
+
this.upperContext.clearRect(0, 0, this.parent.upperCanvas.width, this.parent.upperCanvas.height);
|
|
2028
|
+
}
|
|
2029
|
+
else {
|
|
2030
|
+
var splitWords = void 0;
|
|
2031
|
+
var isCropSelection = false;
|
|
2032
|
+
if (this.parent.activeObj.shape !== undefined) {
|
|
2033
|
+
splitWords = this.parent.activeObj.shape.split('-');
|
|
2034
|
+
}
|
|
2035
|
+
if (splitWords === undefined && this.parent.currObjType.isCustomCrop) {
|
|
2036
|
+
isCropSelection = true;
|
|
2037
|
+
}
|
|
2038
|
+
else if (splitWords !== undefined && splitWords[0] === 'crop') {
|
|
2039
|
+
isCropSelection = true;
|
|
2040
|
+
}
|
|
2041
|
+
if (this.parent.activeObj.shape && !isCropSelection && this.parent.activeObj.shape !== 'shape') {
|
|
2042
|
+
for (var i = 0; i < this.parent.objColl.length; i++) {
|
|
2043
|
+
if (JSON.stringify(this.parent.activeObj) === JSON.stringify(this.parent.objColl[i])) {
|
|
2044
|
+
isActObj = true;
|
|
2045
|
+
break;
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
if (!isActObj) {
|
|
2049
|
+
if (isNullOrUndefined(this.parent.activeObj.currIndex)) {
|
|
2050
|
+
this.parent.activeObj.currIndex = 'shape_' + (this.parent.objColl.length + 1);
|
|
2051
|
+
}
|
|
2052
|
+
this.updImgRatioForActObj();
|
|
2053
|
+
var splitWords_1 = this.parent.activeObj.currIndex.split('_');
|
|
2054
|
+
var tempObjColl = this.parent.objColl.splice(0, parseInt(splitWords_1[1], 10) - 1);
|
|
2055
|
+
tempObjColl.push(extend({}, this.parent.activeObj, {}, true));
|
|
2056
|
+
for (var i = 0; i < this.parent.objColl.length; i++) {
|
|
2057
|
+
tempObjColl.push(this.parent.objColl[i]);
|
|
2058
|
+
}
|
|
2059
|
+
this.parent.objColl = tempObjColl;
|
|
2060
|
+
tempObjColl = [];
|
|
2061
|
+
this.refreshActiveObj();
|
|
2062
|
+
this.lowerContext.clearRect(0, 0, this.parent.lowerCanvas.width, this.parent.lowerCanvas.height);
|
|
2063
|
+
this.parent.notify('draw', { prop: 'redrawImgWithObj', onPropertyChange: false });
|
|
2064
|
+
this.parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
|
|
2065
|
+
this.parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.upperContext } });
|
|
2066
|
+
this.parent.currObjType.shape = '';
|
|
2067
|
+
this.refreshActiveObj();
|
|
2068
|
+
if (this.parent.isCircleCrop) {
|
|
2069
|
+
this.parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
|
|
2070
|
+
value: { context: this.lowerContext, isSave: null, isFlip: null } });
|
|
2071
|
+
}
|
|
2072
|
+
if (!isBlazor()) {
|
|
2073
|
+
this.parent.notify('toolbar', { prop: 'destroy-qa-toolbar', onPropertyChange: false });
|
|
2074
|
+
}
|
|
2075
|
+
else {
|
|
2076
|
+
this.parent.updateToolbar(this.parent.element, 'destroyQuickAccessToolbar');
|
|
2077
|
+
}
|
|
2078
|
+
if (isNullOrUndefined(isMouseDown)) {
|
|
2079
|
+
this.parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
|
|
2080
|
+
this.parent.notify('draw', { prop: 'setPrevActObj', onPropertyChange: false, value: { prevActObj: null } });
|
|
2081
|
+
}
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
2085
|
+
};
|
|
2086
|
+
Shape.prototype.alignTextAreaIntoCanvas = function () {
|
|
2087
|
+
var parent = this.parent;
|
|
2088
|
+
var letters = parent.textArea.value;
|
|
2089
|
+
parent.textArea.value = '';
|
|
2090
|
+
for (var i = 0, len = letters.length; i < len; i++) {
|
|
2091
|
+
parent.textArea.value += letters[i];
|
|
2092
|
+
parent.textArea.style.height = 'auto';
|
|
2093
|
+
parent.textArea.style.height = parent.textArea.scrollHeight + 'px';
|
|
2094
|
+
this.setTextBoxWidth();
|
|
2095
|
+
}
|
|
2096
|
+
};
|
|
2097
|
+
Shape.prototype.transformTextArea = function () {
|
|
2098
|
+
var parent = this.parent;
|
|
2099
|
+
if (parent.activeObj.shape === 'text') {
|
|
2100
|
+
parent.textArea.style.transformOrigin = '0 0';
|
|
2101
|
+
var rotatedDegree = parent.activeObj.rotatedAngle * (180 / Math.PI);
|
|
2102
|
+
var scale = '';
|
|
2103
|
+
var degree = this.getRotDegOfShape(parent.activeObj);
|
|
2104
|
+
if (parent.activeObj.flipObjColl.length > 0) {
|
|
2105
|
+
// need to add scale value according to length.
|
|
2106
|
+
for (var i = 0; i < parent.activeObj.flipObjColl.length; i++) {
|
|
2107
|
+
if (degree !== 0 && degree % 90 === 0 && degree !== 180) {
|
|
2108
|
+
scale += parent.activeObj.flipObjColl[i].toLowerCase() === 'horizontal' ? 'scale(1, -1)' :
|
|
2109
|
+
'scale(-1, 1)';
|
|
2110
|
+
}
|
|
2111
|
+
else {
|
|
2112
|
+
scale += parent.activeObj.flipObjColl[i].toLowerCase() === 'horizontal' ? 'scale(-1, 1)' :
|
|
2113
|
+
'scale(1, -1)';
|
|
2114
|
+
}
|
|
2115
|
+
degree += rotatedDegree;
|
|
2116
|
+
if (parent.activeObj.flipObjColl[i].toLowerCase() === 'horizontal') {
|
|
2117
|
+
parent.textArea.style.transform = 'rotate(' + degree + 'deg)' + scale;
|
|
2118
|
+
}
|
|
2119
|
+
else if (parent.activeObj.flipObjColl[i].toLowerCase() === 'vertical') {
|
|
2120
|
+
parent.textArea.style.transform = 'rotate(' + degree + 'deg)' + scale;
|
|
2121
|
+
}
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
else {
|
|
2125
|
+
degree += rotatedDegree;
|
|
2126
|
+
parent.textArea.style.transform = 'rotate(' + degree + 'deg)';
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2129
|
+
};
|
|
2130
|
+
Shape.prototype.getTextAreaWidth = function (item) {
|
|
2131
|
+
var parent = this.parent;
|
|
2132
|
+
var tempBold = parent.activeObj.textSettings.bold;
|
|
2133
|
+
var tempItalic = parent.activeObj.textSettings.italic;
|
|
2134
|
+
switch (item) {
|
|
2135
|
+
case 'default':
|
|
2136
|
+
parent.activeObj.textSettings.bold = false;
|
|
2137
|
+
parent.activeObj.textSettings.italic = false;
|
|
2138
|
+
break;
|
|
2139
|
+
case 'bold':
|
|
2140
|
+
parent.activeObj.textSettings.bold = true;
|
|
2141
|
+
parent.activeObj.textSettings.italic = false;
|
|
2142
|
+
break;
|
|
2143
|
+
case 'italic':
|
|
2144
|
+
parent.activeObj.textSettings.bold = false;
|
|
2145
|
+
parent.activeObj.textSettings.italic = true;
|
|
2146
|
+
break;
|
|
2147
|
+
case 'bolditalic':
|
|
2148
|
+
parent.activeObj.textSettings.bold = true;
|
|
2149
|
+
parent.activeObj.textSettings.italic = true;
|
|
2150
|
+
break;
|
|
2151
|
+
}
|
|
2152
|
+
this.updateFontStyles();
|
|
2153
|
+
var width;
|
|
2154
|
+
if (parent.textArea.style.display === 'none') {
|
|
2155
|
+
width = this.upperContext.measureText(parent.activeObj.keyHistory).width +
|
|
2156
|
+
parent.activeObj.textSettings.fontSize * 0.5;
|
|
2157
|
+
}
|
|
2158
|
+
else {
|
|
2159
|
+
width = this.upperContext.measureText(parent.textArea.value).width +
|
|
2160
|
+
parent.activeObj.textSettings.fontSize * 0.5;
|
|
2161
|
+
}
|
|
2162
|
+
parent.activeObj.textSettings.bold = tempBold;
|
|
2163
|
+
parent.activeObj.textSettings.italic = tempItalic;
|
|
2164
|
+
return width;
|
|
2165
|
+
};
|
|
2166
|
+
Shape.prototype.getObjDetails = function (obj) {
|
|
2167
|
+
var parent = this.parent;
|
|
2168
|
+
var shapeDetails = {};
|
|
2169
|
+
shapeDetails.id = obj.currIndex;
|
|
2170
|
+
shapeDetails.type = parent.toPascalCase(obj.shape);
|
|
2171
|
+
shapeDetails.startX = obj.activePoint.startX;
|
|
2172
|
+
shapeDetails.startY = obj.activePoint.startY;
|
|
2173
|
+
switch (obj.shape) {
|
|
2174
|
+
case 'rectangle':
|
|
2175
|
+
shapeDetails.width = obj.activePoint.width;
|
|
2176
|
+
shapeDetails.height = obj.activePoint.height;
|
|
2177
|
+
shapeDetails.strokeColor = obj.strokeSettings.strokeColor;
|
|
2178
|
+
shapeDetails.fillColor = obj.strokeSettings.fillColor;
|
|
2179
|
+
shapeDetails.strokeWidth = obj.strokeSettings.strokeWidth;
|
|
2180
|
+
break;
|
|
2181
|
+
case 'ellipse':
|
|
2182
|
+
shapeDetails.radius = obj.activePoint.width / 2;
|
|
2183
|
+
shapeDetails.strokeColor = obj.strokeSettings.strokeColor;
|
|
2184
|
+
shapeDetails.fillColor = obj.strokeSettings.fillColor;
|
|
2185
|
+
shapeDetails.strokeWidth = obj.strokeSettings.strokeWidth;
|
|
2186
|
+
break;
|
|
2187
|
+
case 'line':
|
|
2188
|
+
case 'arrow':
|
|
2189
|
+
shapeDetails.length = obj.activePoint.width;
|
|
2190
|
+
shapeDetails.strokeColor = obj.strokeSettings.strokeColor;
|
|
2191
|
+
shapeDetails.strokeWidth = obj.strokeSettings.strokeWidth;
|
|
2192
|
+
break;
|
|
2193
|
+
case 'text':
|
|
2194
|
+
shapeDetails.text = obj.keyHistory;
|
|
2195
|
+
shapeDetails.fontSize = obj.textSettings.fontSize;
|
|
2196
|
+
shapeDetails.color = obj.strokeSettings.strokeColor;
|
|
2197
|
+
shapeDetails.fontStyle = [];
|
|
2198
|
+
if (obj.textSettings.bold) {
|
|
2199
|
+
shapeDetails.fontStyle.push('bold');
|
|
2200
|
+
}
|
|
2201
|
+
if (obj.textSettings.italic) {
|
|
2202
|
+
shapeDetails.fontStyle.push('italic');
|
|
2203
|
+
}
|
|
2204
|
+
break;
|
|
2205
|
+
}
|
|
2206
|
+
return shapeDetails;
|
|
2207
|
+
};
|
|
2208
|
+
Shape.prototype.getFreehandDrawDetails = function (index) {
|
|
2209
|
+
var parent = this.parent;
|
|
2210
|
+
var shapeDetails = {};
|
|
2211
|
+
shapeDetails.id = parent.pointColl[index].id;
|
|
2212
|
+
shapeDetails.type = ShapeType.FreehandDraw;
|
|
2213
|
+
shapeDetails.points = extend([], parent.pointColl[index].points);
|
|
2214
|
+
shapeDetails.strokeColor = parent.pointColl[index].strokeColor;
|
|
2215
|
+
shapeDetails.strokeWidth = parent.pointColl[index].strokeWidth;
|
|
2216
|
+
return shapeDetails;
|
|
2217
|
+
};
|
|
2218
|
+
Shape.prototype.getShapeSetting = function (id, obj) {
|
|
2219
|
+
var parent = this.parent;
|
|
2220
|
+
var shapeDetails;
|
|
2221
|
+
if (!parent.disabled && parent.isImageLoaded) {
|
|
2222
|
+
this.applyActObj();
|
|
2223
|
+
if (id.split('_')[0] === 'shape') {
|
|
2224
|
+
var obj_1;
|
|
2225
|
+
for (var i = 0, len = parent.objColl.length; i < len; i++) {
|
|
2226
|
+
if (parent.objColl[i].currIndex === id) {
|
|
2227
|
+
obj_1 = extend({}, parent.objColl[i], {}, true);
|
|
2228
|
+
break;
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2231
|
+
shapeDetails = this.getObjDetails(obj_1);
|
|
2232
|
+
}
|
|
2233
|
+
else if (id.split('_')[0] === 'pen') {
|
|
2234
|
+
shapeDetails = this.getFreehandDrawDetails(parseInt(id.split('_')[1], 10) - 1);
|
|
2235
|
+
}
|
|
2236
|
+
}
|
|
2237
|
+
obj['shapeDetails'] = shapeDetails;
|
|
2238
|
+
};
|
|
2239
|
+
Shape.prototype.getShapeSettings = function (obj) {
|
|
2240
|
+
var parent = this.parent;
|
|
2241
|
+
var shapeDetailsColl = [];
|
|
2242
|
+
if (!parent.disabled && parent.isImageLoaded) {
|
|
2243
|
+
this.applyActObj();
|
|
2244
|
+
for (var i = 0, len = parent.objColl.length; i < len; i++) {
|
|
2245
|
+
var shapeDetails = this.getObjDetails(parent.objColl[i]);
|
|
2246
|
+
shapeDetailsColl.push(shapeDetails);
|
|
2247
|
+
}
|
|
2248
|
+
for (var i = 0; i < parent.freehandCounter; i++) {
|
|
2249
|
+
var shapeDetails = this.getFreehandDrawDetails(i);
|
|
2250
|
+
shapeDetailsColl.push(shapeDetails);
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
obj['shapeDetailsColl'] = shapeDetailsColl;
|
|
2254
|
+
};
|
|
2255
|
+
Shape.prototype.isPointsInRange = function (x, y, obj) {
|
|
2256
|
+
var inRange = false;
|
|
2257
|
+
if (!isNullOrUndefined(x) && !isNullOrUndefined(y) && x >= 0 && y >= 0 &&
|
|
2258
|
+
x <= this.parent.lowerCanvas.width && y <= this.parent.lowerCanvas.width) {
|
|
2259
|
+
inRange = true;
|
|
2260
|
+
}
|
|
2261
|
+
obj['inRange'] = inRange;
|
|
2262
|
+
};
|
|
2263
|
+
Shape.prototype.alignRotateFlipColl = function (collection, isRotateFlipCollection, obj) {
|
|
2264
|
+
collection = this.popForDefaultTransformedState(collection);
|
|
2265
|
+
collection = this.popForDefaultFlipState(collection);
|
|
2266
|
+
collection = this.popForDefaultRotateState(collection);
|
|
2267
|
+
if (collection.length === 0 && isRotateFlipCollection) {
|
|
2268
|
+
this.parent.transform.degree = 0;
|
|
2269
|
+
this.parent.transform.currFlipState = '';
|
|
2270
|
+
}
|
|
2271
|
+
obj['collection'] = collection;
|
|
2272
|
+
return collection;
|
|
2273
|
+
};
|
|
2274
|
+
Shape.prototype.popForDefaultTransformedState = function (collection) {
|
|
2275
|
+
var rotateRight = 0;
|
|
2276
|
+
var rotateleft = 0;
|
|
2277
|
+
var horizontal = 0;
|
|
2278
|
+
var vertical = 0;
|
|
2279
|
+
for (var i = 0; i < collection.length; i++) {
|
|
2280
|
+
if (collection[i] === 90 || collection[i] === 'rotateRight') {
|
|
2281
|
+
rotateRight++;
|
|
2282
|
+
rotateleft = 0;
|
|
2283
|
+
horizontal = 0;
|
|
2284
|
+
vertical = 0;
|
|
2285
|
+
if (rotateRight === 4) {
|
|
2286
|
+
collection.pop();
|
|
2287
|
+
collection.pop();
|
|
2288
|
+
collection.pop();
|
|
2289
|
+
collection.pop();
|
|
2290
|
+
}
|
|
2291
|
+
}
|
|
2292
|
+
else if (collection[i] === -90 || collection[i] === 'rotateLeft') {
|
|
2293
|
+
rotateleft++;
|
|
2294
|
+
rotateRight = 0;
|
|
2295
|
+
horizontal = 0;
|
|
2296
|
+
vertical = 0;
|
|
2297
|
+
if (rotateleft === 4) {
|
|
2298
|
+
collection.pop();
|
|
2299
|
+
collection.pop();
|
|
2300
|
+
collection.pop();
|
|
2301
|
+
collection.pop();
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2304
|
+
else if (collection[i] === 'horizontal' || collection[i] === 'Horizontal'
|
|
2305
|
+
|| collection[i] === 'horizontalflip') {
|
|
2306
|
+
horizontal++;
|
|
2307
|
+
rotateleft = 0;
|
|
2308
|
+
rotateRight = 0;
|
|
2309
|
+
vertical = 0;
|
|
2310
|
+
if (horizontal === 2) {
|
|
2311
|
+
collection.pop();
|
|
2312
|
+
collection.pop();
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
else if (collection[i] === 'vertical' || collection[i] === 'Vertical'
|
|
2316
|
+
|| collection[i] === 'verticalflip') {
|
|
2317
|
+
vertical++;
|
|
2318
|
+
horizontal = 0;
|
|
2319
|
+
rotateleft = 0;
|
|
2320
|
+
rotateRight = 0;
|
|
2321
|
+
if (vertical === 2) {
|
|
2322
|
+
collection.pop();
|
|
2323
|
+
collection.pop();
|
|
2324
|
+
}
|
|
2325
|
+
}
|
|
2326
|
+
}
|
|
2327
|
+
return collection;
|
|
2328
|
+
};
|
|
2329
|
+
Shape.prototype.popForDefaultFlipState = function (collection) {
|
|
2330
|
+
for (var i = 0; i < collection.length; i++) {
|
|
2331
|
+
if (!isNullOrUndefined(collection[i + 3])) {
|
|
2332
|
+
if ((collection[i] === 'horizontal' || collection[i] === 'Horizontal'
|
|
2333
|
+
|| collection[i] === 'horizontalFlip')
|
|
2334
|
+
&& (collection[i + 1] === 'vertical' || collection[i + 1] === 'Vertical'
|
|
2335
|
+
|| collection[i] === 'verticalFlip') &&
|
|
2336
|
+
(collection[i + 2] === 'horizontal' || collection[i + 2] === 'Horizontal'
|
|
2337
|
+
|| collection[i] === 'horizontalFlip') &&
|
|
2338
|
+
(collection[i + 3] === 'vertical' || collection[i + 3] === 'Vertical'
|
|
2339
|
+
|| collection[i] === 'verticalFlip')) {
|
|
2340
|
+
collection.pop();
|
|
2341
|
+
collection.pop();
|
|
2342
|
+
collection.pop();
|
|
2343
|
+
collection.pop();
|
|
2344
|
+
}
|
|
2345
|
+
else if ((collection[i] === 'vertical' || collection[i] === 'Vertical'
|
|
2346
|
+
|| collection[i] === 'verticalFlip')
|
|
2347
|
+
&& (collection[i + 1] === 'horizontal' || collection[i + 1] === 'Horizontal'
|
|
2348
|
+
|| collection[i + 1] === 'horizontalFlip') &&
|
|
2349
|
+
(collection[i + 2] === 'vertical' || collection[i + 2] === 'Vertical' || collection[i] === 'verticalFlip') &&
|
|
2350
|
+
(collection[i + 3] === 'horizontal' || collection[i + 3] === 'Horizontal' || collection[i] === 'horizontalFlip')) {
|
|
2351
|
+
collection.pop();
|
|
2352
|
+
collection.pop();
|
|
2353
|
+
collection.pop();
|
|
2354
|
+
collection.pop();
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
return collection;
|
|
2359
|
+
};
|
|
2360
|
+
Shape.prototype.popForDefaultRotateState = function (collection) {
|
|
2361
|
+
for (var i = 0; i < collection.length; i++) {
|
|
2362
|
+
if (!isNullOrUndefined(collection[i + 1])) {
|
|
2363
|
+
if ((collection[i] === 90 || collection[i] === 'rotateRight') &&
|
|
2364
|
+
(collection[i + 1] === -90 || collection[i] === 'rotateLeft')) {
|
|
2365
|
+
collection.pop();
|
|
2366
|
+
collection.pop();
|
|
2367
|
+
}
|
|
2368
|
+
else if ((collection[i] === -90 || collection[i] === 'rotateLeft') &&
|
|
2369
|
+
(collection[i + 1] === 90 || collection[i] === 'rotateRight')) {
|
|
2370
|
+
collection.pop();
|
|
2371
|
+
collection.pop();
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2374
|
+
}
|
|
2375
|
+
return collection;
|
|
2376
|
+
};
|
|
2377
|
+
Shape.prototype.selectShape = function (id, obj) {
|
|
2378
|
+
var parent = this.parent;
|
|
2379
|
+
var isSelected = false;
|
|
2380
|
+
if (!parent.disabled && parent.isImageLoaded) {
|
|
2381
|
+
this.applyActObj();
|
|
2382
|
+
if (id.split('_')[0] === 'shape') {
|
|
2383
|
+
var obj_2;
|
|
2384
|
+
for (var i = 0, len = parent.objColl.length; i < len; i++) {
|
|
2385
|
+
if (parent.objColl[i].currIndex === id) {
|
|
2386
|
+
obj_2 = extend({}, parent.objColl[i], {}, true);
|
|
2387
|
+
break;
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2390
|
+
if (isNullOrUndefined(obj_2)) {
|
|
2391
|
+
isSelected = false;
|
|
2392
|
+
}
|
|
2393
|
+
else {
|
|
2394
|
+
isSelected = true;
|
|
2395
|
+
parent.activeObj = obj_2;
|
|
2396
|
+
var object = { canvasFilter: null };
|
|
2397
|
+
parent.notify('toolbar', { prop: 'getCanvasFilter', onPropertyChange: false, value: { obj: object } });
|
|
2398
|
+
this.lowerContext.filter = object['canvasFilter'];
|
|
2399
|
+
parent.notify('selection', { prop: 'redrawShape', onPropertyChange: false,
|
|
2400
|
+
value: { obj: parent.activeObj } });
|
|
2401
|
+
if (!isBlazor()) {
|
|
2402
|
+
if (parent.activeObj.shape === 'text') {
|
|
2403
|
+
parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'text',
|
|
2404
|
+
isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
|
|
2405
|
+
}
|
|
2406
|
+
else if (parent.activeObj.shape === 'pen') {
|
|
2407
|
+
parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'pen',
|
|
2408
|
+
isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
|
|
2409
|
+
}
|
|
2410
|
+
else {
|
|
2411
|
+
parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'shapes',
|
|
2412
|
+
isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
|
|
2413
|
+
}
|
|
2414
|
+
parent.notify('toolbar', { prop: 'update-toolbar-items', onPropertyChange: false });
|
|
2415
|
+
}
|
|
2416
|
+
else {
|
|
2417
|
+
if (parent.activeObj.shape === 'path') {
|
|
2418
|
+
parent.updateToolbar(this.parent.element, 'path', 'pathQuickAccessToolbar');
|
|
2419
|
+
}
|
|
2420
|
+
else {
|
|
2421
|
+
parent.updateToolbar(parent.element, 'quickAccessToolbar', parent.activeObj.shape);
|
|
2422
|
+
}
|
|
2423
|
+
}
|
|
2424
|
+
}
|
|
2425
|
+
}
|
|
2426
|
+
else if (id.split('_')[0] === 'pen') {
|
|
2427
|
+
var object = { bool: false };
|
|
2428
|
+
parent.notify('selection', { prop: 'getFreehandDrawEditing', onPropertyChange: false, value: { obj: object } });
|
|
2429
|
+
if (object['bool']) {
|
|
2430
|
+
parent.okBtn();
|
|
2431
|
+
}
|
|
2432
|
+
var obj_3 = { isIndex: false };
|
|
2433
|
+
parent.notify('freehand-draw', { prop: 'isFHDIdx', value: { index: parseInt(id.split('_')[1], 10) - 1, obj: obj_3 } });
|
|
2434
|
+
if (obj_3['isIndex']) {
|
|
2435
|
+
isSelected = true;
|
|
2436
|
+
parent.notify('freehand-draw', { prop: 'selectFhd', value: { id: id } });
|
|
2437
|
+
if (!isBlazor()) {
|
|
2438
|
+
parent.notify('toolbar', { prop: 'update-toolbar-items', onPropertyChange: false });
|
|
2439
|
+
}
|
|
2440
|
+
}
|
|
2441
|
+
else {
|
|
2442
|
+
isSelected = false;
|
|
2443
|
+
}
|
|
2444
|
+
}
|
|
2445
|
+
}
|
|
2446
|
+
obj['isSelected'] = isSelected;
|
|
2447
|
+
};
|
|
2448
|
+
Shape.prototype.deleteShape = function (id) {
|
|
2449
|
+
var parent = this.parent;
|
|
2450
|
+
if (!parent.disabled && parent.isImageLoaded) {
|
|
2451
|
+
this.applyActObj();
|
|
2452
|
+
if (id.split('_')[0] === 'shape') {
|
|
2453
|
+
for (var i = 0, len = parent.objColl.length; i < len; i++) {
|
|
2454
|
+
if (parent.objColl[i].currIndex === id) {
|
|
2455
|
+
parent.objColl.splice(i, 1);
|
|
2456
|
+
break;
|
|
2457
|
+
}
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2460
|
+
else if (id.split('_')[0] === 'pen') {
|
|
2461
|
+
parent.notify('freehand-draw', { prop: 'handle-freehand-draw', value: { id: id } });
|
|
2462
|
+
}
|
|
2463
|
+
var object = { canvasFilter: null };
|
|
2464
|
+
parent.notify('toolbar', { prop: 'getCanvasFilter', onPropertyChange: false, value: { obj: object } });
|
|
2465
|
+
this.lowerContext.filter = object['canvasFilter'];
|
|
2466
|
+
this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
|
|
2467
|
+
parent.notify('draw', { prop: 'redrawImgWithObj', onPropertyChange: false });
|
|
2468
|
+
parent.notify('toolbar', { prop: 'refresh-main-toolbar', onPropertyChange: false });
|
|
2469
|
+
}
|
|
2470
|
+
};
|
|
2471
|
+
Shape.prototype.getMaxText = function (isTextBox, text, obj) {
|
|
2472
|
+
if (isNullOrUndefined(text)) {
|
|
2473
|
+
text = isTextBox ? this.parent.textArea.value : this.parent.activeObj.keyHistory;
|
|
2474
|
+
}
|
|
2475
|
+
var maxi;
|
|
2476
|
+
var rows = text.split('\n');
|
|
2477
|
+
var maxStr = rows[0].length;
|
|
2478
|
+
var maxText = rows[0];
|
|
2479
|
+
for (var i = 1; i < rows.length; i++) {
|
|
2480
|
+
maxi = rows[i].length;
|
|
2481
|
+
if (maxi > maxStr) {
|
|
2482
|
+
maxText = rows[i];
|
|
2483
|
+
maxStr = maxi;
|
|
2484
|
+
}
|
|
2485
|
+
}
|
|
2486
|
+
if (obj) {
|
|
2487
|
+
obj['maxText'] = maxText;
|
|
2488
|
+
}
|
|
2489
|
+
return maxText;
|
|
2490
|
+
};
|
|
2491
|
+
Shape.prototype.getLinePoints = function (x1, y1, x2, y2) {
|
|
2492
|
+
var points = [];
|
|
2493
|
+
var i;
|
|
2494
|
+
var j;
|
|
2495
|
+
if (x1 === x2) {
|
|
2496
|
+
if (y1 < y2) {
|
|
2497
|
+
i = [x1, y1];
|
|
2498
|
+
j = [x2, y2];
|
|
2499
|
+
}
|
|
2500
|
+
else {
|
|
2501
|
+
j = [x1, y1];
|
|
2502
|
+
i = [x2, y2];
|
|
2503
|
+
}
|
|
2504
|
+
var m = this.getSlope(i, j, true);
|
|
2505
|
+
var b = this.getIntercept(i, m);
|
|
2506
|
+
for (var y = i[1]; y <= j[1]; y++) {
|
|
2507
|
+
var x = m * y + b;
|
|
2508
|
+
points.push({ x: x, y: y });
|
|
2509
|
+
}
|
|
2510
|
+
}
|
|
2511
|
+
else {
|
|
2512
|
+
if (x1 < x2) {
|
|
2513
|
+
i = [x1, y1];
|
|
2514
|
+
j = [x2, y2];
|
|
2515
|
+
}
|
|
2516
|
+
else {
|
|
2517
|
+
j = [x1, y1];
|
|
2518
|
+
i = [x2, y2];
|
|
2519
|
+
}
|
|
2520
|
+
var m = this.getSlope(i, j, false);
|
|
2521
|
+
var b = this.getIntercept(i, m);
|
|
2522
|
+
for (var x = i[0]; x <= j[0]; x++) {
|
|
2523
|
+
var y = m * x + b;
|
|
2524
|
+
points.push({ x: x, y: y });
|
|
2525
|
+
}
|
|
2526
|
+
}
|
|
2527
|
+
if (Math.floor(x1) === Math.floor(x2) || (points.length < 10 && (y2 - y1 > 10 || y1 - y2 > 10))) {
|
|
2528
|
+
points = [];
|
|
2529
|
+
var lesserY = Math.min(y1, y2);
|
|
2530
|
+
for (var i_1 = 0; i_1 < Math.abs(Math.floor(y2) - Math.floor(y1)); i_1++) {
|
|
2531
|
+
points.push({ x: x1, y: lesserY + i_1 });
|
|
2532
|
+
}
|
|
2533
|
+
if (points.length > 1) {
|
|
2534
|
+
var prev = void 0;
|
|
2535
|
+
if (isNullOrUndefined(points[points.length - 2])) {
|
|
2536
|
+
prev = { x: 0, y: 0 };
|
|
2537
|
+
}
|
|
2538
|
+
else {
|
|
2539
|
+
prev = points[points.length - 2];
|
|
2540
|
+
}
|
|
2541
|
+
var diffX = points[points.length - 1]['x'] - prev.x;
|
|
2542
|
+
var diffY = points[points.length - 1]['y'] - prev.y;
|
|
2543
|
+
points.push({ x: points[points.length - 1]['x'] + (diffX / 2), y: points[points.length - 1]['y'] + (diffY / 2) });
|
|
2544
|
+
}
|
|
2545
|
+
}
|
|
2546
|
+
else if (Math.floor(y1) === Math.floor(y2) || (points.length < 10 && (x2 - x1 > 10 || x1 - x2 > 10))) {
|
|
2547
|
+
points = [];
|
|
2548
|
+
var lesserX = Math.min(x1, x2);
|
|
2549
|
+
for (var i_2 = 0; i_2 < Math.abs(Math.floor(x2) - Math.floor(x1)); i_2++) {
|
|
2550
|
+
points.push({ x: lesserX + i_2, y: y1 });
|
|
2551
|
+
}
|
|
2552
|
+
if (points.length > 1) {
|
|
2553
|
+
var prev = void 0;
|
|
2554
|
+
if (isNullOrUndefined(points[points.length - 2])) {
|
|
2555
|
+
prev = { x: 0, y: 0 };
|
|
2556
|
+
}
|
|
2557
|
+
else {
|
|
2558
|
+
prev = points[points.length - 2];
|
|
2559
|
+
}
|
|
2560
|
+
var diffX = points[points.length - 1]['x'] - prev.x;
|
|
2561
|
+
var diffY = points[points.length - 1]['y'] - prev.y;
|
|
2562
|
+
points.push({ x: points[points.length - 1]['x'] + (diffX / 2), y: points[points.length - 1]['y'] + (diffY / 2) });
|
|
2563
|
+
}
|
|
2564
|
+
}
|
|
2565
|
+
return points;
|
|
2566
|
+
};
|
|
2567
|
+
Shape.prototype.getSlope = function (a, b, isSameAxis) {
|
|
2568
|
+
var slope;
|
|
2569
|
+
if (isSameAxis) {
|
|
2570
|
+
if (a[1] === b[1]) {
|
|
2571
|
+
return null;
|
|
2572
|
+
}
|
|
2573
|
+
slope = (b[0] - a[0]) / (b[1] - a[1]);
|
|
2574
|
+
}
|
|
2575
|
+
else {
|
|
2576
|
+
if (a[0] === b[0]) {
|
|
2577
|
+
return null;
|
|
2578
|
+
}
|
|
2579
|
+
slope = (b[1] - a[1]) / (b[0] - a[0]);
|
|
2580
|
+
}
|
|
2581
|
+
return slope;
|
|
2582
|
+
};
|
|
2583
|
+
Shape.prototype.getIntercept = function (point, getSlope) {
|
|
2584
|
+
if (getSlope === null) {
|
|
2585
|
+
return point[0];
|
|
2586
|
+
}
|
|
2587
|
+
return point[1] - getSlope * point[0];
|
|
2588
|
+
};
|
|
2589
|
+
Shape.prototype.setPointCollForShapeRotation = function (obj) {
|
|
2590
|
+
var center = { x: obj.activePoint.startX + (obj.activePoint.width / 2), y: obj.activePoint.startY +
|
|
2591
|
+
(obj.activePoint.height / 2) };
|
|
2592
|
+
var p1 = { x: Math.cos(obj.rotatedAngle) * (obj.activePoint.startX - center.x) - Math.sin(obj.rotatedAngle) *
|
|
2593
|
+
(obj.activePoint.startY - center.y) + center.x,
|
|
2594
|
+
y: Math.sin(obj.rotatedAngle) * (obj.activePoint.startX - center.x) + Math.cos(obj.rotatedAngle) *
|
|
2595
|
+
(obj.activePoint.startY - center.y) + center.y };
|
|
2596
|
+
var p2 = { x: Math.cos(obj.rotatedAngle) * (obj.activePoint.endX - center.x) - Math.sin(obj.rotatedAngle) *
|
|
2597
|
+
(obj.activePoint.startY - center.y) + center.x,
|
|
2598
|
+
y: Math.sin(obj.rotatedAngle) * (obj.activePoint.endX - center.x) + Math.cos(obj.rotatedAngle) * (obj.activePoint.startY
|
|
2599
|
+
- center.y) + center.y };
|
|
2600
|
+
var p3 = { x: Math.cos(obj.rotatedAngle) * (obj.activePoint.startX - center.x) - Math.sin(obj.rotatedAngle) *
|
|
2601
|
+
(obj.activePoint.endY - center.y) + center.x,
|
|
2602
|
+
y: Math.sin(obj.rotatedAngle) * (obj.activePoint.startX - center.x) + Math.cos(obj.rotatedAngle) * (obj.activePoint.endY
|
|
2603
|
+
- center.y) + center.y };
|
|
2604
|
+
var p4 = { x: Math.cos(obj.rotatedAngle) * (obj.activePoint.endX - center.x) - Math.sin(obj.rotatedAngle) *
|
|
2605
|
+
(obj.activePoint.endY - center.y) + center.x,
|
|
2606
|
+
y: Math.sin(obj.rotatedAngle) * (obj.activePoint.endX - center.x) + Math.cos(obj.rotatedAngle) * (obj.activePoint.endY
|
|
2607
|
+
- center.y) + center.y };
|
|
2608
|
+
obj.horTopLinePointColl = this.getLinePoints(p1.x, p1.y, p2.x, p2.y);
|
|
2609
|
+
obj.horBottomLinePointColl = this.getLinePoints(p3.x, p3.y, p4.x, p4.y);
|
|
2610
|
+
obj.verLeftLinePointColl = this.getLinePoints(p1.x, p1.y, p3.x, p3.y);
|
|
2611
|
+
obj.verRightLinePointColl = this.getLinePoints(p2.x, p2.y, p4.x, p4.y);
|
|
2612
|
+
obj.verLeftLinePointColl.reverse();
|
|
2613
|
+
obj.verRightLinePointColl.reverse();
|
|
2614
|
+
// Updating ratio for point collection
|
|
2615
|
+
for (var i = 0; i < obj.horTopLinePointColl.length; i++) {
|
|
2616
|
+
obj.horTopLinePointColl[i].ratioX = (obj.horTopLinePointColl[i].x -
|
|
2617
|
+
this.parent.img.destLeft) / this.parent.img.destWidth;
|
|
2618
|
+
obj.horTopLinePointColl[i].ratioY = (obj.horTopLinePointColl[i].y -
|
|
2619
|
+
this.parent.img.destTop) / this.parent.img.destHeight;
|
|
2620
|
+
}
|
|
2621
|
+
for (var i = 0; i < obj.horBottomLinePointColl.length; i++) {
|
|
2622
|
+
obj.horBottomLinePointColl[i].ratioX = (obj.horBottomLinePointColl[i].x -
|
|
2623
|
+
this.parent.img.destLeft) / this.parent.img.destWidth;
|
|
2624
|
+
obj.horBottomLinePointColl[i].ratioY = (obj.horBottomLinePointColl[i].y -
|
|
2625
|
+
this.parent.img.destTop) / this.parent.img.destHeight;
|
|
2626
|
+
}
|
|
2627
|
+
for (var i = 0; i < obj.verLeftLinePointColl.length; i++) {
|
|
2628
|
+
obj.verLeftLinePointColl[i].ratioX = (obj.verLeftLinePointColl[i].x -
|
|
2629
|
+
this.parent.img.destLeft) / this.parent.img.destWidth;
|
|
2630
|
+
obj.verLeftLinePointColl[i].ratioY = (obj.verLeftLinePointColl[i].y -
|
|
2631
|
+
this.parent.img.destTop) / this.parent.img.destHeight;
|
|
2632
|
+
}
|
|
2633
|
+
for (var i = 0; i < obj.verRightLinePointColl.length; i++) {
|
|
2634
|
+
obj.verRightLinePointColl[i].ratioX = (obj.verRightLinePointColl[i].x -
|
|
2635
|
+
this.parent.img.destLeft) / this.parent.img.destWidth;
|
|
2636
|
+
obj.verRightLinePointColl[i].ratioY = (obj.verRightLinePointColl[i].y -
|
|
2637
|
+
this.parent.img.destTop) / this.parent.img.destHeight;
|
|
2638
|
+
}
|
|
2639
|
+
if (this.parent.upperCanvas.style.cursor !== 'move') {
|
|
2640
|
+
var object = { rotationCirclePoint: null };
|
|
2641
|
+
this.parent.notify('selection', { prop: 'getTransRotationPoint', value: { obj: obj, object: object } });
|
|
2642
|
+
var rotationCirclePoint = object['rotationCirclePoint'];
|
|
2643
|
+
if (rotationCirclePoint) {
|
|
2644
|
+
obj.rotationCirclePointColl = { x: Math.cos(obj.rotatedAngle) * (rotationCirclePoint.x - center.x) -
|
|
2645
|
+
Math.sin(obj.rotatedAngle) * (rotationCirclePoint.y - center.y) + center.x,
|
|
2646
|
+
y: Math.sin(obj.rotatedAngle) * (rotationCirclePoint.x - center.x) + Math.cos(obj.rotatedAngle)
|
|
2647
|
+
* (rotationCirclePoint.y - center.y) + center.y };
|
|
2648
|
+
obj.rotationCirclePointColl.ratioX = (obj.rotationCirclePointColl.x - this.parent.img.destLeft) /
|
|
2649
|
+
this.parent.img.destWidth;
|
|
2650
|
+
obj.rotationCirclePointColl.ratioY = (obj.rotationCirclePointColl.y - this.parent.img.destTop) /
|
|
2651
|
+
this.parent.img.destHeight;
|
|
2652
|
+
}
|
|
2653
|
+
}
|
|
2654
|
+
};
|
|
2655
|
+
return Shape;
|
|
2656
|
+
}());
|
|
2657
|
+
export { Shape };
|