konva 8.4.3 → 9.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/README.md +1 -9
  2. package/konva.js +17691 -16989
  3. package/konva.min.js +3 -3
  4. package/lib/Animation.js +11 -7
  5. package/lib/BezierFunctions.d.ts +6 -0
  6. package/lib/BezierFunctions.js +791 -0
  7. package/lib/Canvas.d.ts +1 -0
  8. package/lib/Canvas.js +26 -18
  9. package/lib/Container.js +16 -12
  10. package/lib/Context.d.ts +3 -1
  11. package/lib/Context.js +18 -10
  12. package/lib/Core.js +7 -3
  13. package/lib/DragAndDrop.js +25 -22
  14. package/lib/Factory.js +27 -24
  15. package/lib/FastLayer.js +10 -6
  16. package/lib/Global.js +16 -12
  17. package/lib/Group.js +10 -6
  18. package/lib/Layer.js +37 -33
  19. package/lib/Node.d.ts +1 -0
  20. package/lib/Node.js +105 -104
  21. package/lib/PointerEvents.js +15 -7
  22. package/lib/Shape.js +90 -86
  23. package/lib/Stage.js +51 -47
  24. package/lib/Tween.js +26 -22
  25. package/lib/Util.js +29 -25
  26. package/lib/Validators.js +58 -44
  27. package/lib/_CoreInternals.js +36 -33
  28. package/lib/_FullInternals.js +78 -75
  29. package/lib/filters/Blur.js +9 -5
  30. package/lib/filters/Brighten.js +9 -5
  31. package/lib/filters/Contrast.js +9 -5
  32. package/lib/filters/Emboss.js +14 -10
  33. package/lib/filters/Enhance.js +9 -5
  34. package/lib/filters/Grayscale.js +5 -1
  35. package/lib/filters/HSL.js +11 -7
  36. package/lib/filters/HSV.js +11 -7
  37. package/lib/filters/Invert.js +5 -1
  38. package/lib/filters/Kaleidoscope.js +13 -9
  39. package/lib/filters/Mask.js +9 -5
  40. package/lib/filters/Noise.js +9 -5
  41. package/lib/filters/Pixelate.js +11 -7
  42. package/lib/filters/Posterize.js +9 -5
  43. package/lib/filters/RGB.js +11 -7
  44. package/lib/filters/RGBA.js +12 -8
  45. package/lib/filters/Sepia.js +5 -1
  46. package/lib/filters/Solarize.js +5 -1
  47. package/lib/filters/Threshold.js +9 -5
  48. package/lib/index-node.js +7 -5
  49. package/lib/index.js +4 -2
  50. package/lib/shapes/Arc.js +17 -13
  51. package/lib/shapes/Arrow.js +17 -13
  52. package/lib/shapes/Circle.js +11 -7
  53. package/lib/shapes/Ellipse.js +13 -9
  54. package/lib/shapes/Image.js +21 -17
  55. package/lib/shapes/Label.js +18 -13
  56. package/lib/shapes/Line.js +14 -10
  57. package/lib/shapes/Path.d.ts +5 -2
  58. package/lib/shapes/Path.js +44 -43
  59. package/lib/shapes/Rect.js +13 -9
  60. package/lib/shapes/RegularPolygon.js +12 -8
  61. package/lib/shapes/Ring.js +12 -8
  62. package/lib/shapes/Sprite.js +19 -15
  63. package/lib/shapes/Star.js +13 -9
  64. package/lib/shapes/Text.js +31 -26
  65. package/lib/shapes/TextPath.d.ts +5 -1
  66. package/lib/shapes/TextPath.js +82 -188
  67. package/lib/shapes/Transformer.d.ts +2 -0
  68. package/lib/shapes/Transformer.js +97 -82
  69. package/lib/shapes/Wedge.js +16 -12
  70. package/lib/types.d.ts +6 -0
  71. package/lib/types.js +5 -2
  72. package/package.json +13 -42
  73. package/cmj/Animation.d.ts +0 -24
  74. package/cmj/Animation.js +0 -145
  75. package/cmj/Canvas.d.ts +0 -32
  76. package/cmj/Canvas.js +0 -114
  77. package/cmj/Container.d.ts +0 -47
  78. package/cmj/Container.js +0 -325
  79. package/cmj/Context.d.ts +0 -85
  80. package/cmj/Context.js +0 -538
  81. package/cmj/Core.d.ts +0 -3
  82. package/cmj/Core.js +0 -7
  83. package/cmj/DragAndDrop.d.ts +0 -17
  84. package/cmj/DragAndDrop.js +0 -111
  85. package/cmj/Factory.d.ts +0 -11
  86. package/cmj/Factory.js +0 -125
  87. package/cmj/FastLayer.d.ts +0 -4
  88. package/cmj/FastLayer.js +0 -16
  89. package/cmj/Global.d.ts +0 -34
  90. package/cmj/Global.js +0 -61
  91. package/cmj/Group.d.ts +0 -8
  92. package/cmj/Group.js +0 -17
  93. package/cmj/Layer.d.ts +0 -61
  94. package/cmj/Layer.js +0 -309
  95. package/cmj/Node.d.ts +0 -328
  96. package/cmj/Node.js +0 -1420
  97. package/cmj/PointerEvents.d.ts +0 -11
  98. package/cmj/PointerEvents.js +0 -45
  99. package/cmj/Shape.d.ts +0 -186
  100. package/cmj/Shape.js +0 -521
  101. package/cmj/Stage.d.ts +0 -85
  102. package/cmj/Stage.js +0 -692
  103. package/cmj/Tween.d.ts +0 -86
  104. package/cmj/Tween.js +0 -520
  105. package/cmj/Util.d.ts +0 -91
  106. package/cmj/Util.js +0 -801
  107. package/cmj/Validators.d.ts +0 -11
  108. package/cmj/Validators.js +0 -192
  109. package/cmj/_CoreInternals.d.ts +0 -152
  110. package/cmj/_CoreInternals.js +0 -37
  111. package/cmj/_FullInternals.d.ts +0 -196
  112. package/cmj/_FullInternals.js +0 -81
  113. package/cmj/filters/Blur.d.ts +0 -2
  114. package/cmj/filters/Blur.js +0 -701
  115. package/cmj/filters/Brighten.d.ts +0 -2
  116. package/cmj/filters/Brighten.js +0 -16
  117. package/cmj/filters/Contrast.d.ts +0 -2
  118. package/cmj/filters/Contrast.js +0 -38
  119. package/cmj/filters/Emboss.d.ts +0 -2
  120. package/cmj/filters/Emboss.js +0 -106
  121. package/cmj/filters/Enhance.d.ts +0 -2
  122. package/cmj/filters/Enhance.js +0 -87
  123. package/cmj/filters/Grayscale.d.ts +0 -2
  124. package/cmj/filters/Grayscale.js +0 -13
  125. package/cmj/filters/HSL.d.ts +0 -2
  126. package/cmj/filters/HSL.js +0 -28
  127. package/cmj/filters/HSV.d.ts +0 -2
  128. package/cmj/filters/HSV.js +0 -28
  129. package/cmj/filters/Invert.d.ts +0 -2
  130. package/cmj/filters/Invert.js +0 -12
  131. package/cmj/filters/Kaleidoscope.d.ts +0 -2
  132. package/cmj/filters/Kaleidoscope.js +0 -137
  133. package/cmj/filters/Mask.d.ts +0 -2
  134. package/cmj/filters/Mask.js +0 -144
  135. package/cmj/filters/Noise.d.ts +0 -2
  136. package/cmj/filters/Noise.js +0 -16
  137. package/cmj/filters/Pixelate.d.ts +0 -2
  138. package/cmj/filters/Pixelate.js +0 -64
  139. package/cmj/filters/Posterize.d.ts +0 -2
  140. package/cmj/filters/Posterize.js +0 -14
  141. package/cmj/filters/RGB.d.ts +0 -2
  142. package/cmj/filters/RGB.js +0 -43
  143. package/cmj/filters/RGBA.d.ts +0 -2
  144. package/cmj/filters/RGBA.js +0 -53
  145. package/cmj/filters/Sepia.d.ts +0 -2
  146. package/cmj/filters/Sepia.js +0 -15
  147. package/cmj/filters/Solarize.d.ts +0 -2
  148. package/cmj/filters/Solarize.js +0 -29
  149. package/cmj/filters/Threshold.d.ts +0 -2
  150. package/cmj/filters/Threshold.js +0 -14
  151. package/cmj/index-node.d.ts +0 -2
  152. package/cmj/index-node.js +0 -21
  153. package/cmj/index-types.d.ts +0 -181
  154. package/cmj/index.d.ts +0 -2
  155. package/cmj/index.js +0 -4
  156. package/cmj/package.json +0 -6
  157. package/cmj/shapes/Arc.d.ts +0 -26
  158. package/cmj/shapes/Arc.js +0 -59
  159. package/cmj/shapes/Arrow.d.ts +0 -26
  160. package/cmj/shapes/Arrow.js +0 -103
  161. package/cmj/shapes/Circle.d.ts +0 -14
  162. package/cmj/shapes/Circle.js +0 -37
  163. package/cmj/shapes/Ellipse.d.ts +0 -17
  164. package/cmj/shapes/Ellipse.js +0 -41
  165. package/cmj/shapes/Image.d.ts +0 -25
  166. package/cmj/shapes/Image.js +0 -117
  167. package/cmj/shapes/Label.d.ts +0 -36
  168. package/cmj/shapes/Label.js +0 -178
  169. package/cmj/shapes/Line.d.ts +0 -28
  170. package/cmj/shapes/Line.js +0 -159
  171. package/cmj/shapes/Path.d.ts +0 -37
  172. package/cmj/shapes/Path.js +0 -631
  173. package/cmj/shapes/Rect.d.ts +0 -10
  174. package/cmj/shapes/Rect.js +0 -26
  175. package/cmj/shapes/RegularPolygon.d.ts +0 -23
  176. package/cmj/shapes/RegularPolygon.js +0 -69
  177. package/cmj/shapes/Ring.d.ts +0 -16
  178. package/cmj/shapes/Ring.js +0 -37
  179. package/cmj/shapes/Sprite.d.ts +0 -31
  180. package/cmj/shapes/Sprite.js +0 -112
  181. package/cmj/shapes/Star.d.ts +0 -18
  182. package/cmj/shapes/Star.js +0 -42
  183. package/cmj/shapes/Text.d.ts +0 -63
  184. package/cmj/shapes/Text.js +0 -373
  185. package/cmj/shapes/TextPath.d.ts +0 -56
  186. package/cmj/shapes/TextPath.js +0 -351
  187. package/cmj/shapes/Transformer.d.ts +0 -116
  188. package/cmj/shapes/Transformer.js +0 -971
  189. package/cmj/shapes/Wedge.d.ts +0 -18
  190. package/cmj/shapes/Wedge.js +0 -42
  191. package/cmj/types.d.ts +0 -50
  192. package/cmj/types.js +0 -25
@@ -1,971 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Transformer = void 0;
4
- const Util_1 = require("../Util");
5
- const Factory_1 = require("../Factory");
6
- const Node_1 = require("../Node");
7
- const Shape_1 = require("../Shape");
8
- const Rect_1 = require("./Rect");
9
- const Group_1 = require("../Group");
10
- const Global_1 = require("../Global");
11
- const Validators_1 = require("../Validators");
12
- const Global_2 = require("../Global");
13
- var EVENTS_NAME = 'tr-konva';
14
- var ATTR_CHANGE_LIST = [
15
- 'resizeEnabledChange',
16
- 'rotateAnchorOffsetChange',
17
- 'rotateEnabledChange',
18
- 'enabledAnchorsChange',
19
- 'anchorSizeChange',
20
- 'borderEnabledChange',
21
- 'borderStrokeChange',
22
- 'borderStrokeWidthChange',
23
- 'borderDashChange',
24
- 'anchorStrokeChange',
25
- 'anchorStrokeWidthChange',
26
- 'anchorFillChange',
27
- 'anchorCornerRadiusChange',
28
- 'ignoreStrokeChange',
29
- ]
30
- .map((e) => e + `.${EVENTS_NAME}`)
31
- .join(' ');
32
- var NODES_RECT = 'nodesRect';
33
- var TRANSFORM_CHANGE_STR = [
34
- 'widthChange',
35
- 'heightChange',
36
- 'scaleXChange',
37
- 'scaleYChange',
38
- 'skewXChange',
39
- 'skewYChange',
40
- 'rotationChange',
41
- 'offsetXChange',
42
- 'offsetYChange',
43
- 'transformsEnabledChange',
44
- 'strokeWidthChange',
45
- ];
46
- var ANGLES = {
47
- 'top-left': -45,
48
- 'top-center': 0,
49
- 'top-right': 45,
50
- 'middle-right': -90,
51
- 'middle-left': 90,
52
- 'bottom-left': -135,
53
- 'bottom-center': 180,
54
- 'bottom-right': 135,
55
- };
56
- const TOUCH_DEVICE = 'ontouchstart' in Global_1.Konva._global;
57
- function getCursor(anchorName, rad) {
58
- if (anchorName === 'rotater') {
59
- return 'crosshair';
60
- }
61
- rad += Util_1.Util.degToRad(ANGLES[anchorName] || 0);
62
- var angle = ((Util_1.Util.radToDeg(rad) % 360) + 360) % 360;
63
- if (Util_1.Util._inRange(angle, 315 + 22.5, 360) || Util_1.Util._inRange(angle, 0, 22.5)) {
64
- return 'ns-resize';
65
- }
66
- else if (Util_1.Util._inRange(angle, 45 - 22.5, 45 + 22.5)) {
67
- return 'nesw-resize';
68
- }
69
- else if (Util_1.Util._inRange(angle, 90 - 22.5, 90 + 22.5)) {
70
- return 'ew-resize';
71
- }
72
- else if (Util_1.Util._inRange(angle, 135 - 22.5, 135 + 22.5)) {
73
- return 'nwse-resize';
74
- }
75
- else if (Util_1.Util._inRange(angle, 180 - 22.5, 180 + 22.5)) {
76
- return 'ns-resize';
77
- }
78
- else if (Util_1.Util._inRange(angle, 225 - 22.5, 225 + 22.5)) {
79
- return 'nesw-resize';
80
- }
81
- else if (Util_1.Util._inRange(angle, 270 - 22.5, 270 + 22.5)) {
82
- return 'ew-resize';
83
- }
84
- else if (Util_1.Util._inRange(angle, 315 - 22.5, 315 + 22.5)) {
85
- return 'nwse-resize';
86
- }
87
- else {
88
- Util_1.Util.error('Transformer has unknown angle for cursor detection: ' + angle);
89
- return 'pointer';
90
- }
91
- }
92
- var ANCHORS_NAMES = [
93
- 'top-left',
94
- 'top-center',
95
- 'top-right',
96
- 'middle-right',
97
- 'middle-left',
98
- 'bottom-left',
99
- 'bottom-center',
100
- 'bottom-right',
101
- ];
102
- var MAX_SAFE_INTEGER = 100000000;
103
- function getCenter(shape) {
104
- return {
105
- x: shape.x +
106
- (shape.width / 2) * Math.cos(shape.rotation) +
107
- (shape.height / 2) * Math.sin(-shape.rotation),
108
- y: shape.y +
109
- (shape.height / 2) * Math.cos(shape.rotation) +
110
- (shape.width / 2) * Math.sin(shape.rotation),
111
- };
112
- }
113
- function rotateAroundPoint(shape, angleRad, point) {
114
- const x = point.x +
115
- (shape.x - point.x) * Math.cos(angleRad) -
116
- (shape.y - point.y) * Math.sin(angleRad);
117
- const y = point.y +
118
- (shape.x - point.x) * Math.sin(angleRad) +
119
- (shape.y - point.y) * Math.cos(angleRad);
120
- return Object.assign(Object.assign({}, shape), { rotation: shape.rotation + angleRad, x,
121
- y });
122
- }
123
- function rotateAroundCenter(shape, deltaRad) {
124
- const center = getCenter(shape);
125
- return rotateAroundPoint(shape, deltaRad, center);
126
- }
127
- function getSnap(snaps, newRotationRad, tol) {
128
- let snapped = newRotationRad;
129
- for (let i = 0; i < snaps.length; i++) {
130
- const angle = Global_1.Konva.getAngle(snaps[i]);
131
- const absDiff = Math.abs(angle - newRotationRad) % (Math.PI * 2);
132
- const dif = Math.min(absDiff, Math.PI * 2 - absDiff);
133
- if (dif < tol) {
134
- snapped = angle;
135
- }
136
- }
137
- return snapped;
138
- }
139
- class Transformer extends Group_1.Group {
140
- constructor(config) {
141
- super(config);
142
- this._transforming = false;
143
- this._createElements();
144
- this._handleMouseMove = this._handleMouseMove.bind(this);
145
- this._handleMouseUp = this._handleMouseUp.bind(this);
146
- this.update = this.update.bind(this);
147
- this.on(ATTR_CHANGE_LIST, this.update);
148
- if (this.getNode()) {
149
- this.update();
150
- }
151
- }
152
- attachTo(node) {
153
- this.setNode(node);
154
- return this;
155
- }
156
- setNode(node) {
157
- Util_1.Util.warn('tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead.');
158
- return this.setNodes([node]);
159
- }
160
- getNode() {
161
- return this._nodes && this._nodes[0];
162
- }
163
- _getEventNamespace() {
164
- return EVENTS_NAME + this._id;
165
- }
166
- setNodes(nodes = []) {
167
- if (this._nodes && this._nodes.length) {
168
- this.detach();
169
- }
170
- const filteredNodes = nodes.filter((node) => {
171
- if (node.isAncestorOf(this)) {
172
- Util_1.Util.error('Konva.Transformer cannot be an a child of the node you are trying to attach');
173
- return false;
174
- }
175
- return true;
176
- });
177
- this._nodes = nodes = filteredNodes;
178
- if (nodes.length === 1 && this.useSingleNodeRotation()) {
179
- this.rotation(nodes[0].getAbsoluteRotation());
180
- }
181
- else {
182
- this.rotation(0);
183
- }
184
- this._nodes.forEach((node) => {
185
- const onChange = () => {
186
- if (this.nodes().length === 1 && this.useSingleNodeRotation()) {
187
- this.rotation(this.nodes()[0].getAbsoluteRotation());
188
- }
189
- this._resetTransformCache();
190
- if (!this._transforming && !this.isDragging()) {
191
- this.update();
192
- }
193
- };
194
- const additionalEvents = node._attrsAffectingSize
195
- .map((prop) => prop + 'Change.' + this._getEventNamespace())
196
- .join(' ');
197
- node.on(additionalEvents, onChange);
198
- node.on(TRANSFORM_CHANGE_STR.map((e) => e + `.${this._getEventNamespace()}`).join(' '), onChange);
199
- node.on(`absoluteTransformChange.${this._getEventNamespace()}`, onChange);
200
- this._proxyDrag(node);
201
- });
202
- this._resetTransformCache();
203
- var elementsCreated = !!this.findOne('.top-left');
204
- if (elementsCreated) {
205
- this.update();
206
- }
207
- return this;
208
- }
209
- _proxyDrag(node) {
210
- let lastPos;
211
- node.on(`dragstart.${this._getEventNamespace()}`, (e) => {
212
- lastPos = node.getAbsolutePosition();
213
- if (!this.isDragging() && node !== this.findOne('.back')) {
214
- this.startDrag(e, false);
215
- }
216
- });
217
- node.on(`dragmove.${this._getEventNamespace()}`, (e) => {
218
- if (!lastPos) {
219
- return;
220
- }
221
- const abs = node.getAbsolutePosition();
222
- const dx = abs.x - lastPos.x;
223
- const dy = abs.y - lastPos.y;
224
- this.nodes().forEach((otherNode) => {
225
- if (otherNode === node) {
226
- return;
227
- }
228
- if (otherNode.isDragging()) {
229
- return;
230
- }
231
- const otherAbs = otherNode.getAbsolutePosition();
232
- otherNode.setAbsolutePosition({
233
- x: otherAbs.x + dx,
234
- y: otherAbs.y + dy,
235
- });
236
- otherNode.startDrag(e);
237
- });
238
- lastPos = null;
239
- });
240
- }
241
- getNodes() {
242
- return this._nodes || [];
243
- }
244
- getActiveAnchor() {
245
- return this._movingAnchorName;
246
- }
247
- detach() {
248
- if (this._nodes) {
249
- this._nodes.forEach((node) => {
250
- node.off('.' + this._getEventNamespace());
251
- });
252
- }
253
- this._nodes = [];
254
- this._resetTransformCache();
255
- }
256
- _resetTransformCache() {
257
- this._clearCache(NODES_RECT);
258
- this._clearCache('transform');
259
- this._clearSelfAndDescendantCache('absoluteTransform');
260
- }
261
- _getNodeRect() {
262
- return this._getCache(NODES_RECT, this.__getNodeRect);
263
- }
264
- __getNodeShape(node, rot = this.rotation(), relative) {
265
- var rect = node.getClientRect({
266
- skipTransform: true,
267
- skipShadow: true,
268
- skipStroke: this.ignoreStroke(),
269
- });
270
- var absScale = node.getAbsoluteScale(relative);
271
- var absPos = node.getAbsolutePosition(relative);
272
- var dx = rect.x * absScale.x - node.offsetX() * absScale.x;
273
- var dy = rect.y * absScale.y - node.offsetY() * absScale.y;
274
- const rotation = (Global_1.Konva.getAngle(node.getAbsoluteRotation()) + Math.PI * 2) %
275
- (Math.PI * 2);
276
- const box = {
277
- x: absPos.x + dx * Math.cos(rotation) + dy * Math.sin(-rotation),
278
- y: absPos.y + dy * Math.cos(rotation) + dx * Math.sin(rotation),
279
- width: rect.width * absScale.x,
280
- height: rect.height * absScale.y,
281
- rotation: rotation,
282
- };
283
- return rotateAroundPoint(box, -Global_1.Konva.getAngle(rot), {
284
- x: 0,
285
- y: 0,
286
- });
287
- }
288
- __getNodeRect() {
289
- var node = this.getNode();
290
- if (!node) {
291
- return {
292
- x: -MAX_SAFE_INTEGER,
293
- y: -MAX_SAFE_INTEGER,
294
- width: 0,
295
- height: 0,
296
- rotation: 0,
297
- };
298
- }
299
- const totalPoints = [];
300
- this.nodes().map((node) => {
301
- const box = node.getClientRect({
302
- skipTransform: true,
303
- skipShadow: true,
304
- skipStroke: this.ignoreStroke(),
305
- });
306
- var points = [
307
- { x: box.x, y: box.y },
308
- { x: box.x + box.width, y: box.y },
309
- { x: box.x + box.width, y: box.y + box.height },
310
- { x: box.x, y: box.y + box.height },
311
- ];
312
- var trans = node.getAbsoluteTransform();
313
- points.forEach(function (point) {
314
- var transformed = trans.point(point);
315
- totalPoints.push(transformed);
316
- });
317
- });
318
- const tr = new Util_1.Transform();
319
- tr.rotate(-Global_1.Konva.getAngle(this.rotation()));
320
- var minX, minY, maxX, maxY;
321
- totalPoints.forEach(function (point) {
322
- var transformed = tr.point(point);
323
- if (minX === undefined) {
324
- minX = maxX = transformed.x;
325
- minY = maxY = transformed.y;
326
- }
327
- minX = Math.min(minX, transformed.x);
328
- minY = Math.min(minY, transformed.y);
329
- maxX = Math.max(maxX, transformed.x);
330
- maxY = Math.max(maxY, transformed.y);
331
- });
332
- tr.invert();
333
- const p = tr.point({ x: minX, y: minY });
334
- return {
335
- x: p.x,
336
- y: p.y,
337
- width: maxX - minX,
338
- height: maxY - minY,
339
- rotation: Global_1.Konva.getAngle(this.rotation()),
340
- };
341
- }
342
- getX() {
343
- return this._getNodeRect().x;
344
- }
345
- getY() {
346
- return this._getNodeRect().y;
347
- }
348
- getWidth() {
349
- return this._getNodeRect().width;
350
- }
351
- getHeight() {
352
- return this._getNodeRect().height;
353
- }
354
- _createElements() {
355
- this._createBack();
356
- ANCHORS_NAMES.forEach(function (name) {
357
- this._createAnchor(name);
358
- }.bind(this));
359
- this._createAnchor('rotater');
360
- }
361
- _createAnchor(name) {
362
- var anchor = new Rect_1.Rect({
363
- stroke: 'rgb(0, 161, 255)',
364
- fill: 'white',
365
- strokeWidth: 1,
366
- name: name + ' _anchor',
367
- dragDistance: 0,
368
- draggable: true,
369
- hitStrokeWidth: TOUCH_DEVICE ? 10 : 'auto',
370
- });
371
- var self = this;
372
- anchor.on('mousedown touchstart', function (e) {
373
- self._handleMouseDown(e);
374
- });
375
- anchor.on('dragstart', (e) => {
376
- anchor.stopDrag();
377
- e.cancelBubble = true;
378
- });
379
- anchor.on('dragend', (e) => {
380
- e.cancelBubble = true;
381
- });
382
- anchor.on('mouseenter', () => {
383
- var rad = Global_1.Konva.getAngle(this.rotation());
384
- var cursor = getCursor(name, rad);
385
- anchor.getStage().content &&
386
- (anchor.getStage().content.style.cursor = cursor);
387
- this._cursorChange = true;
388
- });
389
- anchor.on('mouseout', () => {
390
- anchor.getStage().content &&
391
- (anchor.getStage().content.style.cursor = '');
392
- this._cursorChange = false;
393
- });
394
- this.add(anchor);
395
- }
396
- _createBack() {
397
- var back = new Shape_1.Shape({
398
- name: 'back',
399
- width: 0,
400
- height: 0,
401
- draggable: true,
402
- sceneFunc(ctx) {
403
- var tr = this.getParent();
404
- var padding = tr.padding();
405
- ctx.beginPath();
406
- ctx.rect(-padding, -padding, this.width() + padding * 2, this.height() + padding * 2);
407
- ctx.moveTo(this.width() / 2, -padding);
408
- if (tr.rotateEnabled()) {
409
- ctx.lineTo(this.width() / 2, -tr.rotateAnchorOffset() * Util_1.Util._sign(this.height()) - padding);
410
- }
411
- ctx.fillStrokeShape(this);
412
- },
413
- hitFunc: (ctx, shape) => {
414
- if (!this.shouldOverdrawWholeArea()) {
415
- return;
416
- }
417
- var padding = this.padding();
418
- ctx.beginPath();
419
- ctx.rect(-padding, -padding, shape.width() + padding * 2, shape.height() + padding * 2);
420
- ctx.fillStrokeShape(shape);
421
- },
422
- });
423
- this.add(back);
424
- this._proxyDrag(back);
425
- back.on('dragstart', (e) => {
426
- e.cancelBubble = true;
427
- });
428
- back.on('dragmove', (e) => {
429
- e.cancelBubble = true;
430
- });
431
- back.on('dragend', (e) => {
432
- e.cancelBubble = true;
433
- });
434
- this.on('dragmove', (e) => {
435
- this.update();
436
- });
437
- }
438
- _handleMouseDown(e) {
439
- this._movingAnchorName = e.target.name().split(' ')[0];
440
- var attrs = this._getNodeRect();
441
- var width = attrs.width;
442
- var height = attrs.height;
443
- var hypotenuse = Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2));
444
- this.sin = Math.abs(height / hypotenuse);
445
- this.cos = Math.abs(width / hypotenuse);
446
- if (typeof window !== 'undefined') {
447
- window.addEventListener('mousemove', this._handleMouseMove);
448
- window.addEventListener('touchmove', this._handleMouseMove);
449
- window.addEventListener('mouseup', this._handleMouseUp, true);
450
- window.addEventListener('touchend', this._handleMouseUp, true);
451
- }
452
- this._transforming = true;
453
- var ap = e.target.getAbsolutePosition();
454
- var pos = e.target.getStage().getPointerPosition();
455
- this._anchorDragOffset = {
456
- x: pos.x - ap.x,
457
- y: pos.y - ap.y,
458
- };
459
- this._fire('transformstart', { evt: e.evt, target: this.getNode() });
460
- this._nodes.forEach((target) => {
461
- target._fire('transformstart', { evt: e.evt, target });
462
- });
463
- }
464
- _handleMouseMove(e) {
465
- var x, y, newHypotenuse;
466
- var anchorNode = this.findOne('.' + this._movingAnchorName);
467
- var stage = anchorNode.getStage();
468
- stage.setPointersPositions(e);
469
- const pp = stage.getPointerPosition();
470
- let newNodePos = {
471
- x: pp.x - this._anchorDragOffset.x,
472
- y: pp.y - this._anchorDragOffset.y,
473
- };
474
- const oldAbs = anchorNode.getAbsolutePosition();
475
- if (this.anchorDragBoundFunc()) {
476
- newNodePos = this.anchorDragBoundFunc()(oldAbs, newNodePos, e);
477
- }
478
- anchorNode.setAbsolutePosition(newNodePos);
479
- const newAbs = anchorNode.getAbsolutePosition();
480
- if (oldAbs.x === newAbs.x && oldAbs.y === newAbs.y) {
481
- return;
482
- }
483
- if (this._movingAnchorName === 'rotater') {
484
- var attrs = this._getNodeRect();
485
- x = anchorNode.x() - attrs.width / 2;
486
- y = -anchorNode.y() + attrs.height / 2;
487
- let delta = Math.atan2(-y, x) + Math.PI / 2;
488
- if (attrs.height < 0) {
489
- delta -= Math.PI;
490
- }
491
- var oldRotation = Global_1.Konva.getAngle(this.rotation());
492
- const newRotation = oldRotation + delta;
493
- const tol = Global_1.Konva.getAngle(this.rotationSnapTolerance());
494
- const snappedRot = getSnap(this.rotationSnaps(), newRotation, tol);
495
- const diff = snappedRot - attrs.rotation;
496
- const shape = rotateAroundCenter(attrs, diff);
497
- this._fitNodesInto(shape, e);
498
- return;
499
- }
500
- var keepProportion = this.keepRatio() || e.shiftKey;
501
- var centeredScaling = this.centeredScaling() || e.altKey;
502
- if (this._movingAnchorName === 'top-left') {
503
- if (keepProportion) {
504
- var comparePoint = centeredScaling
505
- ? {
506
- x: this.width() / 2,
507
- y: this.height() / 2,
508
- }
509
- : {
510
- x: this.findOne('.bottom-right').x(),
511
- y: this.findOne('.bottom-right').y(),
512
- };
513
- newHypotenuse = Math.sqrt(Math.pow(comparePoint.x - anchorNode.x(), 2) +
514
- Math.pow(comparePoint.y - anchorNode.y(), 2));
515
- var reverseX = this.findOne('.top-left').x() > comparePoint.x ? -1 : 1;
516
- var reverseY = this.findOne('.top-left').y() > comparePoint.y ? -1 : 1;
517
- x = newHypotenuse * this.cos * reverseX;
518
- y = newHypotenuse * this.sin * reverseY;
519
- this.findOne('.top-left').x(comparePoint.x - x);
520
- this.findOne('.top-left').y(comparePoint.y - y);
521
- }
522
- }
523
- else if (this._movingAnchorName === 'top-center') {
524
- this.findOne('.top-left').y(anchorNode.y());
525
- }
526
- else if (this._movingAnchorName === 'top-right') {
527
- if (keepProportion) {
528
- var comparePoint = centeredScaling
529
- ? {
530
- x: this.width() / 2,
531
- y: this.height() / 2,
532
- }
533
- : {
534
- x: this.findOne('.bottom-left').x(),
535
- y: this.findOne('.bottom-left').y(),
536
- };
537
- newHypotenuse = Math.sqrt(Math.pow(anchorNode.x() - comparePoint.x, 2) +
538
- Math.pow(comparePoint.y - anchorNode.y(), 2));
539
- var reverseX = this.findOne('.top-right').x() < comparePoint.x ? -1 : 1;
540
- var reverseY = this.findOne('.top-right').y() > comparePoint.y ? -1 : 1;
541
- x = newHypotenuse * this.cos * reverseX;
542
- y = newHypotenuse * this.sin * reverseY;
543
- this.findOne('.top-right').x(comparePoint.x + x);
544
- this.findOne('.top-right').y(comparePoint.y - y);
545
- }
546
- var pos = anchorNode.position();
547
- this.findOne('.top-left').y(pos.y);
548
- this.findOne('.bottom-right').x(pos.x);
549
- }
550
- else if (this._movingAnchorName === 'middle-left') {
551
- this.findOne('.top-left').x(anchorNode.x());
552
- }
553
- else if (this._movingAnchorName === 'middle-right') {
554
- this.findOne('.bottom-right').x(anchorNode.x());
555
- }
556
- else if (this._movingAnchorName === 'bottom-left') {
557
- if (keepProportion) {
558
- var comparePoint = centeredScaling
559
- ? {
560
- x: this.width() / 2,
561
- y: this.height() / 2,
562
- }
563
- : {
564
- x: this.findOne('.top-right').x(),
565
- y: this.findOne('.top-right').y(),
566
- };
567
- newHypotenuse = Math.sqrt(Math.pow(comparePoint.x - anchorNode.x(), 2) +
568
- Math.pow(anchorNode.y() - comparePoint.y, 2));
569
- var reverseX = comparePoint.x < anchorNode.x() ? -1 : 1;
570
- var reverseY = anchorNode.y() < comparePoint.y ? -1 : 1;
571
- x = newHypotenuse * this.cos * reverseX;
572
- y = newHypotenuse * this.sin * reverseY;
573
- anchorNode.x(comparePoint.x - x);
574
- anchorNode.y(comparePoint.y + y);
575
- }
576
- pos = anchorNode.position();
577
- this.findOne('.top-left').x(pos.x);
578
- this.findOne('.bottom-right').y(pos.y);
579
- }
580
- else if (this._movingAnchorName === 'bottom-center') {
581
- this.findOne('.bottom-right').y(anchorNode.y());
582
- }
583
- else if (this._movingAnchorName === 'bottom-right') {
584
- if (keepProportion) {
585
- var comparePoint = centeredScaling
586
- ? {
587
- x: this.width() / 2,
588
- y: this.height() / 2,
589
- }
590
- : {
591
- x: this.findOne('.top-left').x(),
592
- y: this.findOne('.top-left').y(),
593
- };
594
- newHypotenuse = Math.sqrt(Math.pow(anchorNode.x() - comparePoint.x, 2) +
595
- Math.pow(anchorNode.y() - comparePoint.y, 2));
596
- var reverseX = this.findOne('.bottom-right').x() < comparePoint.x ? -1 : 1;
597
- var reverseY = this.findOne('.bottom-right').y() < comparePoint.y ? -1 : 1;
598
- x = newHypotenuse * this.cos * reverseX;
599
- y = newHypotenuse * this.sin * reverseY;
600
- this.findOne('.bottom-right').x(comparePoint.x + x);
601
- this.findOne('.bottom-right').y(comparePoint.y + y);
602
- }
603
- }
604
- else {
605
- console.error(new Error('Wrong position argument of selection resizer: ' +
606
- this._movingAnchorName));
607
- }
608
- var centeredScaling = this.centeredScaling() || e.altKey;
609
- if (centeredScaling) {
610
- var topLeft = this.findOne('.top-left');
611
- var bottomRight = this.findOne('.bottom-right');
612
- var topOffsetX = topLeft.x();
613
- var topOffsetY = topLeft.y();
614
- var bottomOffsetX = this.getWidth() - bottomRight.x();
615
- var bottomOffsetY = this.getHeight() - bottomRight.y();
616
- bottomRight.move({
617
- x: -topOffsetX,
618
- y: -topOffsetY,
619
- });
620
- topLeft.move({
621
- x: bottomOffsetX,
622
- y: bottomOffsetY,
623
- });
624
- }
625
- var absPos = this.findOne('.top-left').getAbsolutePosition();
626
- x = absPos.x;
627
- y = absPos.y;
628
- var width = this.findOne('.bottom-right').x() - this.findOne('.top-left').x();
629
- var height = this.findOne('.bottom-right').y() - this.findOne('.top-left').y();
630
- this._fitNodesInto({
631
- x: x,
632
- y: y,
633
- width: width,
634
- height: height,
635
- rotation: Global_1.Konva.getAngle(this.rotation()),
636
- }, e);
637
- }
638
- _handleMouseUp(e) {
639
- this._removeEvents(e);
640
- }
641
- getAbsoluteTransform() {
642
- return this.getTransform();
643
- }
644
- _removeEvents(e) {
645
- if (this._transforming) {
646
- this._transforming = false;
647
- if (typeof window !== 'undefined') {
648
- window.removeEventListener('mousemove', this._handleMouseMove);
649
- window.removeEventListener('touchmove', this._handleMouseMove);
650
- window.removeEventListener('mouseup', this._handleMouseUp, true);
651
- window.removeEventListener('touchend', this._handleMouseUp, true);
652
- }
653
- var node = this.getNode();
654
- this._fire('transformend', { evt: e, target: node });
655
- if (node) {
656
- this._nodes.forEach((target) => {
657
- target._fire('transformend', { evt: e, target });
658
- });
659
- }
660
- this._movingAnchorName = null;
661
- }
662
- }
663
- _fitNodesInto(newAttrs, evt) {
664
- var oldAttrs = this._getNodeRect();
665
- const minSize = 1;
666
- if (Util_1.Util._inRange(newAttrs.width, -this.padding() * 2 - minSize, minSize)) {
667
- this.update();
668
- return;
669
- }
670
- if (Util_1.Util._inRange(newAttrs.height, -this.padding() * 2 - minSize, minSize)) {
671
- this.update();
672
- return;
673
- }
674
- const allowNegativeScale = this.flipEnabled();
675
- var t = new Util_1.Transform();
676
- t.rotate(Global_1.Konva.getAngle(this.rotation()));
677
- if (this._movingAnchorName &&
678
- newAttrs.width < 0 &&
679
- this._movingAnchorName.indexOf('left') >= 0) {
680
- const offset = t.point({
681
- x: -this.padding() * 2,
682
- y: 0,
683
- });
684
- newAttrs.x += offset.x;
685
- newAttrs.y += offset.y;
686
- newAttrs.width += this.padding() * 2;
687
- this._movingAnchorName = this._movingAnchorName.replace('left', 'right');
688
- this._anchorDragOffset.x -= offset.x;
689
- this._anchorDragOffset.y -= offset.y;
690
- if (!allowNegativeScale) {
691
- this.update();
692
- return;
693
- }
694
- }
695
- else if (this._movingAnchorName &&
696
- newAttrs.width < 0 &&
697
- this._movingAnchorName.indexOf('right') >= 0) {
698
- const offset = t.point({
699
- x: this.padding() * 2,
700
- y: 0,
701
- });
702
- this._movingAnchorName = this._movingAnchorName.replace('right', 'left');
703
- this._anchorDragOffset.x -= offset.x;
704
- this._anchorDragOffset.y -= offset.y;
705
- newAttrs.width += this.padding() * 2;
706
- if (!allowNegativeScale) {
707
- this.update();
708
- return;
709
- }
710
- }
711
- if (this._movingAnchorName &&
712
- newAttrs.height < 0 &&
713
- this._movingAnchorName.indexOf('top') >= 0) {
714
- const offset = t.point({
715
- x: 0,
716
- y: -this.padding() * 2,
717
- });
718
- newAttrs.x += offset.x;
719
- newAttrs.y += offset.y;
720
- this._movingAnchorName = this._movingAnchorName.replace('top', 'bottom');
721
- this._anchorDragOffset.x -= offset.x;
722
- this._anchorDragOffset.y -= offset.y;
723
- newAttrs.height += this.padding() * 2;
724
- if (!allowNegativeScale) {
725
- this.update();
726
- return;
727
- }
728
- }
729
- else if (this._movingAnchorName &&
730
- newAttrs.height < 0 &&
731
- this._movingAnchorName.indexOf('bottom') >= 0) {
732
- const offset = t.point({
733
- x: 0,
734
- y: this.padding() * 2,
735
- });
736
- this._movingAnchorName = this._movingAnchorName.replace('bottom', 'top');
737
- this._anchorDragOffset.x -= offset.x;
738
- this._anchorDragOffset.y -= offset.y;
739
- newAttrs.height += this.padding() * 2;
740
- if (!allowNegativeScale) {
741
- this.update();
742
- return;
743
- }
744
- }
745
- if (this.boundBoxFunc()) {
746
- const bounded = this.boundBoxFunc()(oldAttrs, newAttrs);
747
- if (bounded) {
748
- newAttrs = bounded;
749
- }
750
- else {
751
- Util_1.Util.warn('boundBoxFunc returned falsy. You should return new bound rect from it!');
752
- }
753
- }
754
- const baseSize = 10000000;
755
- const oldTr = new Util_1.Transform();
756
- oldTr.translate(oldAttrs.x, oldAttrs.y);
757
- oldTr.rotate(oldAttrs.rotation);
758
- oldTr.scale(oldAttrs.width / baseSize, oldAttrs.height / baseSize);
759
- const newTr = new Util_1.Transform();
760
- newTr.translate(newAttrs.x, newAttrs.y);
761
- newTr.rotate(newAttrs.rotation);
762
- newTr.scale(newAttrs.width / baseSize, newAttrs.height / baseSize);
763
- const delta = newTr.multiply(oldTr.invert());
764
- this._nodes.forEach((node) => {
765
- var _a;
766
- const parentTransform = node.getParent().getAbsoluteTransform();
767
- const localTransform = node.getTransform().copy();
768
- localTransform.translate(node.offsetX(), node.offsetY());
769
- const newLocalTransform = new Util_1.Transform();
770
- newLocalTransform
771
- .multiply(parentTransform.copy().invert())
772
- .multiply(delta)
773
- .multiply(parentTransform)
774
- .multiply(localTransform);
775
- const attrs = newLocalTransform.decompose();
776
- node.setAttrs(attrs);
777
- this._fire('transform', { evt: evt, target: node });
778
- node._fire('transform', { evt: evt, target: node });
779
- (_a = node.getLayer()) === null || _a === void 0 ? void 0 : _a.batchDraw();
780
- });
781
- this.rotation(Util_1.Util._getRotation(newAttrs.rotation));
782
- this._resetTransformCache();
783
- this.update();
784
- this.getLayer().batchDraw();
785
- }
786
- forceUpdate() {
787
- this._resetTransformCache();
788
- this.update();
789
- }
790
- _batchChangeChild(selector, attrs) {
791
- const anchor = this.findOne(selector);
792
- anchor.setAttrs(attrs);
793
- }
794
- update() {
795
- var _a;
796
- var attrs = this._getNodeRect();
797
- this.rotation(Util_1.Util._getRotation(attrs.rotation));
798
- var width = attrs.width;
799
- var height = attrs.height;
800
- var enabledAnchors = this.enabledAnchors();
801
- var resizeEnabled = this.resizeEnabled();
802
- var padding = this.padding();
803
- var anchorSize = this.anchorSize();
804
- this.find('._anchor').forEach((node) => {
805
- node.setAttrs({
806
- width: anchorSize,
807
- height: anchorSize,
808
- offsetX: anchorSize / 2,
809
- offsetY: anchorSize / 2,
810
- stroke: this.anchorStroke(),
811
- strokeWidth: this.anchorStrokeWidth(),
812
- fill: this.anchorFill(),
813
- cornerRadius: this.anchorCornerRadius(),
814
- });
815
- });
816
- this._batchChangeChild('.top-left', {
817
- x: 0,
818
- y: 0,
819
- offsetX: anchorSize / 2 + padding,
820
- offsetY: anchorSize / 2 + padding,
821
- visible: resizeEnabled && enabledAnchors.indexOf('top-left') >= 0,
822
- });
823
- this._batchChangeChild('.top-center', {
824
- x: width / 2,
825
- y: 0,
826
- offsetY: anchorSize / 2 + padding,
827
- visible: resizeEnabled && enabledAnchors.indexOf('top-center') >= 0,
828
- });
829
- this._batchChangeChild('.top-right', {
830
- x: width,
831
- y: 0,
832
- offsetX: anchorSize / 2 - padding,
833
- offsetY: anchorSize / 2 + padding,
834
- visible: resizeEnabled && enabledAnchors.indexOf('top-right') >= 0,
835
- });
836
- this._batchChangeChild('.middle-left', {
837
- x: 0,
838
- y: height / 2,
839
- offsetX: anchorSize / 2 + padding,
840
- visible: resizeEnabled && enabledAnchors.indexOf('middle-left') >= 0,
841
- });
842
- this._batchChangeChild('.middle-right', {
843
- x: width,
844
- y: height / 2,
845
- offsetX: anchorSize / 2 - padding,
846
- visible: resizeEnabled && enabledAnchors.indexOf('middle-right') >= 0,
847
- });
848
- this._batchChangeChild('.bottom-left', {
849
- x: 0,
850
- y: height,
851
- offsetX: anchorSize / 2 + padding,
852
- offsetY: anchorSize / 2 - padding,
853
- visible: resizeEnabled && enabledAnchors.indexOf('bottom-left') >= 0,
854
- });
855
- this._batchChangeChild('.bottom-center', {
856
- x: width / 2,
857
- y: height,
858
- offsetY: anchorSize / 2 - padding,
859
- visible: resizeEnabled && enabledAnchors.indexOf('bottom-center') >= 0,
860
- });
861
- this._batchChangeChild('.bottom-right', {
862
- x: width,
863
- y: height,
864
- offsetX: anchorSize / 2 - padding,
865
- offsetY: anchorSize / 2 - padding,
866
- visible: resizeEnabled && enabledAnchors.indexOf('bottom-right') >= 0,
867
- });
868
- this._batchChangeChild('.rotater', {
869
- x: width / 2,
870
- y: -this.rotateAnchorOffset() * Util_1.Util._sign(height) - padding,
871
- visible: this.rotateEnabled(),
872
- });
873
- this._batchChangeChild('.back', {
874
- width: width,
875
- height: height,
876
- visible: this.borderEnabled(),
877
- stroke: this.borderStroke(),
878
- strokeWidth: this.borderStrokeWidth(),
879
- dash: this.borderDash(),
880
- x: 0,
881
- y: 0,
882
- });
883
- (_a = this.getLayer()) === null || _a === void 0 ? void 0 : _a.batchDraw();
884
- }
885
- isTransforming() {
886
- return this._transforming;
887
- }
888
- stopTransform() {
889
- if (this._transforming) {
890
- this._removeEvents();
891
- var anchorNode = this.findOne('.' + this._movingAnchorName);
892
- if (anchorNode) {
893
- anchorNode.stopDrag();
894
- }
895
- }
896
- }
897
- destroy() {
898
- if (this.getStage() && this._cursorChange) {
899
- this.getStage().content && (this.getStage().content.style.cursor = '');
900
- }
901
- Group_1.Group.prototype.destroy.call(this);
902
- this.detach();
903
- this._removeEvents();
904
- return this;
905
- }
906
- toObject() {
907
- return Node_1.Node.prototype.toObject.call(this);
908
- }
909
- clone(obj) {
910
- var node = Node_1.Node.prototype.clone.call(this, obj);
911
- return node;
912
- }
913
- getClientRect() {
914
- if (this.nodes().length > 0) {
915
- return super.getClientRect();
916
- }
917
- else {
918
- return { x: 0, y: 0, width: 0, height: 0 };
919
- }
920
- }
921
- }
922
- exports.Transformer = Transformer;
923
- function validateAnchors(val) {
924
- if (!(val instanceof Array)) {
925
- Util_1.Util.warn('enabledAnchors value should be an array');
926
- }
927
- if (val instanceof Array) {
928
- val.forEach(function (name) {
929
- if (ANCHORS_NAMES.indexOf(name) === -1) {
930
- Util_1.Util.warn('Unknown anchor name: ' +
931
- name +
932
- '. Available names are: ' +
933
- ANCHORS_NAMES.join(', '));
934
- }
935
- });
936
- }
937
- return val || [];
938
- }
939
- Transformer.prototype.className = 'Transformer';
940
- (0, Global_2._registerNode)(Transformer);
941
- Factory_1.Factory.addGetterSetter(Transformer, 'enabledAnchors', ANCHORS_NAMES, validateAnchors);
942
- Factory_1.Factory.addGetterSetter(Transformer, 'flipEnabled', true, (0, Validators_1.getBooleanValidator)());
943
- Factory_1.Factory.addGetterSetter(Transformer, 'resizeEnabled', true);
944
- Factory_1.Factory.addGetterSetter(Transformer, 'anchorSize', 10, (0, Validators_1.getNumberValidator)());
945
- Factory_1.Factory.addGetterSetter(Transformer, 'rotateEnabled', true);
946
- Factory_1.Factory.addGetterSetter(Transformer, 'rotationSnaps', []);
947
- Factory_1.Factory.addGetterSetter(Transformer, 'rotateAnchorOffset', 50, (0, Validators_1.getNumberValidator)());
948
- Factory_1.Factory.addGetterSetter(Transformer, 'rotationSnapTolerance', 5, (0, Validators_1.getNumberValidator)());
949
- Factory_1.Factory.addGetterSetter(Transformer, 'borderEnabled', true);
950
- Factory_1.Factory.addGetterSetter(Transformer, 'anchorStroke', 'rgb(0, 161, 255)');
951
- Factory_1.Factory.addGetterSetter(Transformer, 'anchorStrokeWidth', 1, (0, Validators_1.getNumberValidator)());
952
- Factory_1.Factory.addGetterSetter(Transformer, 'anchorFill', 'white');
953
- Factory_1.Factory.addGetterSetter(Transformer, 'anchorCornerRadius', 0, (0, Validators_1.getNumberValidator)());
954
- Factory_1.Factory.addGetterSetter(Transformer, 'borderStroke', 'rgb(0, 161, 255)');
955
- Factory_1.Factory.addGetterSetter(Transformer, 'borderStrokeWidth', 1, (0, Validators_1.getNumberValidator)());
956
- Factory_1.Factory.addGetterSetter(Transformer, 'borderDash');
957
- Factory_1.Factory.addGetterSetter(Transformer, 'keepRatio', true);
958
- Factory_1.Factory.addGetterSetter(Transformer, 'centeredScaling', false);
959
- Factory_1.Factory.addGetterSetter(Transformer, 'ignoreStroke', false);
960
- Factory_1.Factory.addGetterSetter(Transformer, 'padding', 0, (0, Validators_1.getNumberValidator)());
961
- Factory_1.Factory.addGetterSetter(Transformer, 'node');
962
- Factory_1.Factory.addGetterSetter(Transformer, 'nodes');
963
- Factory_1.Factory.addGetterSetter(Transformer, 'boundBoxFunc');
964
- Factory_1.Factory.addGetterSetter(Transformer, 'anchorDragBoundFunc');
965
- Factory_1.Factory.addGetterSetter(Transformer, 'shouldOverdrawWholeArea', false);
966
- Factory_1.Factory.addGetterSetter(Transformer, 'useSingleNodeRotation', true);
967
- Factory_1.Factory.backCompat(Transformer, {
968
- lineEnabled: 'borderEnabled',
969
- rotateHandlerOffset: 'rotateAnchorOffset',
970
- enabledHandlers: 'enabledAnchors',
971
- });