@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,583 +0,0 @@
1
- import { Util } from '../Util.ts';
2
- import { Factory } from '../Factory.ts';
3
- import type { Context } from '../Context.ts';
4
- import type { ShapeConfig } from '../Shape.ts';
5
- import { Shape } from '../Shape.ts';
6
- import { Path } from './Path.ts';
7
- import { Text, stringToArray } from './Text.ts';
8
- import { getNumberValidator } from '../Validators.ts';
9
- import { _registerNode } from '../Global.ts';
10
-
11
- import type { GetSet, PathSegment, Vector2d } from '../types.ts';
12
-
13
- export interface TextPathConfig extends ShapeConfig {
14
- text?: string;
15
- data?: string;
16
- fontFamily?: string;
17
- fontSize?: number;
18
- fontStyle?: string;
19
- letterSpacing?: number;
20
- }
21
-
22
- const EMPTY_STRING = '',
23
- NORMAL = 'normal';
24
-
25
- function _fillFunc(this: TextPath, context) {
26
- context.fillText(this.partialText, 0, 0);
27
- }
28
- function _strokeFunc(this: TextPath, context) {
29
- context.strokeText(this.partialText, 0, 0);
30
- }
31
-
32
- /**
33
- * Path constructor.
34
- * @author Jason Follas
35
- * @constructor
36
- * @memberof Konva
37
- * @augments Konva.Shape
38
- * @param {Object} config
39
- * @param {String} [config.fontFamily] default is Arial
40
- * @param {Number} [config.fontSize] default is 12
41
- * @param {String} [config.fontStyle] Can be 'normal', 'italic', or 'bold', '500' or even 'italic bold'. 'normal' is the default.
42
- * @param {String} [config.fontVariant] can be normal or small-caps. Default is normal
43
- * @param {String} [config.textBaseline] Can be 'top', 'bottom', 'middle', 'alphabetic', 'hanging'. Default is middle
44
- * @param {String} config.text
45
- * @param {String} config.data SVG data string
46
- * @param {Function} config.kerningFunc a getter for kerning values for the specified characters
47
- * @@shapeParams
48
- * @@nodeParams
49
- * @example
50
- * var kerningPairs = {
51
- * 'A': {
52
- * ' ': -0.05517578125,
53
- * 'T': -0.07421875,
54
- * 'V': -0.07421875
55
- * }
56
- * 'V': {
57
- * ',': -0.091796875,
58
- * ":": -0.037109375,
59
- * ";": -0.037109375,
60
- * "A": -0.07421875
61
- * }
62
- * }
63
- * var textpath = new Konva.TextPath({
64
- * x: 100,
65
- * y: 50,
66
- * fill: '#333',
67
- * fontSize: '24',
68
- * fontFamily: 'Arial',
69
- * text: 'All the world\'s a stage, and all the men and women merely players.',
70
- * data: 'M10,10 C0,0 10,150 100,100 S300,150 400,50',
71
- * kerningFunc(leftChar, rightChar) {
72
- * return kerningPairs.hasOwnProperty(leftChar) ? pairs[leftChar][rightChar] || 0 : 0
73
- * }
74
- * });
75
- */
76
- export class TextPath extends Shape<TextPathConfig> {
77
- dummyCanvas = Util.createCanvasElement();
78
- dataArray: PathSegment[] = [];
79
- glyphInfo: Array<{
80
- transposeX: number;
81
- transposeY: number;
82
- text: string;
83
- rotation: number;
84
- p0: Vector2d;
85
- p1: Vector2d;
86
- }>;
87
- partialText: string;
88
- pathLength: number;
89
- textWidth: number;
90
- textHeight: number;
91
-
92
- constructor(config?: TextPathConfig) {
93
- // call super constructor
94
- super(config);
95
-
96
- this._readDataAttribute();
97
-
98
- this.on('dataChange.konva', function () {
99
- this._readDataAttribute();
100
- this._setTextData();
101
- });
102
-
103
- // update text data for certain attr changes
104
- this.on(
105
- 'textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva',
106
- this._setTextData
107
- );
108
-
109
- this._setTextData();
110
- }
111
-
112
- _getTextPathLength() {
113
- return Path.getPathLength(this.dataArray);
114
- }
115
- _getPointAtLength(length: number) {
116
- // if path is not defined yet, do nothing
117
- if (!this.attrs.data) {
118
- return null;
119
- }
120
-
121
- const totalLength = this.pathLength;
122
- // -1px for rounding of the last symbol
123
- if (length - 1 > totalLength) {
124
- return null;
125
- }
126
-
127
- return Path.getPointAtLengthOfDataArray(length, this.dataArray);
128
- }
129
-
130
- _readDataAttribute() {
131
- this.dataArray = Path.parsePathData(this.attrs.data);
132
- this.pathLength = this._getTextPathLength();
133
- }
134
-
135
- _sceneFunc(context: Context) {
136
- context.setAttr('font', this._getContextFont());
137
- context.setAttr('textBaseline', this.textBaseline());
138
- context.setAttr('textAlign', 'left');
139
- context.save();
140
-
141
- const textDecoration = this.textDecoration();
142
- const fill = this.fill();
143
- const fontSize = this.fontSize();
144
-
145
- const glyphInfo = this.glyphInfo;
146
- if (textDecoration === 'underline') {
147
- context.beginPath();
148
- }
149
- for (let i = 0; i < glyphInfo.length; i++) {
150
- context.save();
151
-
152
- const p0 = glyphInfo[i].p0;
153
-
154
- context.translate(p0.x, p0.y);
155
- context.rotate(glyphInfo[i].rotation);
156
- this.partialText = glyphInfo[i].text;
157
-
158
- context.fillStrokeShape(this);
159
- if (textDecoration === 'underline') {
160
- if (i === 0) {
161
- context.moveTo(0, fontSize / 2 + 1);
162
- }
163
-
164
- context.lineTo(fontSize, fontSize / 2 + 1);
165
- }
166
- context.restore();
167
-
168
- //// To assist with debugging visually, uncomment following
169
- //
170
- // if (i % 2) context.strokeStyle = 'cyan';
171
- // else context.strokeStyle = 'green';
172
- // var p1 = glyphInfo[i].p1;
173
- // context.moveTo(p0.x, p0.y);
174
- // context.lineTo(p1.x, p1.y);
175
- // context.stroke();
176
- }
177
- if (textDecoration === 'underline') {
178
- context.strokeStyle = fill;
179
- context.lineWidth = fontSize / 20;
180
- context.stroke();
181
- }
182
-
183
- context.restore();
184
- }
185
- _hitFunc(context: Context) {
186
- context.beginPath();
187
-
188
- const glyphInfo = this.glyphInfo;
189
- if (glyphInfo.length >= 1) {
190
- const p0 = glyphInfo[0].p0;
191
- context.moveTo(p0.x, p0.y);
192
- }
193
- for (let i = 0; i < glyphInfo.length; i++) {
194
- const p1 = glyphInfo[i].p1;
195
- context.lineTo(p1.x, p1.y);
196
- }
197
- context.setAttr('lineWidth', this.fontSize());
198
- context.setAttr('strokeStyle', this.colorKey);
199
- context.stroke();
200
- }
201
- /**
202
- * get text width in pixels
203
- * @method
204
- * @name Konva.TextPath#getTextWidth
205
- */
206
- getTextWidth() {
207
- return this.textWidth;
208
- }
209
- getTextHeight() {
210
- Util.warn(
211
- 'text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height.'
212
- );
213
- return this.textHeight;
214
- }
215
- setText(text: string) {
216
- return Text.prototype.setText.call(this, text);
217
- }
218
-
219
- _getContextFont() {
220
- return Text.prototype._getContextFont.call(this);
221
- }
222
-
223
- _getTextSize(text: string) {
224
- const dummyCanvas = this.dummyCanvas;
225
- const _context = dummyCanvas.getContext('2d')!;
226
-
227
- _context.save();
228
-
229
- _context.font = this._getContextFont();
230
- const metrics = _context.measureText(text);
231
-
232
- _context.restore();
233
-
234
- return {
235
- width: metrics.width,
236
- height: parseInt(`${this.fontSize()}`, 10),
237
- };
238
- }
239
- _setTextData() {
240
- const charArr = stringToArray(this.text());
241
- const chars: { char: string; width: number }[] = [];
242
- let width = 0;
243
- for (let i = 0; i < charArr.length; i++) {
244
- chars.push({
245
- char: charArr[i],
246
- width: this._getTextSize(charArr[i]).width,
247
- });
248
- width += chars[i].width;
249
- }
250
- const { height } = this._getTextSize(this.attrs.text);
251
- this.textWidth = width;
252
- this.textHeight = height;
253
- this.glyphInfo = [];
254
-
255
- if (!this.attrs.data) {
256
- return null;
257
- }
258
-
259
- const letterSpacing = this.letterSpacing();
260
- const align = this.align();
261
- const kerningFunc = this.kerningFunc();
262
-
263
- // defines the width of the text on a straight line
264
- const textWidth = Math.max(
265
- this.textWidth + ((this.attrs.text || '').length - 1) * letterSpacing,
266
- 0
267
- );
268
-
269
- let offset = 0;
270
- if (align === 'center') {
271
- offset = Math.max(0, this.pathLength / 2 - textWidth / 2);
272
- }
273
- if (align === 'right') {
274
- offset = Math.max(0, this.pathLength - textWidth);
275
- }
276
-
277
- // Algorithm for calculating glyph positions:
278
- // 1. Get the begging point of the glyph on the path using the offsetToGlyph,
279
- // 2. Get the ending point of the glyph on the path using the offsetToGlyph plus glyph width,
280
- // 3. Calculate the rotation, width, and midpoint of the glyph using the start and end points,
281
- // 4. Add glyph width to the offsetToGlyph and repeat
282
- let offsetToGlyph = offset;
283
- for (let i = 0; i < chars.length; i++) {
284
- const charStartPoint = this._getPointAtLength(offsetToGlyph);
285
- if (!charStartPoint) return;
286
-
287
- const char = chars[i].char;
288
- let glyphWidth = chars[i].width + letterSpacing;
289
- if (char === ' ' && align === 'justify') {
290
- const numberOfSpaces = this.text().split(' ').length - 1;
291
- glyphWidth += (this.pathLength - textWidth) / numberOfSpaces;
292
- }
293
-
294
- const charEndPoint = this._getPointAtLength(offsetToGlyph + glyphWidth);
295
- if (!charEndPoint) {
296
- return;
297
- }
298
-
299
- const width = Path.getLineLength(
300
- charStartPoint.x,
301
- charStartPoint.y,
302
- charEndPoint.x,
303
- charEndPoint.y
304
- );
305
-
306
- let kern = 0;
307
- if (kerningFunc) {
308
- try {
309
- // getKerning is a user provided getter. Make sure it never breaks our logic
310
- kern = kerningFunc(chars[i - 1].char, char) * this.fontSize();
311
- } catch (e) {
312
- kern = 0;
313
- }
314
- }
315
-
316
- charStartPoint.x += kern;
317
- charEndPoint.x += kern;
318
- this.textWidth += kern;
319
-
320
- const midpoint = Path.getPointOnLine(
321
- kern + width / 2.0,
322
- charStartPoint.x,
323
- charStartPoint.y,
324
- charEndPoint.x,
325
- charEndPoint.y
326
- );
327
-
328
- const rotation = Math.atan2(
329
- charEndPoint.y - charStartPoint.y,
330
- charEndPoint.x - charStartPoint.x
331
- );
332
- this.glyphInfo.push({
333
- transposeX: midpoint.x,
334
- transposeY: midpoint.y,
335
- text: charArr[i],
336
- rotation: rotation,
337
- p0: charStartPoint,
338
- p1: charEndPoint,
339
- });
340
-
341
- offsetToGlyph += glyphWidth;
342
- }
343
- }
344
- getSelfRect() {
345
- if (!this.glyphInfo.length) {
346
- return {
347
- x: 0,
348
- y: 0,
349
- width: 0,
350
- height: 0,
351
- };
352
- }
353
- const points: number[] = [];
354
-
355
- this.glyphInfo.forEach(function (info) {
356
- points.push(info.p0.x);
357
- points.push(info.p0.y);
358
- points.push(info.p1.x);
359
- points.push(info.p1.y);
360
- });
361
- let minX = points[0] || 0;
362
- let maxX = points[0] || 0;
363
- let minY = points[1] || 0;
364
- let maxY = points[1] || 0;
365
- let x, y;
366
- for (let i = 0; i < points.length / 2; i++) {
367
- x = points[i * 2];
368
- y = points[i * 2 + 1];
369
- minX = Math.min(minX, x);
370
- maxX = Math.max(maxX, x);
371
- minY = Math.min(minY, y);
372
- maxY = Math.max(maxY, y);
373
- }
374
- const fontSize = this.fontSize();
375
- return {
376
- x: minX - fontSize / 2,
377
- y: minY - fontSize / 2,
378
- width: maxX - minX + fontSize,
379
- height: maxY - minY + fontSize,
380
- };
381
- }
382
- destroy(): this {
383
- Util.releaseCanvas(this.dummyCanvas);
384
- return super.destroy();
385
- }
386
-
387
- fontFamily: GetSet<string, this>;
388
- fontSize: GetSet<number, this>;
389
- fontStyle: GetSet<string, this>;
390
- fontVariant: GetSet<string, this>;
391
- align: GetSet<string, this>;
392
- letterSpacing: GetSet<number, this>;
393
- text: GetSet<string, this>;
394
- data: GetSet<string, this>;
395
-
396
- kerningFunc: GetSet<(leftChar: string, rightChar: string) => number, this>;
397
- textBaseline: GetSet<string, this>;
398
- textDecoration: GetSet<string, this>;
399
- }
400
-
401
- TextPath.prototype._fillFunc = _fillFunc;
402
- TextPath.prototype._strokeFunc = _strokeFunc;
403
- TextPath.prototype._fillFuncHit = _fillFunc;
404
- TextPath.prototype._strokeFuncHit = _strokeFunc;
405
- TextPath.prototype.className = 'TextPath';
406
- TextPath.prototype._attrsAffectingSize = ['text', 'fontSize', 'data'];
407
- _registerNode(TextPath);
408
-
409
- /**
410
- * get/set SVG path data string. This method
411
- * also automatically parses the data string
412
- * into a data array. Currently supported SVG data:
413
- * M, m, L, l, H, h, V, v, Q, q, T, t, C, c, S, s, A, a, Z, z
414
- * @name Konva.TextPath#data
415
- * @method
416
- * @param {String} data svg path string
417
- * @returns {String}
418
- * @example
419
- * // get data
420
- * var data = shape.data();
421
- *
422
- * // set data
423
- * shape.data('M200,100h100v50z');
424
- */
425
- Factory.addGetterSetter(TextPath, 'data');
426
-
427
- /**
428
- * get/set font family
429
- * @name Konva.TextPath#fontFamily
430
- * @method
431
- * @param {String} fontFamily
432
- * @returns {String}
433
- * @example
434
- * // get font family
435
- * var fontFamily = shape.fontFamily();
436
- *
437
- * // set font family
438
- * shape.fontFamily('Arial');
439
- */
440
- Factory.addGetterSetter(TextPath, 'fontFamily', 'Arial');
441
-
442
- /**
443
- * get/set font size in pixels
444
- * @name Konva.TextPath#fontSize
445
- * @method
446
- * @param {Number} fontSize
447
- * @returns {Number}
448
- * @example
449
- * // get font size
450
- * var fontSize = shape.fontSize();
451
- *
452
- * // set font size to 22px
453
- * shape.fontSize(22);
454
- */
455
-
456
- Factory.addGetterSetter(TextPath, 'fontSize', 12, getNumberValidator());
457
-
458
- /**
459
- * get/set font style. Can be 'normal', 'italic', or 'bold', '500' or even 'italic bold'. 'normal' is the default.
460
- * @name Konva.TextPath#fontStyle
461
- * @method
462
- * @param {String} fontStyle
463
- * @returns {String}
464
- * @example
465
- * // get font style
466
- * var fontStyle = shape.fontStyle();
467
- *
468
- * // set font style
469
- * shape.fontStyle('bold');
470
- */
471
-
472
- Factory.addGetterSetter(TextPath, 'fontStyle', NORMAL);
473
-
474
- /**
475
- * get/set horizontal align of text. Can be 'left', 'center', 'right' or 'justify'
476
- * @name Konva.TextPath#align
477
- * @method
478
- * @param {String} align
479
- * @returns {String}
480
- * @example
481
- * // get text align
482
- * var align = text.align();
483
- *
484
- * // center text
485
- * text.align('center');
486
- *
487
- * // align text to right
488
- * text.align('right');
489
- */
490
- Factory.addGetterSetter(TextPath, 'align', 'left');
491
-
492
- /**
493
- * get/set letter spacing. The default is 0.
494
- * @name Konva.TextPath#letterSpacing
495
- * @method
496
- * @param {Number} letterSpacing
497
- * @returns {Number}
498
- * @example
499
- * // get letter spacing value
500
- * var letterSpacing = shape.letterSpacing();
501
- *
502
- * // set the letter spacing value
503
- * shape.letterSpacing(2);
504
- */
505
-
506
- Factory.addGetterSetter(TextPath, 'letterSpacing', 0, getNumberValidator());
507
-
508
- /**
509
- * get/set text baseline. The default is 'middle'. Can be 'top', 'bottom', 'middle', 'alphabetic', 'hanging'
510
- * @name Konva.TextPath#textBaseline
511
- * @method
512
- * @param {String} textBaseline
513
- * @returns {String}
514
- * @example
515
- * // get current text baseline
516
- * var textBaseline = shape.textBaseline();
517
- *
518
- * // set new text baseline
519
- * shape.textBaseline('top');
520
- */
521
- Factory.addGetterSetter(TextPath, 'textBaseline', 'middle');
522
-
523
- /**
524
- * get/set font variant. Can be 'normal' or 'small-caps'. 'normal' is the default.
525
- * @name Konva.TextPath#fontVariant
526
- * @method
527
- * @param {String} fontVariant
528
- * @returns {String}
529
- * @example
530
- * // get font variant
531
- * var fontVariant = shape.fontVariant();
532
- *
533
- * // set font variant
534
- * shape.fontVariant('small-caps');
535
- */
536
- Factory.addGetterSetter(TextPath, 'fontVariant', NORMAL);
537
-
538
- /**
539
- * get/set text
540
- * @name Konva.TextPath#getText
541
- * @method
542
- * @param {String} text
543
- * @returns {String}
544
- * @example
545
- * // get text
546
- * var text = text.text();
547
- *
548
- * // set text
549
- * text.text('Hello world!');
550
- */
551
- Factory.addGetterSetter(TextPath, 'text', EMPTY_STRING);
552
-
553
- /**
554
- * get/set text decoration of a text. Can be '' or 'underline'.
555
- * @name Konva.TextPath#textDecoration
556
- * @method
557
- * @param {String} textDecoration
558
- * @returns {String}
559
- * @example
560
- * // get text decoration
561
- * var textDecoration = shape.textDecoration();
562
- *
563
- * // underline text
564
- * shape.textDecoration('underline');
565
- */
566
- Factory.addGetterSetter(TextPath, 'textDecoration', '');
567
-
568
- /**
569
- * get/set kerning function.
570
- * @name Konva.TextPath#kerningFunc
571
- * @method
572
- * @param {String} kerningFunc
573
- * @returns {String}
574
- * @example
575
- * // get text decoration
576
- * var kerningFunc = text.kerningFunc();
577
- *
578
- * // center text
579
- * text.kerningFunc(function(leftChar, rightChar) {
580
- * return 1;
581
- * });
582
- */
583
- Factory.addGetterSetter(TextPath, 'kerningFunc', undefined);