konva 10.3.2 → 10.4.0
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/README.md +5 -1
- package/konva.js +1327 -1572
- package/konva.min.js +4 -4
- package/lib/Animation.d.ts +63 -3
- package/lib/Animation.js +86 -65
- package/lib/BezierFunctions.d.ts +10 -0
- package/lib/BezierFunctions.js +32 -0
- package/lib/Canvas.d.ts +53 -0
- package/lib/Canvas.js +93 -34
- package/lib/Container.d.ts +156 -9
- package/lib/Container.js +260 -25
- package/lib/Context.d.ts +247 -0
- package/lib/Context.js +312 -74
- package/lib/Core.js +1 -0
- package/lib/DragAndDrop.d.ts +1 -0
- package/lib/DragAndDrop.js +66 -17
- package/lib/Factory.d.ts +24 -1
- package/lib/Factory.js +14 -20
- package/lib/FastLayer.d.ts +14 -1
- package/lib/FastLayer.js +14 -1
- package/lib/Global.d.ts +114 -3
- package/lib/Global.js +134 -5
- package/lib/Group.d.ts +11 -0
- package/lib/Group.js +11 -0
- package/lib/Layer.d.ts +128 -3
- package/lib/Layer.js +260 -49
- package/lib/Node.d.ts +692 -30
- package/lib/Node.js +1534 -202
- package/lib/PointerEvents.d.ts +2 -1
- package/lib/PointerEvents.js +19 -1
- package/lib/Shape.d.ts +99 -14
- package/lib/Shape.js +1101 -67
- package/lib/Stage.d.ts +81 -1
- package/lib/Stage.js +166 -7
- package/lib/Tween.d.ts +159 -4
- package/lib/Tween.js +243 -24
- package/lib/Util.d.ts +147 -4
- package/lib/Util.js +332 -82
- package/lib/Validators.d.ts +0 -2
- package/lib/Validators.js +3 -25
- package/lib/_CoreInternals.d.ts +10 -6
- package/lib/_CoreInternals.js +1 -0
- package/lib/_FullInternals.d.ts +15 -6
- package/lib/_FullInternals.js +7 -0
- package/lib/canvas-backend.js +6 -0
- package/lib/filters/Blur.d.ts +18 -0
- package/lib/filters/Blur.js +97 -24
- package/lib/filters/Brighten.d.ts +21 -0
- package/lib/filters/Brighten.js +24 -0
- package/lib/filters/Brightness.d.ts +11 -0
- package/lib/filters/Brightness.js +16 -0
- package/lib/filters/Contrast.d.ts +10 -0
- package/lib/filters/Contrast.js +21 -0
- package/lib/filters/Emboss.d.ts +20 -0
- package/lib/filters/Emboss.js +68 -8
- package/lib/filters/Enhance.d.ts +14 -0
- package/lib/filters/Enhance.js +34 -0
- package/lib/filters/Grayscale.d.ts +9 -0
- package/lib/filters/Grayscale.js +12 -0
- package/lib/filters/HSL.d.ts +17 -0
- package/lib/filters/HSL.js +48 -5
- package/lib/filters/HSV.d.ts +18 -0
- package/lib/filters/HSV.js +49 -5
- package/lib/filters/Invert.d.ts +9 -0
- package/lib/filters/Invert.js +12 -0
- package/lib/filters/Kaleidoscope.d.ts +12 -0
- package/lib/filters/Kaleidoscope.js +83 -0
- package/lib/filters/Mask.d.ts +11 -0
- package/lib/filters/Mask.js +18 -0
- package/lib/filters/Noise.d.ts +19 -0
- package/lib/filters/Noise.js +19 -0
- package/lib/filters/Pixelate.d.ts +20 -0
- package/lib/filters/Pixelate.js +28 -1
- package/lib/filters/Posterize.d.ts +21 -0
- package/lib/filters/Posterize.js +22 -0
- package/lib/filters/RGB.d.ts +21 -0
- package/lib/filters/RGB.js +43 -28
- package/lib/filters/RGBA.d.ts +23 -0
- package/lib/filters/RGBA.js +28 -41
- package/lib/filters/Sepia.d.ts +9 -0
- package/lib/filters/Sepia.js +10 -0
- package/lib/filters/Solarize.d.ts +10 -0
- package/lib/filters/Solarize.js +11 -0
- package/lib/filters/Threshold.d.ts +22 -0
- package/lib/filters/Threshold.js +22 -0
- package/lib/shapes/Arc.d.ts +40 -0
- package/lib/shapes/Arc.js +89 -6
- package/lib/shapes/Arrow.d.ts +24 -1
- package/lib/shapes/Arrow.js +83 -0
- package/lib/shapes/Circle.d.ts +18 -0
- package/lib/shapes/Circle.js +36 -9
- package/lib/shapes/Ellipse.d.ts +34 -2
- package/lib/shapes/Ellipse.js +67 -9
- package/lib/shapes/Image.d.ts +49 -0
- package/lib/shapes/Image.js +151 -22
- package/lib/shapes/Label.d.ts +65 -1
- package/lib/shapes/Label.js +113 -20
- package/lib/shapes/Line.d.ts +50 -8
- package/lib/shapes/Line.js +116 -20
- package/lib/shapes/Path.d.ts +40 -6
- package/lib/shapes/Path.js +187 -128
- package/lib/shapes/Rect.d.ts +18 -0
- package/lib/shapes/Rect.js +36 -0
- package/lib/shapes/RegularPolygon.d.ts +22 -0
- package/lib/shapes/RegularPolygon.js +70 -0
- package/lib/shapes/Ring.d.ts +19 -0
- package/lib/shapes/Ring.js +51 -5
- package/lib/shapes/Sprite.d.ts +78 -0
- package/lib/shapes/Sprite.js +238 -25
- package/lib/shapes/Star.d.ts +23 -0
- package/lib/shapes/Star.js +62 -0
- package/lib/shapes/Text.d.ts +59 -1
- package/lib/shapes/Text.js +481 -97
- package/lib/shapes/TextPath.d.ts +49 -3
- package/lib/shapes/TextPath.js +278 -34
- package/lib/shapes/Transformer.d.ts +108 -11
- package/lib/shapes/Transformer.js +744 -102
- package/lib/shapes/Wedge.d.ts +22 -0
- package/lib/shapes/Wedge.js +67 -3
- package/lib/skia-backend.js +9 -0
- package/lib/types.d.ts +2 -23
- package/lib/types.js +1 -21
- package/package.json +24 -21
package/lib/shapes/Star.js
CHANGED
|
@@ -2,6 +2,29 @@ import { Factory } from "../Factory.js";
|
|
|
2
2
|
import { Shape } from "../Shape.js";
|
|
3
3
|
import { getNumberValidator } from "../Validators.js";
|
|
4
4
|
import { _registerNode } from "../Global.js";
|
|
5
|
+
/**
|
|
6
|
+
* Star constructor
|
|
7
|
+
* @constructor
|
|
8
|
+
* @memberof Konva
|
|
9
|
+
* @augments Konva.Shape
|
|
10
|
+
* @param {Object} config
|
|
11
|
+
* @param {Integer} config.numPoints
|
|
12
|
+
* @param {Number} config.innerRadius
|
|
13
|
+
* @param {Number} config.outerRadius
|
|
14
|
+
* @@shapeParams
|
|
15
|
+
* @@nodeParams
|
|
16
|
+
* @example
|
|
17
|
+
* var star = new Konva.Star({
|
|
18
|
+
* x: 100,
|
|
19
|
+
* y: 200,
|
|
20
|
+
* numPoints: 5,
|
|
21
|
+
* innerRadius: 70,
|
|
22
|
+
* outerRadius: 70,
|
|
23
|
+
* fill: 'red',
|
|
24
|
+
* stroke: 'black',
|
|
25
|
+
* strokeWidth: 4
|
|
26
|
+
* });
|
|
27
|
+
*/
|
|
5
28
|
export class Star extends Shape {
|
|
6
29
|
_sceneFunc(context) {
|
|
7
30
|
const innerRadius = this.innerRadius(), outerRadius = this.outerRadius(), numPoints = this.numPoints();
|
|
@@ -33,6 +56,45 @@ Star.prototype.className = 'Star';
|
|
|
33
56
|
Star.prototype._centroid = true;
|
|
34
57
|
Star.prototype._attrsAffectingSize = ['innerRadius', 'outerRadius'];
|
|
35
58
|
_registerNode(Star);
|
|
59
|
+
/**
|
|
60
|
+
* get/set number of points
|
|
61
|
+
* @name Konva.Star#numPoints
|
|
62
|
+
* @method
|
|
63
|
+
* @param {Number} numPoints
|
|
64
|
+
* @returns {Number}
|
|
65
|
+
* @example
|
|
66
|
+
* // get inner radius
|
|
67
|
+
* var numPoints = star.numPoints();
|
|
68
|
+
*
|
|
69
|
+
* // set inner radius
|
|
70
|
+
* star.numPoints(20);
|
|
71
|
+
*/
|
|
36
72
|
Factory.addGetterSetter(Star, 'numPoints', 5, getNumberValidator());
|
|
73
|
+
/**
|
|
74
|
+
* get/set innerRadius
|
|
75
|
+
* @name Konva.Star#innerRadius
|
|
76
|
+
* @method
|
|
77
|
+
* @param {Number} innerRadius
|
|
78
|
+
* @returns {Number}
|
|
79
|
+
* @example
|
|
80
|
+
* // get inner radius
|
|
81
|
+
* var innerRadius = star.innerRadius();
|
|
82
|
+
*
|
|
83
|
+
* // set inner radius
|
|
84
|
+
* star.innerRadius(20);
|
|
85
|
+
*/
|
|
37
86
|
Factory.addGetterSetter(Star, 'innerRadius', 0, getNumberValidator());
|
|
87
|
+
/**
|
|
88
|
+
* get/set outerRadius
|
|
89
|
+
* @name Konva.Star#outerRadius
|
|
90
|
+
* @method
|
|
91
|
+
* @param {Number} outerRadius
|
|
92
|
+
* @returns {Number}
|
|
93
|
+
* @example
|
|
94
|
+
* // get inner radius
|
|
95
|
+
* var outerRadius = star.outerRadius();
|
|
96
|
+
*
|
|
97
|
+
* // set inner radius
|
|
98
|
+
* star.outerRadius(20);
|
|
99
|
+
*/
|
|
38
100
|
Factory.addGetterSetter(Star, 'outerRadius', 0, getNumberValidator());
|
package/lib/shapes/Text.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export interface CharRenderProps {
|
|
|
13
13
|
width: number;
|
|
14
14
|
context: Context;
|
|
15
15
|
}
|
|
16
|
+
export declare function getDecorationLineWidth(fontSize: number): number;
|
|
16
17
|
export declare function stringToArray(string: string): string[];
|
|
17
18
|
export interface TextConfig extends ShapeConfig {
|
|
18
19
|
direction?: string;
|
|
@@ -30,7 +31,41 @@ export interface TextConfig extends ShapeConfig {
|
|
|
30
31
|
letterSpacing?: number;
|
|
31
32
|
wrap?: string;
|
|
32
33
|
ellipsis?: boolean;
|
|
34
|
+
charRenderFunc?: null | ((props: CharRenderProps) => void);
|
|
33
35
|
}
|
|
36
|
+
export declare function getDummyContext(): CanvasRenderingContext2D;
|
|
37
|
+
/**
|
|
38
|
+
* Text constructor
|
|
39
|
+
* @constructor
|
|
40
|
+
* @memberof Konva
|
|
41
|
+
* @augments Konva.Shape
|
|
42
|
+
* @param {Object} config
|
|
43
|
+
* @param {String} [config.direction] default is inherit
|
|
44
|
+
* @param {String} [config.fontFamily] default is Arial
|
|
45
|
+
* @param {Number} [config.fontSize] in pixels. Default is 12
|
|
46
|
+
* @param {String} [config.fontStyle] can be 'normal', 'italic', or 'bold', '500' or even 'italic bold'. 'normal' is the default.
|
|
47
|
+
* @param {String} [config.fontVariant] can be normal or small-caps. Default is normal
|
|
48
|
+
* @param {String} [config.textDecoration] can be line-through, underline or empty string. Default is empty string.
|
|
49
|
+
* @param {Number} [config.underlineOffset] offset for underline line. Default is calculated based on font size.
|
|
50
|
+
* @param {String} config.text
|
|
51
|
+
* @param {String} [config.align] can be left, center, right or justify
|
|
52
|
+
* @param {String} [config.verticalAlign] can be top, middle or bottom
|
|
53
|
+
* @param {Number} [config.padding]
|
|
54
|
+
* @param {Number} [config.lineHeight] default is 1
|
|
55
|
+
* @param {String} [config.wrap] can be "word", "char", or "none". Default is word
|
|
56
|
+
* @param {Boolean} [config.ellipsis] can be true or false. Default is false. If true, text that does not fit is cut and ends with "…". That needs a fixed height or wrap="none"
|
|
57
|
+
* @@shapeParams
|
|
58
|
+
* @@nodeParams
|
|
59
|
+
* @example
|
|
60
|
+
* var text = new Konva.Text({
|
|
61
|
+
* x: 10,
|
|
62
|
+
* y: 15,
|
|
63
|
+
* text: 'Simple Text',
|
|
64
|
+
* fontSize: 30,
|
|
65
|
+
* fontFamily: 'Calibri',
|
|
66
|
+
* fill: 'green'
|
|
67
|
+
* });
|
|
68
|
+
*/
|
|
34
69
|
export declare class Text extends Shape<TextConfig> {
|
|
35
70
|
textArr: Array<{
|
|
36
71
|
text: string;
|
|
@@ -50,8 +85,22 @@ export declare class Text extends Shape<TextConfig> {
|
|
|
50
85
|
setText(text: string): this;
|
|
51
86
|
getWidth(): any;
|
|
52
87
|
getHeight(): any;
|
|
88
|
+
/**
|
|
89
|
+
* get pure text width without padding
|
|
90
|
+
* @method
|
|
91
|
+
* @name Konva.Text#getTextWidth
|
|
92
|
+
* @returns {Number}
|
|
93
|
+
*/
|
|
53
94
|
getTextWidth(): number;
|
|
54
95
|
getTextHeight(): number;
|
|
96
|
+
/**
|
|
97
|
+
* measure string with the font of current text shape.
|
|
98
|
+
* That method can't handle multiline text.
|
|
99
|
+
* @method
|
|
100
|
+
* @name Konva.Text#measureSize
|
|
101
|
+
* @param {String} text text to measure
|
|
102
|
+
* @returns {Object} { width , height } of measured text
|
|
103
|
+
*/
|
|
55
104
|
measureSize(text: string): {
|
|
56
105
|
actualBoundingBoxAscent: number;
|
|
57
106
|
actualBoundingBoxDescent: number;
|
|
@@ -69,8 +118,15 @@ export declare class Text extends Shape<TextConfig> {
|
|
|
69
118
|
};
|
|
70
119
|
_getContextFont(): string;
|
|
71
120
|
_addTextLine(line: string): number;
|
|
72
|
-
_getTextWidth(text: string): number;
|
|
121
|
+
_getTextWidth(text: string, graphemes?: number): number;
|
|
73
122
|
_setTextData(): void;
|
|
123
|
+
/**
|
|
124
|
+
* whether to handle ellipsis, there are two cases:
|
|
125
|
+
* 1. the current line is the last line
|
|
126
|
+
* 2. wrap is NONE
|
|
127
|
+
* @param {Number} currentHeightPx
|
|
128
|
+
* @returns {Boolean}
|
|
129
|
+
*/
|
|
74
130
|
_shouldHandleEllipsis(currentHeightPx: number): boolean;
|
|
75
131
|
_tryToAddEllipsisToLastLine(): void;
|
|
76
132
|
getStrokeScaleEnabled(): boolean;
|
|
@@ -91,4 +147,6 @@ export declare class Text extends Shape<TextConfig> {
|
|
|
91
147
|
wrap: GetSet<string, this>;
|
|
92
148
|
ellipsis: GetSet<boolean, this>;
|
|
93
149
|
charRenderFunc: GetSet<null | ((props: CharRenderProps) => void), this>;
|
|
150
|
+
width: GetSet<number, this, number | 'auto'>;
|
|
151
|
+
height: GetSet<number, this, number | 'auto'>;
|
|
94
152
|
}
|