@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.
- package/0 +0 -0
- package/dist/index.js +323 -155
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/index.min.mjs +1 -1
- package/dist/index.min.mjs.map +1 -1
- package/dist/index.mjs +323 -155
- package/dist/index.mjs.map +1 -1
- package/dist/index.node.cjs +323 -155
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +323 -155
- package/dist/index.node.mjs.map +1 -1
- package/dist/package.json.min.mjs +1 -1
- package/dist/package.json.mjs +1 -1
- package/dist/src/shapes/Line.d.ts +31 -86
- package/dist/src/shapes/Line.d.ts.map +1 -1
- package/dist/src/shapes/Line.min.mjs +1 -1
- package/dist/src/shapes/Line.min.mjs.map +1 -1
- package/dist/src/shapes/Line.mjs +323 -154
- package/dist/src/shapes/Line.mjs.map +1 -1
- package/dist-extensions/src/shapes/CustomLine.d.ts +10 -0
- package/dist-extensions/src/shapes/CustomLine.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Line.d.ts +31 -86
- package/dist-extensions/src/shapes/Line.d.ts.map +1 -1
- package/fabric-test-editor.html +157 -8
- package/fabric-test2.html +513 -0
- package/fabric.ts +182 -182
- package/package.json +1 -1
- package/src/shapes/Line.ts +372 -158
- package/debug/konva/CHANGELOG.md +0 -1474
- package/debug/konva/LICENSE +0 -22
- package/debug/konva/README.md +0 -205
- package/debug/konva/gulpfile.mjs +0 -110
- package/debug/konva/package.json +0 -139
- package/debug/konva/release.sh +0 -65
- package/debug/konva/resources/doc-includes/ContainerParams.txt +0 -6
- package/debug/konva/resources/doc-includes/NodeParams.txt +0 -20
- package/debug/konva/resources/doc-includes/ShapeParams.txt +0 -53
- package/debug/konva/resources/jsdoc.conf.json +0 -28
- package/debug/konva/rollup.config.mjs +0 -32
- package/debug/konva/src/Animation.ts +0 -237
- package/debug/konva/src/BezierFunctions.ts +0 -826
- package/debug/konva/src/Canvas.ts +0 -193
- package/debug/konva/src/Container.ts +0 -649
- package/debug/konva/src/Context.ts +0 -1017
- package/debug/konva/src/Core.ts +0 -5
- package/debug/konva/src/DragAndDrop.ts +0 -173
- package/debug/konva/src/Factory.ts +0 -246
- package/debug/konva/src/FastLayer.ts +0 -29
- package/debug/konva/src/Global.ts +0 -210
- package/debug/konva/src/Group.ts +0 -31
- package/debug/konva/src/Layer.ts +0 -546
- package/debug/konva/src/Node.ts +0 -3477
- package/debug/konva/src/PointerEvents.ts +0 -67
- package/debug/konva/src/Shape.ts +0 -2081
- package/debug/konva/src/Stage.ts +0 -1000
- package/debug/konva/src/Tween.ts +0 -811
- package/debug/konva/src/Util.ts +0 -1123
- package/debug/konva/src/Validators.ts +0 -210
- package/debug/konva/src/_CoreInternals.ts +0 -85
- package/debug/konva/src/_FullInternals.ts +0 -171
- package/debug/konva/src/canvas-backend.ts +0 -36
- package/debug/konva/src/filters/Blur.ts +0 -388
- package/debug/konva/src/filters/Brighten.ts +0 -48
- package/debug/konva/src/filters/Brightness.ts +0 -30
- package/debug/konva/src/filters/Contrast.ts +0 -75
- package/debug/konva/src/filters/Emboss.ts +0 -207
- package/debug/konva/src/filters/Enhance.ts +0 -154
- package/debug/konva/src/filters/Grayscale.ts +0 -25
- package/debug/konva/src/filters/HSL.ts +0 -108
- package/debug/konva/src/filters/HSV.ts +0 -106
- package/debug/konva/src/filters/Invert.ts +0 -23
- package/debug/konva/src/filters/Kaleidoscope.ts +0 -274
- package/debug/konva/src/filters/Mask.ts +0 -220
- package/debug/konva/src/filters/Noise.ts +0 -44
- package/debug/konva/src/filters/Pixelate.ts +0 -107
- package/debug/konva/src/filters/Posterize.ts +0 -46
- package/debug/konva/src/filters/RGB.ts +0 -82
- package/debug/konva/src/filters/RGBA.ts +0 -103
- package/debug/konva/src/filters/Sepia.ts +0 -27
- package/debug/konva/src/filters/Solarize.ts +0 -29
- package/debug/konva/src/filters/Threshold.ts +0 -44
- package/debug/konva/src/index.ts +0 -3
- package/debug/konva/src/shapes/Arc.ts +0 -176
- package/debug/konva/src/shapes/Arrow.ts +0 -231
- package/debug/konva/src/shapes/Circle.ts +0 -76
- package/debug/konva/src/shapes/Ellipse.ts +0 -121
- package/debug/konva/src/shapes/Image.ts +0 -319
- package/debug/konva/src/shapes/Label.ts +0 -386
- package/debug/konva/src/shapes/Line.ts +0 -364
- package/debug/konva/src/shapes/Path.ts +0 -1013
- package/debug/konva/src/shapes/Rect.ts +0 -79
- package/debug/konva/src/shapes/RegularPolygon.ts +0 -167
- package/debug/konva/src/shapes/Ring.ts +0 -94
- package/debug/konva/src/shapes/Sprite.ts +0 -370
- package/debug/konva/src/shapes/Star.ts +0 -125
- package/debug/konva/src/shapes/Text.ts +0 -1065
- package/debug/konva/src/shapes/TextPath.ts +0 -583
- package/debug/konva/src/shapes/Transformer.ts +0 -1889
- package/debug/konva/src/shapes/Wedge.ts +0 -129
- package/debug/konva/src/skia-backend.ts +0 -35
- package/debug/konva/src/types.ts +0 -84
- package/debug/konva/tsconfig.json +0 -31
- package/debug/konva/tsconfig.test.json +0 -7
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// import resolve from 'rollup-plugin-node-resolve';
|
|
2
|
-
import typescript from 'rollup-plugin-typescript2';
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
input: `src/index.ts`,
|
|
6
|
-
output: [
|
|
7
|
-
{
|
|
8
|
-
file: 'konva.js',
|
|
9
|
-
name: 'Konva',
|
|
10
|
-
format: 'umd',
|
|
11
|
-
sourcemap: false,
|
|
12
|
-
freeze: false,
|
|
13
|
-
},
|
|
14
|
-
],
|
|
15
|
-
external: [],
|
|
16
|
-
watch: {
|
|
17
|
-
include: 'src/**',
|
|
18
|
-
},
|
|
19
|
-
plugins: [
|
|
20
|
-
// Compile TypeScript files
|
|
21
|
-
typescript({
|
|
22
|
-
useTsconfigDeclarationDir: true,
|
|
23
|
-
abortOnError: false,
|
|
24
|
-
removeComments: false,
|
|
25
|
-
tsconfigOverride: {
|
|
26
|
-
compilerOptions: {
|
|
27
|
-
module: 'ES2020',
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
}),
|
|
31
|
-
],
|
|
32
|
-
};
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import { glob } from './Global.ts';
|
|
2
|
-
import type { Layer } from './Layer.ts';
|
|
3
|
-
import type { IFrame, AnimationFn } from './types.ts';
|
|
4
|
-
import { Util } from './Util.ts';
|
|
5
|
-
|
|
6
|
-
const now = (function (): () => number {
|
|
7
|
-
if (glob.performance && glob.performance.now) {
|
|
8
|
-
return function () {
|
|
9
|
-
return glob.performance.now();
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
return function () {
|
|
14
|
-
return new Date().getTime();
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Animation constructor.
|
|
20
|
-
* @constructor
|
|
21
|
-
* @memberof Konva
|
|
22
|
-
* @param {AnimationFn} func function executed on each animation frame. The function is passed a frame object, which contains
|
|
23
|
-
* timeDiff, lastTime, time, and frameRate properties. The timeDiff property is the number of milliseconds that have passed
|
|
24
|
-
* since the last animation frame. The time property is the time in milliseconds that elapsed from the moment the animation started
|
|
25
|
-
* to the current animation frame. The lastTime property is a `time` value from the previous frame. The frameRate property is the current frame rate in frames / second.
|
|
26
|
-
* Return false from function, if you don't need to redraw layer/layers on some frames.
|
|
27
|
-
* @param {Konva.Layer|Array} [layers] layer(s) to be redrawn on each animation frame. Can be a layer, an array of layers, or null.
|
|
28
|
-
* Not specifying a node will result in no redraw.
|
|
29
|
-
* @example
|
|
30
|
-
* // move a node to the right at 50 pixels / second
|
|
31
|
-
* var velocity = 50;
|
|
32
|
-
*
|
|
33
|
-
* var anim = new Konva.Animation(function(frame) {
|
|
34
|
-
* var dist = velocity * (frame.timeDiff / 1000);
|
|
35
|
-
* node.move({x: dist, y: 0});
|
|
36
|
-
* }, layer);
|
|
37
|
-
*
|
|
38
|
-
* anim.start();
|
|
39
|
-
*/
|
|
40
|
-
export class Animation {
|
|
41
|
-
func: AnimationFn;
|
|
42
|
-
id = Animation.animIdCounter++;
|
|
43
|
-
|
|
44
|
-
layers: Layer[];
|
|
45
|
-
|
|
46
|
-
frame: IFrame = {
|
|
47
|
-
time: 0,
|
|
48
|
-
timeDiff: 0,
|
|
49
|
-
lastTime: now(),
|
|
50
|
-
frameRate: 0,
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
constructor(func: AnimationFn, layers?) {
|
|
54
|
-
this.func = func;
|
|
55
|
-
this.setLayers(layers);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* set layers to be redrawn on each animation frame
|
|
59
|
-
* @method
|
|
60
|
-
* @name Konva.Animation#setLayers
|
|
61
|
-
* @param {Konva.Layer|Array} [layers] layer(s) to be redrawn. Can be a layer, an array of layers, or null. Not specifying a node will result in no redraw.
|
|
62
|
-
* @return {Konva.Animation} this
|
|
63
|
-
*/
|
|
64
|
-
setLayers(layers: null | Layer | Layer[]) {
|
|
65
|
-
let lays: Layer[] = [];
|
|
66
|
-
// if passing in no layers
|
|
67
|
-
if (layers) {
|
|
68
|
-
lays = Array.isArray(layers) ? layers : [layers];
|
|
69
|
-
}
|
|
70
|
-
this.layers = lays;
|
|
71
|
-
return this;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* get layers
|
|
75
|
-
* @method
|
|
76
|
-
* @name Konva.Animation#getLayers
|
|
77
|
-
* @return {Array} Array of Konva.Layer
|
|
78
|
-
*/
|
|
79
|
-
getLayers() {
|
|
80
|
-
return this.layers;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* add layer. Returns true if the layer was added, and false if it was not
|
|
84
|
-
* @method
|
|
85
|
-
* @name Konva.Animation#addLayer
|
|
86
|
-
* @param {Konva.Layer} layer to add
|
|
87
|
-
* @return {Bool} true if layer is added to animation, otherwise false
|
|
88
|
-
*/
|
|
89
|
-
addLayer(layer: Layer) {
|
|
90
|
-
const layers = this.layers;
|
|
91
|
-
const len = layers.length;
|
|
92
|
-
|
|
93
|
-
// don't add the layer if it already exists
|
|
94
|
-
for (let n = 0; n < len; n++) {
|
|
95
|
-
if (layers[n]._id === layer._id) {
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
this.layers.push(layer);
|
|
101
|
-
return true;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* determine if animation is running or not. returns true or false
|
|
105
|
-
* @method
|
|
106
|
-
* @name Konva.Animation#isRunning
|
|
107
|
-
* @return {Bool} is animation running?
|
|
108
|
-
*/
|
|
109
|
-
isRunning() {
|
|
110
|
-
const a = Animation;
|
|
111
|
-
const animations = a.animations;
|
|
112
|
-
const len = animations.length;
|
|
113
|
-
|
|
114
|
-
for (let n = 0; n < len; n++) {
|
|
115
|
-
if (animations[n].id === this.id) {
|
|
116
|
-
return true;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* start animation
|
|
123
|
-
* @method
|
|
124
|
-
* @name Konva.Animation#start
|
|
125
|
-
* @return {Konva.Animation} this
|
|
126
|
-
*/
|
|
127
|
-
start() {
|
|
128
|
-
this.stop();
|
|
129
|
-
this.frame.timeDiff = 0;
|
|
130
|
-
this.frame.lastTime = now();
|
|
131
|
-
Animation._addAnimation(this);
|
|
132
|
-
return this;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* stop animation
|
|
136
|
-
* @method
|
|
137
|
-
* @name Konva.Animation#stop
|
|
138
|
-
* @return {Konva.Animation} this
|
|
139
|
-
*/
|
|
140
|
-
stop() {
|
|
141
|
-
Animation._removeAnimation(this);
|
|
142
|
-
return this;
|
|
143
|
-
}
|
|
144
|
-
_updateFrameObject(time: number) {
|
|
145
|
-
this.frame.timeDiff = time - this.frame.lastTime;
|
|
146
|
-
this.frame.lastTime = time;
|
|
147
|
-
this.frame.time += this.frame.timeDiff;
|
|
148
|
-
this.frame.frameRate = 1000 / this.frame.timeDiff;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
static animations: Array<Animation> = [];
|
|
152
|
-
static animIdCounter = 0;
|
|
153
|
-
static animRunning = false;
|
|
154
|
-
|
|
155
|
-
static _addAnimation(anim) {
|
|
156
|
-
this.animations.push(anim);
|
|
157
|
-
this._handleAnimation();
|
|
158
|
-
}
|
|
159
|
-
static _removeAnimation(anim) {
|
|
160
|
-
const id = anim.id;
|
|
161
|
-
const animations = this.animations;
|
|
162
|
-
const len = animations.length;
|
|
163
|
-
|
|
164
|
-
for (let n = 0; n < len; n++) {
|
|
165
|
-
if (animations[n].id === id) {
|
|
166
|
-
this.animations.splice(n, 1);
|
|
167
|
-
break;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
static _runFrames() {
|
|
173
|
-
const layerHash = {};
|
|
174
|
-
const animations = this.animations;
|
|
175
|
-
/*
|
|
176
|
-
* loop through all animations and execute animation
|
|
177
|
-
* function. if the animation object has specified node,
|
|
178
|
-
* we can add the node to the nodes hash to eliminate
|
|
179
|
-
* drawing the same node multiple times. The node property
|
|
180
|
-
* can be the stage itself or a layer
|
|
181
|
-
*/
|
|
182
|
-
/*
|
|
183
|
-
* WARNING: don't cache animations.length because it could change while
|
|
184
|
-
* the for loop is running, causing a JS error
|
|
185
|
-
*/
|
|
186
|
-
|
|
187
|
-
for (let n = 0; n < animations.length; n++) {
|
|
188
|
-
const anim = animations[n];
|
|
189
|
-
const layers = anim.layers;
|
|
190
|
-
const func = anim.func;
|
|
191
|
-
|
|
192
|
-
anim._updateFrameObject(now());
|
|
193
|
-
const layersLen = layers.length;
|
|
194
|
-
|
|
195
|
-
// if animation object has a function, execute it
|
|
196
|
-
let needRedraw;
|
|
197
|
-
if (func) {
|
|
198
|
-
// allow anim bypassing drawing
|
|
199
|
-
needRedraw = func.call(anim, anim.frame) !== false;
|
|
200
|
-
} else {
|
|
201
|
-
needRedraw = true;
|
|
202
|
-
}
|
|
203
|
-
if (!needRedraw) {
|
|
204
|
-
continue;
|
|
205
|
-
}
|
|
206
|
-
for (let i = 0; i < layersLen; i++) {
|
|
207
|
-
const layer = layers[i];
|
|
208
|
-
|
|
209
|
-
if (layer._id !== undefined) {
|
|
210
|
-
layerHash[layer._id] = layer;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
for (const key in layerHash) {
|
|
216
|
-
if (!layerHash.hasOwnProperty(key)) {
|
|
217
|
-
continue;
|
|
218
|
-
}
|
|
219
|
-
layerHash[key].batchDraw();
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
static _animationLoop() {
|
|
223
|
-
const Anim = Animation;
|
|
224
|
-
if (Anim.animations.length) {
|
|
225
|
-
Anim._runFrames();
|
|
226
|
-
Util.requestAnimFrame(Anim._animationLoop);
|
|
227
|
-
} else {
|
|
228
|
-
Anim.animRunning = false;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
static _handleAnimation() {
|
|
232
|
-
if (!this.animRunning) {
|
|
233
|
-
this.animRunning = true;
|
|
234
|
-
Util.requestAnimFrame(this._animationLoop);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
}
|