@nasser-sw/fabric 7.0.1-beta3 → 7.0.1-beta4

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 (105) hide show
  1. package/0 +0 -0
  2. package/dist/index.js +323 -155
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.min.js +1 -1
  5. package/dist/index.min.js.map +1 -1
  6. package/dist/index.min.mjs +1 -1
  7. package/dist/index.min.mjs.map +1 -1
  8. package/dist/index.mjs +323 -155
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/index.node.cjs +323 -155
  11. package/dist/index.node.cjs.map +1 -1
  12. package/dist/index.node.mjs +323 -155
  13. package/dist/index.node.mjs.map +1 -1
  14. package/dist/package.json.min.mjs +1 -1
  15. package/dist/package.json.mjs +1 -1
  16. package/dist/src/shapes/Line.d.ts +31 -86
  17. package/dist/src/shapes/Line.d.ts.map +1 -1
  18. package/dist/src/shapes/Line.min.mjs +1 -1
  19. package/dist/src/shapes/Line.min.mjs.map +1 -1
  20. package/dist/src/shapes/Line.mjs +323 -154
  21. package/dist/src/shapes/Line.mjs.map +1 -1
  22. package/dist-extensions/src/shapes/CustomLine.d.ts +10 -0
  23. package/dist-extensions/src/shapes/CustomLine.d.ts.map +1 -0
  24. package/dist-extensions/src/shapes/Line.d.ts +31 -86
  25. package/dist-extensions/src/shapes/Line.d.ts.map +1 -1
  26. package/fabric-test-editor.html +157 -8
  27. package/fabric-test2.html +513 -0
  28. package/fabric.ts +182 -182
  29. package/package.json +1 -1
  30. package/src/shapes/Line.ts +372 -158
  31. package/debug/konva/CHANGELOG.md +0 -1474
  32. package/debug/konva/LICENSE +0 -22
  33. package/debug/konva/README.md +0 -205
  34. package/debug/konva/gulpfile.mjs +0 -110
  35. package/debug/konva/package.json +0 -139
  36. package/debug/konva/release.sh +0 -65
  37. package/debug/konva/resources/doc-includes/ContainerParams.txt +0 -6
  38. package/debug/konva/resources/doc-includes/NodeParams.txt +0 -20
  39. package/debug/konva/resources/doc-includes/ShapeParams.txt +0 -53
  40. package/debug/konva/resources/jsdoc.conf.json +0 -28
  41. package/debug/konva/rollup.config.mjs +0 -32
  42. package/debug/konva/src/Animation.ts +0 -237
  43. package/debug/konva/src/BezierFunctions.ts +0 -826
  44. package/debug/konva/src/Canvas.ts +0 -193
  45. package/debug/konva/src/Container.ts +0 -649
  46. package/debug/konva/src/Context.ts +0 -1017
  47. package/debug/konva/src/Core.ts +0 -5
  48. package/debug/konva/src/DragAndDrop.ts +0 -173
  49. package/debug/konva/src/Factory.ts +0 -246
  50. package/debug/konva/src/FastLayer.ts +0 -29
  51. package/debug/konva/src/Global.ts +0 -210
  52. package/debug/konva/src/Group.ts +0 -31
  53. package/debug/konva/src/Layer.ts +0 -546
  54. package/debug/konva/src/Node.ts +0 -3477
  55. package/debug/konva/src/PointerEvents.ts +0 -67
  56. package/debug/konva/src/Shape.ts +0 -2081
  57. package/debug/konva/src/Stage.ts +0 -1000
  58. package/debug/konva/src/Tween.ts +0 -811
  59. package/debug/konva/src/Util.ts +0 -1123
  60. package/debug/konva/src/Validators.ts +0 -210
  61. package/debug/konva/src/_CoreInternals.ts +0 -85
  62. package/debug/konva/src/_FullInternals.ts +0 -171
  63. package/debug/konva/src/canvas-backend.ts +0 -36
  64. package/debug/konva/src/filters/Blur.ts +0 -388
  65. package/debug/konva/src/filters/Brighten.ts +0 -48
  66. package/debug/konva/src/filters/Brightness.ts +0 -30
  67. package/debug/konva/src/filters/Contrast.ts +0 -75
  68. package/debug/konva/src/filters/Emboss.ts +0 -207
  69. package/debug/konva/src/filters/Enhance.ts +0 -154
  70. package/debug/konva/src/filters/Grayscale.ts +0 -25
  71. package/debug/konva/src/filters/HSL.ts +0 -108
  72. package/debug/konva/src/filters/HSV.ts +0 -106
  73. package/debug/konva/src/filters/Invert.ts +0 -23
  74. package/debug/konva/src/filters/Kaleidoscope.ts +0 -274
  75. package/debug/konva/src/filters/Mask.ts +0 -220
  76. package/debug/konva/src/filters/Noise.ts +0 -44
  77. package/debug/konva/src/filters/Pixelate.ts +0 -107
  78. package/debug/konva/src/filters/Posterize.ts +0 -46
  79. package/debug/konva/src/filters/RGB.ts +0 -82
  80. package/debug/konva/src/filters/RGBA.ts +0 -103
  81. package/debug/konva/src/filters/Sepia.ts +0 -27
  82. package/debug/konva/src/filters/Solarize.ts +0 -29
  83. package/debug/konva/src/filters/Threshold.ts +0 -44
  84. package/debug/konva/src/index.ts +0 -3
  85. package/debug/konva/src/shapes/Arc.ts +0 -176
  86. package/debug/konva/src/shapes/Arrow.ts +0 -231
  87. package/debug/konva/src/shapes/Circle.ts +0 -76
  88. package/debug/konva/src/shapes/Ellipse.ts +0 -121
  89. package/debug/konva/src/shapes/Image.ts +0 -319
  90. package/debug/konva/src/shapes/Label.ts +0 -386
  91. package/debug/konva/src/shapes/Line.ts +0 -364
  92. package/debug/konva/src/shapes/Path.ts +0 -1013
  93. package/debug/konva/src/shapes/Rect.ts +0 -79
  94. package/debug/konva/src/shapes/RegularPolygon.ts +0 -167
  95. package/debug/konva/src/shapes/Ring.ts +0 -94
  96. package/debug/konva/src/shapes/Sprite.ts +0 -370
  97. package/debug/konva/src/shapes/Star.ts +0 -125
  98. package/debug/konva/src/shapes/Text.ts +0 -1065
  99. package/debug/konva/src/shapes/TextPath.ts +0 -583
  100. package/debug/konva/src/shapes/Transformer.ts +0 -1889
  101. package/debug/konva/src/shapes/Wedge.ts +0 -129
  102. package/debug/konva/src/skia-backend.ts +0 -35
  103. package/debug/konva/src/types.ts +0 -84
  104. package/debug/konva/tsconfig.json +0 -31
  105. package/debug/konva/tsconfig.test.json +0 -7
@@ -1,386 +0,0 @@
1
- import { Factory } from '../Factory.ts';
2
- import type { ShapeConfig } from '../Shape.ts';
3
- import { Shape } from '../Shape.ts';
4
- import { Group } from '../Group.ts';
5
- import type { Context } from '../Context.ts';
6
- import type { ContainerConfig } from '../Container.ts';
7
- import {
8
- getNumberOrArrayOfNumbersValidator,
9
- getNumberValidator,
10
- } from '../Validators.ts';
11
- import { _registerNode } from '../Global.ts';
12
-
13
- import type { GetSet } from '../types.ts';
14
- import type { Text } from './Text.ts';
15
-
16
- export interface LabelConfig extends ContainerConfig {}
17
-
18
- // constants
19
- const ATTR_CHANGE_LIST = [
20
- 'fontFamily',
21
- 'fontSize',
22
- 'fontStyle',
23
- 'padding',
24
- 'lineHeight',
25
- 'text',
26
- 'width',
27
- 'height',
28
- 'pointerDirection',
29
- 'pointerWidth',
30
- 'pointerHeight',
31
- ],
32
- CHANGE_KONVA = 'Change.konva',
33
- NONE = 'none',
34
- UP = 'up',
35
- RIGHT = 'right',
36
- DOWN = 'down',
37
- LEFT = 'left',
38
- // cached variables
39
- attrChangeListLen = ATTR_CHANGE_LIST.length;
40
-
41
- /**
42
- * Label constructor.  Labels are groups that contain a Text and Tag shape
43
- * @constructor
44
- * @memberof Konva
45
- * @param {Object} config
46
- * @@nodeParams
47
- * @example
48
- * // create label
49
- * var label = new Konva.Label({
50
- * x: 100,
51
- * y: 100,
52
- * draggable: true
53
- * });
54
- *
55
- * // add a tag to the label
56
- * label.add(new Konva.Tag({
57
- * fill: '#bbb',
58
- * stroke: '#333',
59
- * shadowColor: 'black',
60
- * shadowBlur: 10,
61
- * shadowOffset: [10, 10],
62
- * shadowOpacity: 0.2,
63
- * lineJoin: 'round',
64
- * pointerDirection: 'up',
65
- * pointerWidth: 20,
66
- * pointerHeight: 20,
67
- * cornerRadius: 5
68
- * }));
69
- *
70
- * // add text to the label
71
- * label.add(new Konva.Text({
72
- * text: 'Hello World!',
73
- * fontSize: 50,
74
- * lineHeight: 1.2,
75
- * padding: 10,
76
- * fill: 'green'
77
- * }));
78
- */
79
- export class Label extends Group {
80
- constructor(config?: LabelConfig) {
81
- super(config);
82
- this.on('add.konva', function (evt) {
83
- this._addListeners(evt.child);
84
- this._sync();
85
- });
86
- }
87
-
88
- /**
89
- * get Text shape for the label. You need to access the Text shape in order to update
90
- * the text properties
91
- * @name Konva.Label#getText
92
- * @method
93
- * @example
94
- * label.getText().fill('red')
95
- */
96
- getText() {
97
- return this.find<Text>('Text')[0];
98
- }
99
- /**
100
- * get Tag shape for the label. You need to access the Tag shape in order to update
101
- * the pointer properties and the corner radius
102
- * @name Konva.Label#getTag
103
- * @method
104
- */
105
- getTag() {
106
- return this.find('Tag')[0] as Tag;
107
- }
108
- _addListeners(text) {
109
- let that = this,
110
- n;
111
- const func = function () {
112
- that._sync();
113
- };
114
-
115
- // update text data for certain attr changes
116
- for (n = 0; n < attrChangeListLen; n++) {
117
- text.on(ATTR_CHANGE_LIST[n] + CHANGE_KONVA, func);
118
- }
119
- }
120
- getWidth() {
121
- return this.getText().width();
122
- }
123
- getHeight() {
124
- return this.getText().height();
125
- }
126
- _sync() {
127
- let text = this.getText(),
128
- tag = this.getTag(),
129
- width,
130
- height,
131
- pointerDirection,
132
- pointerWidth,
133
- x,
134
- y,
135
- pointerHeight;
136
-
137
- if (text && tag) {
138
- width = text.width();
139
- height = text.height();
140
- pointerDirection = tag.pointerDirection();
141
- pointerWidth = tag.pointerWidth();
142
- pointerHeight = tag.pointerHeight();
143
- x = 0;
144
- y = 0;
145
-
146
- switch (pointerDirection) {
147
- case UP:
148
- x = width / 2;
149
- y = -1 * pointerHeight;
150
- break;
151
- case RIGHT:
152
- x = width + pointerWidth;
153
- y = height / 2;
154
- break;
155
- case DOWN:
156
- x = width / 2;
157
- y = height + pointerHeight;
158
- break;
159
- case LEFT:
160
- x = -1 * pointerWidth;
161
- y = height / 2;
162
- break;
163
- }
164
-
165
- tag.setAttrs({
166
- x: -1 * x,
167
- y: -1 * y,
168
- width: width,
169
- height: height,
170
- });
171
-
172
- text.setAttrs({
173
- x: -1 * x,
174
- y: -1 * y,
175
- });
176
- }
177
- }
178
- }
179
-
180
- Label.prototype.className = 'Label';
181
- _registerNode(Label);
182
-
183
- export interface TagConfig extends ShapeConfig {
184
- pointerDirection?: string;
185
- pointerWidth?: number;
186
- pointerHeight?: number;
187
- cornerRadius?: number | Array<number>;
188
- }
189
-
190
- /**
191
- * Tag constructor.&nbsp; A Tag can be configured
192
- * to have a pointer element that points up, right, down, or left
193
- * @constructor
194
- * @memberof Konva
195
- * @param {Object} config
196
- * @param {String} [config.pointerDirection] can be up, right, down, left, or none; the default
197
- * is none. When a pointer is present, the positioning of the label is relative to the tip of the pointer.
198
- * @param {Number} [config.pointerWidth]
199
- * @param {Number} [config.pointerHeight]
200
- * @param {Number} [config.cornerRadius]
201
- */
202
- export class Tag extends Shape<TagConfig> {
203
- _sceneFunc(context: Context) {
204
- const width = this.width(),
205
- height = this.height(),
206
- pointerDirection = this.pointerDirection(),
207
- pointerWidth = this.pointerWidth(),
208
- pointerHeight = this.pointerHeight(),
209
- cornerRadius = this.cornerRadius();
210
-
211
- let topLeft = 0;
212
- let topRight = 0;
213
- let bottomLeft = 0;
214
- let bottomRight = 0;
215
-
216
- if (typeof cornerRadius === 'number') {
217
- topLeft =
218
- topRight =
219
- bottomLeft =
220
- bottomRight =
221
- Math.min(cornerRadius, width / 2, height / 2);
222
- } else {
223
- topLeft = Math.min(cornerRadius[0] || 0, width / 2, height / 2);
224
- topRight = Math.min(cornerRadius[1] || 0, width / 2, height / 2);
225
- bottomRight = Math.min(cornerRadius[2] || 0, width / 2, height / 2);
226
- bottomLeft = Math.min(cornerRadius[3] || 0, width / 2, height / 2);
227
- }
228
-
229
- context.beginPath();
230
- context.moveTo(topLeft, 0);
231
-
232
- if (pointerDirection === UP) {
233
- context.lineTo((width - pointerWidth) / 2, 0);
234
- context.lineTo(width / 2, -1 * pointerHeight);
235
- context.lineTo((width + pointerWidth) / 2, 0);
236
- }
237
-
238
- context.lineTo(width - topRight, 0);
239
- context.arc(
240
- width - topRight,
241
- topRight,
242
- topRight,
243
- (Math.PI * 3) / 2,
244
- 0,
245
- false
246
- );
247
-
248
- if (pointerDirection === RIGHT) {
249
- context.lineTo(width, (height - pointerHeight) / 2);
250
- context.lineTo(width + pointerWidth, height / 2);
251
- context.lineTo(width, (height + pointerHeight) / 2);
252
- }
253
-
254
- context.lineTo(width, height - bottomRight);
255
- context.arc(
256
- width - bottomRight,
257
- height - bottomRight,
258
- bottomRight,
259
- 0,
260
- Math.PI / 2,
261
- false
262
- );
263
-
264
- if (pointerDirection === DOWN) {
265
- context.lineTo((width + pointerWidth) / 2, height);
266
- context.lineTo(width / 2, height + pointerHeight);
267
- context.lineTo((width - pointerWidth) / 2, height);
268
- }
269
-
270
- context.lineTo(bottomLeft, height);
271
- context.arc(
272
- bottomLeft,
273
- height - bottomLeft,
274
- bottomLeft,
275
- Math.PI / 2,
276
- Math.PI,
277
- false
278
- );
279
-
280
- if (pointerDirection === LEFT) {
281
- context.lineTo(0, (height + pointerHeight) / 2);
282
- context.lineTo(-1 * pointerWidth, height / 2);
283
- context.lineTo(0, (height - pointerHeight) / 2);
284
- }
285
-
286
- context.lineTo(0, topLeft);
287
- context.arc(topLeft, topLeft, topLeft, Math.PI, (Math.PI * 3) / 2, false);
288
-
289
- context.closePath();
290
- context.fillStrokeShape(this);
291
- }
292
- getSelfRect() {
293
- let x = 0,
294
- y = 0,
295
- pointerWidth = this.pointerWidth(),
296
- pointerHeight = this.pointerHeight(),
297
- direction = this.pointerDirection(),
298
- width = this.width(),
299
- height = this.height();
300
-
301
- if (direction === UP) {
302
- y -= pointerHeight;
303
- height += pointerHeight;
304
- } else if (direction === DOWN) {
305
- height += pointerHeight;
306
- } else if (direction === LEFT) {
307
- // ARGH!!! I have no idea why should I used magic 1.5!!!!!!!!!
308
- x -= pointerWidth * 1.5;
309
- width += pointerWidth;
310
- } else if (direction === RIGHT) {
311
- width += pointerWidth * 1.5;
312
- }
313
- return {
314
- x: x,
315
- y: y,
316
- width: width,
317
- height: height,
318
- };
319
- }
320
-
321
- pointerDirection: GetSet<
322
- 'left' | 'up' | 'right' | 'down' | typeof NONE,
323
- this
324
- >;
325
- pointerWidth: GetSet<number, this>;
326
- pointerHeight: GetSet<number, this>;
327
- cornerRadius: GetSet<number, this>;
328
- }
329
-
330
- Tag.prototype.className = 'Tag';
331
- _registerNode(Tag);
332
-
333
- /**
334
- * get/set pointer direction
335
- * @name Konva.Tag#pointerDirection
336
- * @method
337
- * @param {String} pointerDirection can be up, right, down, left, or none. The default is none.
338
- * @returns {String}
339
- * @example
340
- * tag.pointerDirection('right');
341
- */
342
- Factory.addGetterSetter(Tag, 'pointerDirection', NONE);
343
-
344
- /**
345
- * get/set pointer width
346
- * @name Konva.Tag#pointerWidth
347
- * @method
348
- * @param {Number} pointerWidth
349
- * @returns {Number}
350
- * @example
351
- * tag.pointerWidth(20);
352
- */
353
- Factory.addGetterSetter(Tag, 'pointerWidth', 0, getNumberValidator());
354
-
355
- /**
356
- * get/set pointer height
357
- * @method
358
- * @name Konva.Tag#pointerHeight
359
- * @param {Number} pointerHeight
360
- * @returns {Number}
361
- * @example
362
- * tag.pointerHeight(20);
363
- */
364
-
365
- Factory.addGetterSetter(Tag, 'pointerHeight', 0, getNumberValidator());
366
-
367
- /**
368
- * get/set cornerRadius
369
- * @name Konva.Tag#cornerRadius
370
- * @method
371
- * @param {Number} cornerRadius
372
- * @returns {Number}
373
- * @example
374
- * tag.cornerRadius(20);
375
- *
376
- * // set different corner radius values
377
- * // top-left, top-right, bottom-right, bottom-left
378
- * tag.cornerRadius([0, 10, 20, 30]);
379
- */
380
-
381
- Factory.addGetterSetter(
382
- Tag,
383
- 'cornerRadius',
384
- 0,
385
- getNumberOrArrayOfNumbersValidator(4)
386
- );