konva 8.4.3 → 9.0.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 +1 -9
- package/konva.js +17669 -16989
- package/konva.min.js +3 -3
- package/lib/Animation.js +11 -7
- package/lib/BezierFunctions.d.ts +6 -0
- package/lib/BezierFunctions.js +791 -0
- package/lib/Canvas.d.ts +1 -0
- package/lib/Canvas.js +26 -18
- package/lib/Container.js +16 -12
- package/lib/Context.d.ts +3 -1
- package/lib/Context.js +18 -10
- package/lib/Core.js +7 -3
- package/lib/DragAndDrop.js +25 -22
- package/lib/Factory.js +27 -24
- package/lib/FastLayer.js +10 -6
- package/lib/Global.js +16 -12
- package/lib/Group.js +10 -6
- package/lib/Layer.js +37 -33
- package/lib/Node.js +95 -90
- package/lib/PointerEvents.js +15 -7
- package/lib/Shape.js +90 -86
- package/lib/Stage.js +51 -47
- package/lib/Tween.js +26 -22
- package/lib/Util.js +29 -25
- package/lib/Validators.js +58 -44
- package/lib/_CoreInternals.js +36 -33
- package/lib/_FullInternals.js +78 -75
- package/lib/filters/Blur.js +9 -5
- package/lib/filters/Brighten.js +9 -5
- package/lib/filters/Contrast.js +9 -5
- package/lib/filters/Emboss.js +14 -10
- package/lib/filters/Enhance.js +9 -5
- package/lib/filters/Grayscale.js +5 -1
- package/lib/filters/HSL.js +11 -7
- package/lib/filters/HSV.js +11 -7
- package/lib/filters/Invert.js +5 -1
- package/lib/filters/Kaleidoscope.js +13 -9
- package/lib/filters/Mask.js +9 -5
- package/lib/filters/Noise.js +9 -5
- package/lib/filters/Pixelate.js +11 -7
- package/lib/filters/Posterize.js +9 -5
- package/lib/filters/RGB.js +11 -7
- package/lib/filters/RGBA.js +12 -8
- package/lib/filters/Sepia.js +5 -1
- package/lib/filters/Solarize.js +5 -1
- package/lib/filters/Threshold.js +9 -5
- package/lib/index-node.js +7 -5
- package/lib/index.js +4 -2
- package/lib/shapes/Arc.js +17 -13
- package/lib/shapes/Arrow.js +17 -13
- package/lib/shapes/Circle.js +11 -7
- package/lib/shapes/Ellipse.js +13 -9
- package/lib/shapes/Image.js +21 -17
- package/lib/shapes/Label.js +18 -13
- package/lib/shapes/Line.js +14 -10
- package/lib/shapes/Path.d.ts +5 -2
- package/lib/shapes/Path.js +44 -43
- package/lib/shapes/Rect.js +13 -9
- package/lib/shapes/RegularPolygon.js +12 -8
- package/lib/shapes/Ring.js +12 -8
- package/lib/shapes/Sprite.js +19 -15
- package/lib/shapes/Star.js +13 -9
- package/lib/shapes/Text.js +31 -26
- package/lib/shapes/TextPath.d.ts +5 -1
- package/lib/shapes/TextPath.js +82 -188
- package/lib/shapes/Transformer.js +85 -81
- package/lib/shapes/Wedge.js +16 -12
- package/lib/types.d.ts +6 -0
- package/lib/types.js +5 -2
- package/package.json +13 -42
- package/cmj/Animation.d.ts +0 -24
- package/cmj/Animation.js +0 -145
- package/cmj/Canvas.d.ts +0 -32
- package/cmj/Canvas.js +0 -114
- package/cmj/Container.d.ts +0 -47
- package/cmj/Container.js +0 -325
- package/cmj/Context.d.ts +0 -85
- package/cmj/Context.js +0 -538
- package/cmj/Core.d.ts +0 -3
- package/cmj/Core.js +0 -7
- package/cmj/DragAndDrop.d.ts +0 -17
- package/cmj/DragAndDrop.js +0 -111
- package/cmj/Factory.d.ts +0 -11
- package/cmj/Factory.js +0 -125
- package/cmj/FastLayer.d.ts +0 -4
- package/cmj/FastLayer.js +0 -16
- package/cmj/Global.d.ts +0 -34
- package/cmj/Global.js +0 -61
- package/cmj/Group.d.ts +0 -8
- package/cmj/Group.js +0 -17
- package/cmj/Layer.d.ts +0 -61
- package/cmj/Layer.js +0 -309
- package/cmj/Node.d.ts +0 -328
- package/cmj/Node.js +0 -1420
- package/cmj/PointerEvents.d.ts +0 -11
- package/cmj/PointerEvents.js +0 -45
- package/cmj/Shape.d.ts +0 -186
- package/cmj/Shape.js +0 -521
- package/cmj/Stage.d.ts +0 -85
- package/cmj/Stage.js +0 -692
- package/cmj/Tween.d.ts +0 -86
- package/cmj/Tween.js +0 -520
- package/cmj/Util.d.ts +0 -91
- package/cmj/Util.js +0 -801
- package/cmj/Validators.d.ts +0 -11
- package/cmj/Validators.js +0 -192
- package/cmj/_CoreInternals.d.ts +0 -152
- package/cmj/_CoreInternals.js +0 -37
- package/cmj/_FullInternals.d.ts +0 -196
- package/cmj/_FullInternals.js +0 -81
- package/cmj/filters/Blur.d.ts +0 -2
- package/cmj/filters/Blur.js +0 -701
- package/cmj/filters/Brighten.d.ts +0 -2
- package/cmj/filters/Brighten.js +0 -16
- package/cmj/filters/Contrast.d.ts +0 -2
- package/cmj/filters/Contrast.js +0 -38
- package/cmj/filters/Emboss.d.ts +0 -2
- package/cmj/filters/Emboss.js +0 -106
- package/cmj/filters/Enhance.d.ts +0 -2
- package/cmj/filters/Enhance.js +0 -87
- package/cmj/filters/Grayscale.d.ts +0 -2
- package/cmj/filters/Grayscale.js +0 -13
- package/cmj/filters/HSL.d.ts +0 -2
- package/cmj/filters/HSL.js +0 -28
- package/cmj/filters/HSV.d.ts +0 -2
- package/cmj/filters/HSV.js +0 -28
- package/cmj/filters/Invert.d.ts +0 -2
- package/cmj/filters/Invert.js +0 -12
- package/cmj/filters/Kaleidoscope.d.ts +0 -2
- package/cmj/filters/Kaleidoscope.js +0 -137
- package/cmj/filters/Mask.d.ts +0 -2
- package/cmj/filters/Mask.js +0 -144
- package/cmj/filters/Noise.d.ts +0 -2
- package/cmj/filters/Noise.js +0 -16
- package/cmj/filters/Pixelate.d.ts +0 -2
- package/cmj/filters/Pixelate.js +0 -64
- package/cmj/filters/Posterize.d.ts +0 -2
- package/cmj/filters/Posterize.js +0 -14
- package/cmj/filters/RGB.d.ts +0 -2
- package/cmj/filters/RGB.js +0 -43
- package/cmj/filters/RGBA.d.ts +0 -2
- package/cmj/filters/RGBA.js +0 -53
- package/cmj/filters/Sepia.d.ts +0 -2
- package/cmj/filters/Sepia.js +0 -15
- package/cmj/filters/Solarize.d.ts +0 -2
- package/cmj/filters/Solarize.js +0 -29
- package/cmj/filters/Threshold.d.ts +0 -2
- package/cmj/filters/Threshold.js +0 -14
- package/cmj/index-node.d.ts +0 -2
- package/cmj/index-node.js +0 -21
- package/cmj/index-types.d.ts +0 -181
- package/cmj/index.d.ts +0 -2
- package/cmj/index.js +0 -4
- package/cmj/package.json +0 -6
- package/cmj/shapes/Arc.d.ts +0 -26
- package/cmj/shapes/Arc.js +0 -59
- package/cmj/shapes/Arrow.d.ts +0 -26
- package/cmj/shapes/Arrow.js +0 -103
- package/cmj/shapes/Circle.d.ts +0 -14
- package/cmj/shapes/Circle.js +0 -37
- package/cmj/shapes/Ellipse.d.ts +0 -17
- package/cmj/shapes/Ellipse.js +0 -41
- package/cmj/shapes/Image.d.ts +0 -25
- package/cmj/shapes/Image.js +0 -117
- package/cmj/shapes/Label.d.ts +0 -36
- package/cmj/shapes/Label.js +0 -178
- package/cmj/shapes/Line.d.ts +0 -28
- package/cmj/shapes/Line.js +0 -159
- package/cmj/shapes/Path.d.ts +0 -37
- package/cmj/shapes/Path.js +0 -631
- package/cmj/shapes/Rect.d.ts +0 -10
- package/cmj/shapes/Rect.js +0 -26
- package/cmj/shapes/RegularPolygon.d.ts +0 -23
- package/cmj/shapes/RegularPolygon.js +0 -69
- package/cmj/shapes/Ring.d.ts +0 -16
- package/cmj/shapes/Ring.js +0 -37
- package/cmj/shapes/Sprite.d.ts +0 -31
- package/cmj/shapes/Sprite.js +0 -112
- package/cmj/shapes/Star.d.ts +0 -18
- package/cmj/shapes/Star.js +0 -42
- package/cmj/shapes/Text.d.ts +0 -63
- package/cmj/shapes/Text.js +0 -373
- package/cmj/shapes/TextPath.d.ts +0 -56
- package/cmj/shapes/TextPath.js +0 -351
- package/cmj/shapes/Transformer.d.ts +0 -116
- package/cmj/shapes/Transformer.js +0 -971
- package/cmj/shapes/Wedge.d.ts +0 -18
- package/cmj/shapes/Wedge.js +0 -42
- package/cmj/types.d.ts +0 -50
- package/cmj/types.js +0 -25
package/cmj/Tween.d.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { Animation } from './Animation';
|
|
2
|
-
import { Node, NodeConfig } from './Node';
|
|
3
|
-
declare class TweenEngine {
|
|
4
|
-
prop: string;
|
|
5
|
-
propFunc: Function;
|
|
6
|
-
begin: number;
|
|
7
|
-
_pos: number;
|
|
8
|
-
duration: number;
|
|
9
|
-
prevPos: number;
|
|
10
|
-
yoyo: boolean;
|
|
11
|
-
_time: number;
|
|
12
|
-
_position: number;
|
|
13
|
-
_startTime: number;
|
|
14
|
-
_finish: number;
|
|
15
|
-
func: Function;
|
|
16
|
-
_change: number;
|
|
17
|
-
state: number;
|
|
18
|
-
onPlay: Function;
|
|
19
|
-
onReverse: Function;
|
|
20
|
-
onPause: Function;
|
|
21
|
-
onReset: Function;
|
|
22
|
-
onFinish: Function;
|
|
23
|
-
onUpdate: Function;
|
|
24
|
-
constructor(prop: any, propFunc: any, func: any, begin: any, finish: any, duration: any, yoyo: any);
|
|
25
|
-
fire(str: any): void;
|
|
26
|
-
setTime(t: any): void;
|
|
27
|
-
getTime(): number;
|
|
28
|
-
setPosition(p: any): void;
|
|
29
|
-
getPosition(t: any): any;
|
|
30
|
-
play(): void;
|
|
31
|
-
reverse(): void;
|
|
32
|
-
seek(t: any): void;
|
|
33
|
-
reset(): void;
|
|
34
|
-
finish(): void;
|
|
35
|
-
update(): void;
|
|
36
|
-
onEnterFrame(): void;
|
|
37
|
-
pause(): void;
|
|
38
|
-
getTimer(): number;
|
|
39
|
-
}
|
|
40
|
-
export interface TweenConfig extends NodeConfig {
|
|
41
|
-
onFinish?: Function;
|
|
42
|
-
onUpdate?: Function;
|
|
43
|
-
duration?: number;
|
|
44
|
-
node: Node;
|
|
45
|
-
}
|
|
46
|
-
export declare class Tween {
|
|
47
|
-
static attrs: {};
|
|
48
|
-
static tweens: {};
|
|
49
|
-
node: Node;
|
|
50
|
-
anim: Animation;
|
|
51
|
-
tween: TweenEngine;
|
|
52
|
-
_id: number;
|
|
53
|
-
onFinish: Function;
|
|
54
|
-
onReset: Function;
|
|
55
|
-
onUpdate: Function;
|
|
56
|
-
constructor(config: TweenConfig);
|
|
57
|
-
_addAttr(key: any, end: any): void;
|
|
58
|
-
_tweenFunc(i: any): void;
|
|
59
|
-
_addListeners(): void;
|
|
60
|
-
play(): this;
|
|
61
|
-
reverse(): this;
|
|
62
|
-
reset(): this;
|
|
63
|
-
seek(t: any): this;
|
|
64
|
-
pause(): this;
|
|
65
|
-
finish(): this;
|
|
66
|
-
destroy(): void;
|
|
67
|
-
}
|
|
68
|
-
export declare const Easings: {
|
|
69
|
-
BackEaseIn(t: any, b: any, c: any, d: any): any;
|
|
70
|
-
BackEaseOut(t: any, b: any, c: any, d: any): any;
|
|
71
|
-
BackEaseInOut(t: any, b: any, c: any, d: any): any;
|
|
72
|
-
ElasticEaseIn(t: any, b: any, c: any, d: any, a: any, p: any): any;
|
|
73
|
-
ElasticEaseOut(t: any, b: any, c: any, d: any, a: any, p: any): any;
|
|
74
|
-
ElasticEaseInOut(t: any, b: any, c: any, d: any, a: any, p: any): any;
|
|
75
|
-
BounceEaseOut(t: any, b: any, c: any, d: any): any;
|
|
76
|
-
BounceEaseIn(t: any, b: any, c: any, d: any): any;
|
|
77
|
-
BounceEaseInOut(t: any, b: any, c: any, d: any): any;
|
|
78
|
-
EaseIn(t: any, b: any, c: any, d: any): any;
|
|
79
|
-
EaseOut(t: any, b: any, c: any, d: any): any;
|
|
80
|
-
EaseInOut(t: any, b: any, c: any, d: any): any;
|
|
81
|
-
StrongEaseIn(t: any, b: any, c: any, d: any): any;
|
|
82
|
-
StrongEaseOut(t: any, b: any, c: any, d: any): any;
|
|
83
|
-
StrongEaseInOut(t: any, b: any, c: any, d: any): any;
|
|
84
|
-
Linear(t: any, b: any, c: any, d: any): any;
|
|
85
|
-
};
|
|
86
|
-
export {};
|
package/cmj/Tween.js
DELETED
|
@@ -1,520 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Easings = exports.Tween = void 0;
|
|
4
|
-
const Util_1 = require("./Util");
|
|
5
|
-
const Animation_1 = require("./Animation");
|
|
6
|
-
const Node_1 = require("./Node");
|
|
7
|
-
const Global_1 = require("./Global");
|
|
8
|
-
var blacklist = {
|
|
9
|
-
node: 1,
|
|
10
|
-
duration: 1,
|
|
11
|
-
easing: 1,
|
|
12
|
-
onFinish: 1,
|
|
13
|
-
yoyo: 1,
|
|
14
|
-
}, PAUSED = 1, PLAYING = 2, REVERSING = 3, idCounter = 0, colorAttrs = ['fill', 'stroke', 'shadowColor'];
|
|
15
|
-
class TweenEngine {
|
|
16
|
-
constructor(prop, propFunc, func, begin, finish, duration, yoyo) {
|
|
17
|
-
this.prop = prop;
|
|
18
|
-
this.propFunc = propFunc;
|
|
19
|
-
this.begin = begin;
|
|
20
|
-
this._pos = begin;
|
|
21
|
-
this.duration = duration;
|
|
22
|
-
this._change = 0;
|
|
23
|
-
this.prevPos = 0;
|
|
24
|
-
this.yoyo = yoyo;
|
|
25
|
-
this._time = 0;
|
|
26
|
-
this._position = 0;
|
|
27
|
-
this._startTime = 0;
|
|
28
|
-
this._finish = 0;
|
|
29
|
-
this.func = func;
|
|
30
|
-
this._change = finish - this.begin;
|
|
31
|
-
this.pause();
|
|
32
|
-
}
|
|
33
|
-
fire(str) {
|
|
34
|
-
var handler = this[str];
|
|
35
|
-
if (handler) {
|
|
36
|
-
handler();
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
setTime(t) {
|
|
40
|
-
if (t > this.duration) {
|
|
41
|
-
if (this.yoyo) {
|
|
42
|
-
this._time = this.duration;
|
|
43
|
-
this.reverse();
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
this.finish();
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
else if (t < 0) {
|
|
50
|
-
if (this.yoyo) {
|
|
51
|
-
this._time = 0;
|
|
52
|
-
this.play();
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
this.reset();
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
this._time = t;
|
|
60
|
-
this.update();
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
getTime() {
|
|
64
|
-
return this._time;
|
|
65
|
-
}
|
|
66
|
-
setPosition(p) {
|
|
67
|
-
this.prevPos = this._pos;
|
|
68
|
-
this.propFunc(p);
|
|
69
|
-
this._pos = p;
|
|
70
|
-
}
|
|
71
|
-
getPosition(t) {
|
|
72
|
-
if (t === undefined) {
|
|
73
|
-
t = this._time;
|
|
74
|
-
}
|
|
75
|
-
return this.func(t, this.begin, this._change, this.duration);
|
|
76
|
-
}
|
|
77
|
-
play() {
|
|
78
|
-
this.state = PLAYING;
|
|
79
|
-
this._startTime = this.getTimer() - this._time;
|
|
80
|
-
this.onEnterFrame();
|
|
81
|
-
this.fire('onPlay');
|
|
82
|
-
}
|
|
83
|
-
reverse() {
|
|
84
|
-
this.state = REVERSING;
|
|
85
|
-
this._time = this.duration - this._time;
|
|
86
|
-
this._startTime = this.getTimer() - this._time;
|
|
87
|
-
this.onEnterFrame();
|
|
88
|
-
this.fire('onReverse');
|
|
89
|
-
}
|
|
90
|
-
seek(t) {
|
|
91
|
-
this.pause();
|
|
92
|
-
this._time = t;
|
|
93
|
-
this.update();
|
|
94
|
-
this.fire('onSeek');
|
|
95
|
-
}
|
|
96
|
-
reset() {
|
|
97
|
-
this.pause();
|
|
98
|
-
this._time = 0;
|
|
99
|
-
this.update();
|
|
100
|
-
this.fire('onReset');
|
|
101
|
-
}
|
|
102
|
-
finish() {
|
|
103
|
-
this.pause();
|
|
104
|
-
this._time = this.duration;
|
|
105
|
-
this.update();
|
|
106
|
-
this.fire('onFinish');
|
|
107
|
-
}
|
|
108
|
-
update() {
|
|
109
|
-
this.setPosition(this.getPosition(this._time));
|
|
110
|
-
this.fire('onUpdate');
|
|
111
|
-
}
|
|
112
|
-
onEnterFrame() {
|
|
113
|
-
var t = this.getTimer() - this._startTime;
|
|
114
|
-
if (this.state === PLAYING) {
|
|
115
|
-
this.setTime(t);
|
|
116
|
-
}
|
|
117
|
-
else if (this.state === REVERSING) {
|
|
118
|
-
this.setTime(this.duration - t);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
pause() {
|
|
122
|
-
this.state = PAUSED;
|
|
123
|
-
this.fire('onPause');
|
|
124
|
-
}
|
|
125
|
-
getTimer() {
|
|
126
|
-
return new Date().getTime();
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
class Tween {
|
|
130
|
-
constructor(config) {
|
|
131
|
-
var that = this, node = config.node, nodeId = node._id, duration, easing = config.easing || exports.Easings.Linear, yoyo = !!config.yoyo, key;
|
|
132
|
-
if (typeof config.duration === 'undefined') {
|
|
133
|
-
duration = 0.3;
|
|
134
|
-
}
|
|
135
|
-
else if (config.duration === 0) {
|
|
136
|
-
duration = 0.001;
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
duration = config.duration;
|
|
140
|
-
}
|
|
141
|
-
this.node = node;
|
|
142
|
-
this._id = idCounter++;
|
|
143
|
-
var layers = node.getLayer() ||
|
|
144
|
-
(node instanceof Global_1.Konva['Stage'] ? node.getLayers() : null);
|
|
145
|
-
if (!layers) {
|
|
146
|
-
Util_1.Util.error('Tween constructor have `node` that is not in a layer. Please add node into layer first.');
|
|
147
|
-
}
|
|
148
|
-
this.anim = new Animation_1.Animation(function () {
|
|
149
|
-
that.tween.onEnterFrame();
|
|
150
|
-
}, layers);
|
|
151
|
-
this.tween = new TweenEngine(key, function (i) {
|
|
152
|
-
that._tweenFunc(i);
|
|
153
|
-
}, easing, 0, 1, duration * 1000, yoyo);
|
|
154
|
-
this._addListeners();
|
|
155
|
-
if (!Tween.attrs[nodeId]) {
|
|
156
|
-
Tween.attrs[nodeId] = {};
|
|
157
|
-
}
|
|
158
|
-
if (!Tween.attrs[nodeId][this._id]) {
|
|
159
|
-
Tween.attrs[nodeId][this._id] = {};
|
|
160
|
-
}
|
|
161
|
-
if (!Tween.tweens[nodeId]) {
|
|
162
|
-
Tween.tweens[nodeId] = {};
|
|
163
|
-
}
|
|
164
|
-
for (key in config) {
|
|
165
|
-
if (blacklist[key] === undefined) {
|
|
166
|
-
this._addAttr(key, config[key]);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
this.reset();
|
|
170
|
-
this.onFinish = config.onFinish;
|
|
171
|
-
this.onReset = config.onReset;
|
|
172
|
-
this.onUpdate = config.onUpdate;
|
|
173
|
-
}
|
|
174
|
-
_addAttr(key, end) {
|
|
175
|
-
var node = this.node, nodeId = node._id, start, diff, tweenId, n, len, trueEnd, trueStart, endRGBA;
|
|
176
|
-
tweenId = Tween.tweens[nodeId][key];
|
|
177
|
-
if (tweenId) {
|
|
178
|
-
delete Tween.attrs[nodeId][tweenId][key];
|
|
179
|
-
}
|
|
180
|
-
start = node.getAttr(key);
|
|
181
|
-
if (Util_1.Util._isArray(end)) {
|
|
182
|
-
diff = [];
|
|
183
|
-
len = Math.max(end.length, start.length);
|
|
184
|
-
if (key === 'points' && end.length !== start.length) {
|
|
185
|
-
if (end.length > start.length) {
|
|
186
|
-
trueStart = start;
|
|
187
|
-
start = Util_1.Util._prepareArrayForTween(start, end, node.closed());
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
trueEnd = end;
|
|
191
|
-
end = Util_1.Util._prepareArrayForTween(end, start, node.closed());
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
if (key.indexOf('fill') === 0) {
|
|
195
|
-
for (n = 0; n < len; n++) {
|
|
196
|
-
if (n % 2 === 0) {
|
|
197
|
-
diff.push(end[n] - start[n]);
|
|
198
|
-
}
|
|
199
|
-
else {
|
|
200
|
-
var startRGBA = Util_1.Util.colorToRGBA(start[n]);
|
|
201
|
-
endRGBA = Util_1.Util.colorToRGBA(end[n]);
|
|
202
|
-
start[n] = startRGBA;
|
|
203
|
-
diff.push({
|
|
204
|
-
r: endRGBA.r - startRGBA.r,
|
|
205
|
-
g: endRGBA.g - startRGBA.g,
|
|
206
|
-
b: endRGBA.b - startRGBA.b,
|
|
207
|
-
a: endRGBA.a - startRGBA.a,
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
else {
|
|
213
|
-
for (n = 0; n < len; n++) {
|
|
214
|
-
diff.push(end[n] - start[n]);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
else if (colorAttrs.indexOf(key) !== -1) {
|
|
219
|
-
start = Util_1.Util.colorToRGBA(start);
|
|
220
|
-
endRGBA = Util_1.Util.colorToRGBA(end);
|
|
221
|
-
diff = {
|
|
222
|
-
r: endRGBA.r - start.r,
|
|
223
|
-
g: endRGBA.g - start.g,
|
|
224
|
-
b: endRGBA.b - start.b,
|
|
225
|
-
a: endRGBA.a - start.a,
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
else {
|
|
229
|
-
diff = end - start;
|
|
230
|
-
}
|
|
231
|
-
Tween.attrs[nodeId][this._id][key] = {
|
|
232
|
-
start: start,
|
|
233
|
-
diff: diff,
|
|
234
|
-
end: end,
|
|
235
|
-
trueEnd: trueEnd,
|
|
236
|
-
trueStart: trueStart,
|
|
237
|
-
};
|
|
238
|
-
Tween.tweens[nodeId][key] = this._id;
|
|
239
|
-
}
|
|
240
|
-
_tweenFunc(i) {
|
|
241
|
-
var node = this.node, attrs = Tween.attrs[node._id][this._id], key, attr, start, diff, newVal, n, len, end;
|
|
242
|
-
for (key in attrs) {
|
|
243
|
-
attr = attrs[key];
|
|
244
|
-
start = attr.start;
|
|
245
|
-
diff = attr.diff;
|
|
246
|
-
end = attr.end;
|
|
247
|
-
if (Util_1.Util._isArray(start)) {
|
|
248
|
-
newVal = [];
|
|
249
|
-
len = Math.max(start.length, end.length);
|
|
250
|
-
if (key.indexOf('fill') === 0) {
|
|
251
|
-
for (n = 0; n < len; n++) {
|
|
252
|
-
if (n % 2 === 0) {
|
|
253
|
-
newVal.push((start[n] || 0) + diff[n] * i);
|
|
254
|
-
}
|
|
255
|
-
else {
|
|
256
|
-
newVal.push('rgba(' +
|
|
257
|
-
Math.round(start[n].r + diff[n].r * i) +
|
|
258
|
-
',' +
|
|
259
|
-
Math.round(start[n].g + diff[n].g * i) +
|
|
260
|
-
',' +
|
|
261
|
-
Math.round(start[n].b + diff[n].b * i) +
|
|
262
|
-
',' +
|
|
263
|
-
(start[n].a + diff[n].a * i) +
|
|
264
|
-
')');
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
else {
|
|
269
|
-
for (n = 0; n < len; n++) {
|
|
270
|
-
newVal.push((start[n] || 0) + diff[n] * i);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
else if (colorAttrs.indexOf(key) !== -1) {
|
|
275
|
-
newVal =
|
|
276
|
-
'rgba(' +
|
|
277
|
-
Math.round(start.r + diff.r * i) +
|
|
278
|
-
',' +
|
|
279
|
-
Math.round(start.g + diff.g * i) +
|
|
280
|
-
',' +
|
|
281
|
-
Math.round(start.b + diff.b * i) +
|
|
282
|
-
',' +
|
|
283
|
-
(start.a + diff.a * i) +
|
|
284
|
-
')';
|
|
285
|
-
}
|
|
286
|
-
else {
|
|
287
|
-
newVal = start + diff * i;
|
|
288
|
-
}
|
|
289
|
-
node.setAttr(key, newVal);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
_addListeners() {
|
|
293
|
-
this.tween.onPlay = () => {
|
|
294
|
-
this.anim.start();
|
|
295
|
-
};
|
|
296
|
-
this.tween.onReverse = () => {
|
|
297
|
-
this.anim.start();
|
|
298
|
-
};
|
|
299
|
-
this.tween.onPause = () => {
|
|
300
|
-
this.anim.stop();
|
|
301
|
-
};
|
|
302
|
-
this.tween.onFinish = () => {
|
|
303
|
-
var node = this.node;
|
|
304
|
-
var attrs = Tween.attrs[node._id][this._id];
|
|
305
|
-
if (attrs.points && attrs.points.trueEnd) {
|
|
306
|
-
node.setAttr('points', attrs.points.trueEnd);
|
|
307
|
-
}
|
|
308
|
-
if (this.onFinish) {
|
|
309
|
-
this.onFinish.call(this);
|
|
310
|
-
}
|
|
311
|
-
};
|
|
312
|
-
this.tween.onReset = () => {
|
|
313
|
-
var node = this.node;
|
|
314
|
-
var attrs = Tween.attrs[node._id][this._id];
|
|
315
|
-
if (attrs.points && attrs.points.trueStart) {
|
|
316
|
-
node.points(attrs.points.trueStart);
|
|
317
|
-
}
|
|
318
|
-
if (this.onReset) {
|
|
319
|
-
this.onReset();
|
|
320
|
-
}
|
|
321
|
-
};
|
|
322
|
-
this.tween.onUpdate = () => {
|
|
323
|
-
if (this.onUpdate) {
|
|
324
|
-
this.onUpdate.call(this);
|
|
325
|
-
}
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
play() {
|
|
329
|
-
this.tween.play();
|
|
330
|
-
return this;
|
|
331
|
-
}
|
|
332
|
-
reverse() {
|
|
333
|
-
this.tween.reverse();
|
|
334
|
-
return this;
|
|
335
|
-
}
|
|
336
|
-
reset() {
|
|
337
|
-
this.tween.reset();
|
|
338
|
-
return this;
|
|
339
|
-
}
|
|
340
|
-
seek(t) {
|
|
341
|
-
this.tween.seek(t * 1000);
|
|
342
|
-
return this;
|
|
343
|
-
}
|
|
344
|
-
pause() {
|
|
345
|
-
this.tween.pause();
|
|
346
|
-
return this;
|
|
347
|
-
}
|
|
348
|
-
finish() {
|
|
349
|
-
this.tween.finish();
|
|
350
|
-
return this;
|
|
351
|
-
}
|
|
352
|
-
destroy() {
|
|
353
|
-
var nodeId = this.node._id, thisId = this._id, attrs = Tween.tweens[nodeId], key;
|
|
354
|
-
this.pause();
|
|
355
|
-
for (key in attrs) {
|
|
356
|
-
delete Tween.tweens[nodeId][key];
|
|
357
|
-
}
|
|
358
|
-
delete Tween.attrs[nodeId][thisId];
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
exports.Tween = Tween;
|
|
362
|
-
Tween.attrs = {};
|
|
363
|
-
Tween.tweens = {};
|
|
364
|
-
Node_1.Node.prototype.to = function (params) {
|
|
365
|
-
var onFinish = params.onFinish;
|
|
366
|
-
params.node = this;
|
|
367
|
-
params.onFinish = function () {
|
|
368
|
-
this.destroy();
|
|
369
|
-
if (onFinish) {
|
|
370
|
-
onFinish();
|
|
371
|
-
}
|
|
372
|
-
};
|
|
373
|
-
var tween = new Tween(params);
|
|
374
|
-
tween.play();
|
|
375
|
-
};
|
|
376
|
-
exports.Easings = {
|
|
377
|
-
BackEaseIn(t, b, c, d) {
|
|
378
|
-
var s = 1.70158;
|
|
379
|
-
return c * (t /= d) * t * ((s + 1) * t - s) + b;
|
|
380
|
-
},
|
|
381
|
-
BackEaseOut(t, b, c, d) {
|
|
382
|
-
var s = 1.70158;
|
|
383
|
-
return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
|
|
384
|
-
},
|
|
385
|
-
BackEaseInOut(t, b, c, d) {
|
|
386
|
-
var s = 1.70158;
|
|
387
|
-
if ((t /= d / 2) < 1) {
|
|
388
|
-
return (c / 2) * (t * t * (((s *= 1.525) + 1) * t - s)) + b;
|
|
389
|
-
}
|
|
390
|
-
return (c / 2) * ((t -= 2) * t * (((s *= 1.525) + 1) * t + s) + 2) + b;
|
|
391
|
-
},
|
|
392
|
-
ElasticEaseIn(t, b, c, d, a, p) {
|
|
393
|
-
var s = 0;
|
|
394
|
-
if (t === 0) {
|
|
395
|
-
return b;
|
|
396
|
-
}
|
|
397
|
-
if ((t /= d) === 1) {
|
|
398
|
-
return b + c;
|
|
399
|
-
}
|
|
400
|
-
if (!p) {
|
|
401
|
-
p = d * 0.3;
|
|
402
|
-
}
|
|
403
|
-
if (!a || a < Math.abs(c)) {
|
|
404
|
-
a = c;
|
|
405
|
-
s = p / 4;
|
|
406
|
-
}
|
|
407
|
-
else {
|
|
408
|
-
s = (p / (2 * Math.PI)) * Math.asin(c / a);
|
|
409
|
-
}
|
|
410
|
-
return (-(a *
|
|
411
|
-
Math.pow(2, 10 * (t -= 1)) *
|
|
412
|
-
Math.sin(((t * d - s) * (2 * Math.PI)) / p)) + b);
|
|
413
|
-
},
|
|
414
|
-
ElasticEaseOut(t, b, c, d, a, p) {
|
|
415
|
-
var s = 0;
|
|
416
|
-
if (t === 0) {
|
|
417
|
-
return b;
|
|
418
|
-
}
|
|
419
|
-
if ((t /= d) === 1) {
|
|
420
|
-
return b + c;
|
|
421
|
-
}
|
|
422
|
-
if (!p) {
|
|
423
|
-
p = d * 0.3;
|
|
424
|
-
}
|
|
425
|
-
if (!a || a < Math.abs(c)) {
|
|
426
|
-
a = c;
|
|
427
|
-
s = p / 4;
|
|
428
|
-
}
|
|
429
|
-
else {
|
|
430
|
-
s = (p / (2 * Math.PI)) * Math.asin(c / a);
|
|
431
|
-
}
|
|
432
|
-
return (a * Math.pow(2, -10 * t) * Math.sin(((t * d - s) * (2 * Math.PI)) / p) +
|
|
433
|
-
c +
|
|
434
|
-
b);
|
|
435
|
-
},
|
|
436
|
-
ElasticEaseInOut(t, b, c, d, a, p) {
|
|
437
|
-
var s = 0;
|
|
438
|
-
if (t === 0) {
|
|
439
|
-
return b;
|
|
440
|
-
}
|
|
441
|
-
if ((t /= d / 2) === 2) {
|
|
442
|
-
return b + c;
|
|
443
|
-
}
|
|
444
|
-
if (!p) {
|
|
445
|
-
p = d * (0.3 * 1.5);
|
|
446
|
-
}
|
|
447
|
-
if (!a || a < Math.abs(c)) {
|
|
448
|
-
a = c;
|
|
449
|
-
s = p / 4;
|
|
450
|
-
}
|
|
451
|
-
else {
|
|
452
|
-
s = (p / (2 * Math.PI)) * Math.asin(c / a);
|
|
453
|
-
}
|
|
454
|
-
if (t < 1) {
|
|
455
|
-
return (-0.5 *
|
|
456
|
-
(a *
|
|
457
|
-
Math.pow(2, 10 * (t -= 1)) *
|
|
458
|
-
Math.sin(((t * d - s) * (2 * Math.PI)) / p)) +
|
|
459
|
-
b);
|
|
460
|
-
}
|
|
461
|
-
return (a *
|
|
462
|
-
Math.pow(2, -10 * (t -= 1)) *
|
|
463
|
-
Math.sin(((t * d - s) * (2 * Math.PI)) / p) *
|
|
464
|
-
0.5 +
|
|
465
|
-
c +
|
|
466
|
-
b);
|
|
467
|
-
},
|
|
468
|
-
BounceEaseOut(t, b, c, d) {
|
|
469
|
-
if ((t /= d) < 1 / 2.75) {
|
|
470
|
-
return c * (7.5625 * t * t) + b;
|
|
471
|
-
}
|
|
472
|
-
else if (t < 2 / 2.75) {
|
|
473
|
-
return c * (7.5625 * (t -= 1.5 / 2.75) * t + 0.75) + b;
|
|
474
|
-
}
|
|
475
|
-
else if (t < 2.5 / 2.75) {
|
|
476
|
-
return c * (7.5625 * (t -= 2.25 / 2.75) * t + 0.9375) + b;
|
|
477
|
-
}
|
|
478
|
-
else {
|
|
479
|
-
return c * (7.5625 * (t -= 2.625 / 2.75) * t + 0.984375) + b;
|
|
480
|
-
}
|
|
481
|
-
},
|
|
482
|
-
BounceEaseIn(t, b, c, d) {
|
|
483
|
-
return c - exports.Easings.BounceEaseOut(d - t, 0, c, d) + b;
|
|
484
|
-
},
|
|
485
|
-
BounceEaseInOut(t, b, c, d) {
|
|
486
|
-
if (t < d / 2) {
|
|
487
|
-
return exports.Easings.BounceEaseIn(t * 2, 0, c, d) * 0.5 + b;
|
|
488
|
-
}
|
|
489
|
-
else {
|
|
490
|
-
return exports.Easings.BounceEaseOut(t * 2 - d, 0, c, d) * 0.5 + c * 0.5 + b;
|
|
491
|
-
}
|
|
492
|
-
},
|
|
493
|
-
EaseIn(t, b, c, d) {
|
|
494
|
-
return c * (t /= d) * t + b;
|
|
495
|
-
},
|
|
496
|
-
EaseOut(t, b, c, d) {
|
|
497
|
-
return -c * (t /= d) * (t - 2) + b;
|
|
498
|
-
},
|
|
499
|
-
EaseInOut(t, b, c, d) {
|
|
500
|
-
if ((t /= d / 2) < 1) {
|
|
501
|
-
return (c / 2) * t * t + b;
|
|
502
|
-
}
|
|
503
|
-
return (-c / 2) * (--t * (t - 2) - 1) + b;
|
|
504
|
-
},
|
|
505
|
-
StrongEaseIn(t, b, c, d) {
|
|
506
|
-
return c * (t /= d) * t * t * t * t + b;
|
|
507
|
-
},
|
|
508
|
-
StrongEaseOut(t, b, c, d) {
|
|
509
|
-
return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
|
|
510
|
-
},
|
|
511
|
-
StrongEaseInOut(t, b, c, d) {
|
|
512
|
-
if ((t /= d / 2) < 1) {
|
|
513
|
-
return (c / 2) * t * t * t * t * t + b;
|
|
514
|
-
}
|
|
515
|
-
return (c / 2) * ((t -= 2) * t * t * t * t + 2) + b;
|
|
516
|
-
},
|
|
517
|
-
Linear(t, b, c, d) {
|
|
518
|
-
return (c * t) / d + b;
|
|
519
|
-
},
|
|
520
|
-
};
|
package/cmj/Util.d.ts
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { Context } from './Context';
|
|
2
|
-
import { IRect, RGB, RGBA, Vector2d } from './types';
|
|
3
|
-
export declare class Transform {
|
|
4
|
-
m: Array<number>;
|
|
5
|
-
dirty: boolean;
|
|
6
|
-
constructor(m?: number[]);
|
|
7
|
-
reset(): void;
|
|
8
|
-
copy(): Transform;
|
|
9
|
-
copyInto(tr: Transform): void;
|
|
10
|
-
point(point: Vector2d): {
|
|
11
|
-
x: number;
|
|
12
|
-
y: number;
|
|
13
|
-
};
|
|
14
|
-
translate(x: number, y: number): this;
|
|
15
|
-
scale(sx: number, sy: number): this;
|
|
16
|
-
rotate(rad: number): this;
|
|
17
|
-
getTranslation(): {
|
|
18
|
-
x: number;
|
|
19
|
-
y: number;
|
|
20
|
-
};
|
|
21
|
-
skew(sx: number, sy: number): this;
|
|
22
|
-
multiply(matrix: Transform): this;
|
|
23
|
-
invert(): this;
|
|
24
|
-
getMatrix(): number[];
|
|
25
|
-
decompose(): {
|
|
26
|
-
x: number;
|
|
27
|
-
y: number;
|
|
28
|
-
rotation: number;
|
|
29
|
-
scaleX: number;
|
|
30
|
-
scaleY: number;
|
|
31
|
-
skewX: number;
|
|
32
|
-
skewY: number;
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
export declare const Util: {
|
|
36
|
-
_isElement(obj: any): obj is Element;
|
|
37
|
-
_isFunction(obj: any): boolean;
|
|
38
|
-
_isPlainObject(obj: any): boolean;
|
|
39
|
-
_isArray(obj: any): obj is any[];
|
|
40
|
-
_isNumber(obj: any): obj is number;
|
|
41
|
-
_isString(obj: any): obj is string;
|
|
42
|
-
_isBoolean(obj: any): obj is boolean;
|
|
43
|
-
isObject(val: any): val is Object;
|
|
44
|
-
isValidSelector(selector: any): boolean;
|
|
45
|
-
_sign(number: number): 1 | -1;
|
|
46
|
-
requestAnimFrame(callback: Function): void;
|
|
47
|
-
createCanvasElement(): HTMLCanvasElement;
|
|
48
|
-
createImageElement(): HTMLImageElement;
|
|
49
|
-
_isInDocument(el: any): boolean;
|
|
50
|
-
_urlToImage(url: string, callback: Function): void;
|
|
51
|
-
_rgbToHex(r: number, g: number, b: number): string;
|
|
52
|
-
_hexToRgb(hex: string): RGB;
|
|
53
|
-
getRandomColor(): string;
|
|
54
|
-
getRGB(color: string): RGB;
|
|
55
|
-
colorToRGBA(str: string): RGBA;
|
|
56
|
-
_namedColorToRBA(str: string): {
|
|
57
|
-
r: any;
|
|
58
|
-
g: any;
|
|
59
|
-
b: any;
|
|
60
|
-
a: number;
|
|
61
|
-
};
|
|
62
|
-
_rgbColorToRGBA(str: string): RGBA;
|
|
63
|
-
_rgbaColorToRGBA(str: string): RGBA;
|
|
64
|
-
_hex8ColorToRGBA(str: string): RGBA;
|
|
65
|
-
_hex6ColorToRGBA(str: string): RGBA;
|
|
66
|
-
_hex4ColorToRGBA(str: string): RGBA;
|
|
67
|
-
_hex3ColorToRGBA(str: string): RGBA;
|
|
68
|
-
_hslColorToRGBA(str: string): RGBA;
|
|
69
|
-
haveIntersection(r1: IRect, r2: IRect): boolean;
|
|
70
|
-
cloneObject<Any>(obj: Any): Any;
|
|
71
|
-
cloneArray(arr: Array<any>): any[];
|
|
72
|
-
degToRad(deg: number): number;
|
|
73
|
-
radToDeg(rad: number): number;
|
|
74
|
-
_degToRad(deg: number): number;
|
|
75
|
-
_radToDeg(rad: number): number;
|
|
76
|
-
_getRotation(radians: any): any;
|
|
77
|
-
_capitalize(str: string): string;
|
|
78
|
-
throw(str: string): never;
|
|
79
|
-
error(str: string): void;
|
|
80
|
-
warn(str: string): void;
|
|
81
|
-
each(obj: any, func: any): void;
|
|
82
|
-
_inRange(val: any, left: any, right: any): boolean;
|
|
83
|
-
_getProjectionToSegment(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any): any[];
|
|
84
|
-
_getProjectionToLine(pt: Vector2d, line: any, isClosed: any): Vector2d;
|
|
85
|
-
_prepareArrayForTween(startArray: any, endArray: any, isClosed: any): any[];
|
|
86
|
-
_prepareToStringify(obj: any): any;
|
|
87
|
-
_assign<T, U>(target: T, source: U): T & U;
|
|
88
|
-
_getFirstPointerId(evt: any): any;
|
|
89
|
-
releaseCanvas(...canvases: HTMLCanvasElement[]): void;
|
|
90
|
-
drawRoundedRectPath(context: Context, width: number, height: number, cornerRadius: number | number[]): void;
|
|
91
|
-
};
|