-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathp5.anims.js
More file actions
736 lines (683 loc) · 30 KB
/
p5.anims.js
File metadata and controls
736 lines (683 loc) · 30 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.animS = {}));
}(this, (function (exports) { 'use strict';
/**
* Utility classes for p5.animS.
*/
/**
* A simple vertex. Similar to the vertex() function of p5.js.
*/
class Vertex {
/**
* @param {!number} x x-coordinate.
* @param {!number} y y-coordinate.
*/
constructor(x, y) {
this.x = x;
this.y = y;
}
}
/**
* A vertex to define a cubic Bezier curve. Similar to the bezierVertex()
* function of p5.js.
*/
class BezierVertex {
/**
* @param {!number} x2 x-coordinate for the first control point.
* @param {!number} y2 y-coordinate for the first control point.
* @param {!number} x3 x-coordinate for the second control point.
* @param {!number} y3 y-coordinate for the second control point.
* @param {!number} x4 x-coordinate for the anchor point.
* @param {!number} y4 y-coordinate for the anchor point.
*/
constructor(x2, y2, x3, y3, x4, y4) {
this.x2 = x2;
this.y2 = y2;
this.x3 = x3;
this.y3 = y3;
this.x4 = x4;
this.y4 = y4;
}
}
/**
* Eight coordinate numbers to define a cubic Bezier curve.
*/
class BezierCurve {
/**
* @param {!number} x1 x-coordinate for the first anchor point.
* @param {!number} y1 y-coordinate for the first anchor point.
* @param {!number} x2 x-coordinate for the first control point.
* @param {!number} y2 y-coordinate for the first control point.
* @param {!number} x3 x-coordinate for the second control point.
* @param {!number} y3 y-coordinate for the second control point.
* @param {!number} x4 x-coordinate for the second anchor point.
* @param {!number} y4 y-coordinate for the second anchor point.
*/
constructor(x1, y1, x2, y2, x3, y3, x4, y4) {
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
this.x3 = x3;
this.y3 = y3;
this.x4 = x4;
this.y4 = y4;
}
/**
* Constructs an instance from a Vertex and a BezierVertex.
* @param {!Vertex} startVertex The first anchor point.
* @param {!BezierVertex} bezierVertex The two control points and the
* second anchor point.
*/
static fromVetices(startVertex, bezierVertex) {
return new BezierCurve(
startVertex.x,
startVertex.y,
bezierVertex.x2,
bezierVertex.y2,
bezierVertex.x3,
bezierVertex.y3,
bezierVertex.x4,
bezierVertex.y4);
}
}
/**
* Gets the end point of a vertex. If the input is a Bezier vertex, its anchor
* point is returned. If the input is a simple vertex, the input itself is
* returned.
* @param {!Vertex|BezierVertex} vertex The input vertex.
* @returns {Vertex} The end point.
*/
function getEndPoint(vertex) {
if (vertex instanceof Vertex)
return new Vertex(vertex.x, vertex.y);
else
return new Vertex(vertex.x4, vertex.y4);
}
/**
* Generates a new cubic Bezier curve which is a partial segment of the
* given cubic Bezier curve.
*
* See https://stackoverflow.com/questions/878862/
* and https://en.wikipedia.org/wiki/De_Casteljau%27s_algorithm
* for the algorithm to break a Bezier curve into segments.
*
* @param {!BezierCurve} bezierCurve The original Bezier curve.
* @param {!number} t0 The start (in a ratio value, 0-1) of the segment.
* @param {!number} t1 The end (in a ratio value, 0-1) of the segment.
* @returns {BezierCurve} The generated partial Bezier curve.
*/
function partialBezierCurve(bezierCurve, t0, t1) {
const u0 = 1.0 - t0;
const u1 = 1.0 - t1;
const qxa = bezierCurve.x1 * u0 * u0 + bezierCurve.x2 * 2 * t0 * u0 + bezierCurve.x3 * t0 * t0;
const qxb = bezierCurve.x1 * u1 * u1 + bezierCurve.x2 * 2 * t1 * u1 + bezierCurve.x3 * t1 * t1;
const qxc = bezierCurve.x2 * u0 * u0 + bezierCurve.x3 * 2 * t0 * u0 + bezierCurve.x4 * t0 * t0;
const qxd = bezierCurve.x2 * u1 * u1 + bezierCurve.x3 * 2 * t1 * u1 + bezierCurve.x4 * t1 * t1;
const qya = bezierCurve.y1 * u0 * u0 + bezierCurve.y2 * 2 * t0 * u0 + bezierCurve.y3 * t0 * t0;
const qyb = bezierCurve.y1 * u1 * u1 + bezierCurve.y2 * 2 * t1 * u1 + bezierCurve.y3 * t1 * t1;
const qyc = bezierCurve.y2 * u0 * u0 + bezierCurve.y3 * 2 * t0 * u0 + bezierCurve.y4 * t0 * t0;
const qyd = bezierCurve.y2 * u1 * u1 + bezierCurve.y3 * 2 * t1 * u1 + bezierCurve.y4 * t1 * t1;
const xa = qxa * u0 + qxc * t0;
const xb = qxa * u1 + qxc * t1;
const xc = qxb * u0 + qxd * t0;
const xd = qxb * u1 + qxd * t1;
const ya = qya * u0 + qyc * t0;
const yb = qya * u1 + qyc * t1;
const yc = qyb * u0 + qyd * t0;
const yd = qyb * u1 + qyd * t1;
return new BezierCurve(xa, ya, xb, yb, xc, yc, xd, yd);
}
/**
* Generates a cubic Bezier representing an arc.
* @param {!number} start The angle to start the arc, in radians.
* @param {!number} size Total angle 'size', in radians.
* @returns {BezierCurve} The result curve.
*/
function arcToBezier(start, size) {
const alpha = size / 2.0;
const cosAlpha = Math.cos(alpha);
const sinAlpha = Math.sin(alpha);
const cotAlpha = 1.0 / Math.tan(alpha);
const phi = start + alpha;
const cosPhi = Math.cos(phi);
const sinPhi = Math.sin(phi);
const lambda = (4.0 - cosAlpha) / 3.0;
const mu = sinAlpha + (cosAlpha - lambda) * cotAlpha;
return new BezierCurve(
Math.cos(start).toFixed(7),
Math.sin(start).toFixed(7),
(lambda * cosPhi + mu * sinPhi).toFixed(7),
(lambda * sinPhi - mu * cosPhi).toFixed(7),
(lambda * cosPhi - mu * sinPhi).toFixed(7),
(lambda * sinPhi + mu * cosPhi).toFixed(7),
Math.cos(start + size).toFixed(7),
Math.sin(start + size).toFixed(7));
}
/**
* @fileoverview The Shape class which supports partial rendering.
*/
class Shape {
/**
* @param {!Object} p5obj The p5 instance of the global object.
* @param {!Array<Vertex|BezierVertex>} vertices The vertices that define
* the shape.
* @param {!number} startFrame The start frame number of the animation.
* @param {!number} duration The duration of the creation animation, in
* number of frames.
*/
constructor(p5obj, vertices, startFrame, duration) {
if (vertices.length <= 0)
throw new Error('The vertex array must not be empty.');
if (!(vertices[0] instanceof Vertex))
throw new Error('The start vertex must not be a Bezier vertex.');
this.p5obj = p5obj;
this.vertices = vertices;
this.startFrame = startFrame;
this.duration = duration;
}
/**
* Draws the shape instance on the current frame.
*/
update() {
let progress = (this.p5obj.frameCount - this.startFrame) / this.duration;
if (progress < 0) progress = 0;
if (progress > 1) progress = 1;
const numCurves = this.vertices.length - 1;
const progressOverCurves = numCurves * progress;
const currentCurveNo = Math.floor(progressOverCurves);
const currentCurveProgress = progressOverCurves - currentCurveNo;
this.p5obj.beginShape();
// The start point.
this.p5obj.vertex(this.vertices[0].x, this.vertices[0].y);
let lastPoint = getEndPoint(this.vertices[0]);
// Draws all the full curves.
for (let i = 0; i < currentCurveNo; i++) {
const v = this.vertices[i + 1];
if (v instanceof Vertex)
this.p5obj.vertex(v.x, v.y);
else
this.p5obj.bezierVertex(v.x2, v.y2, v.x3, v.y3, v.x4, v.y4);
lastPoint = getEndPoint(v);
}
// Draws the partial curve.
if (currentCurveNo < numCurves) {
const v = this.vertices[currentCurveNo + 1];
if (v instanceof Vertex) {
const x1 = lastPoint.x + (v.x - lastPoint.x) * currentCurveProgress;
const y1 = lastPoint.y + (v.y - lastPoint.y) * currentCurveProgress;
this.p5obj.vertex(x1, y1);
} else {
const currentCurve = BezierCurve.fromVetices(lastPoint, v);
const partial = partialBezierCurve(currentCurve, 0, currentCurveProgress);
this.p5obj.bezierVertex(partial.x2, partial.y2, partial.x3, partial.y3, partial.x4, partial.y4);
}
}
if (progress >= 1 && this.vertices.length > 1 &&
this.vertices[this.vertices.length - 1] instanceof Vertex &&
this.vertices[0].x == this.vertices[this.vertices.length - 1].x &&
this.vertices[0].y == this.vertices[this.vertices.length - 1].y) {
this.p5obj.endShape(this.p5obj.CLOSE);
} else {
this.p5obj.endShape();
}
}
}
/**
* @fileoverview Manages the animated shape instances and updates the animation
* effects per frame.
*/
class AnimShapes {
/**
* @param {Object} p5obj The instance of the p5 object.
*/
constructor(p5obj) {
this.p5obj = p5obj || window;
/**
* @type {Map<string, Shape>}
* @private
*/
this.instances_ = new Map();
/**
* @type {Set<string>}
* @private
*/
this.dedup_ = new Set();
}
/**
* Checks if the animation instance exists. Returns the object if it exists.
* Creates and returns a new instance if it does not exist.
* @param {!string} id A unique string ID of the animation. The animation is
* showed during multiple frames, so that there must be an ID for the
* renderer to keep track of each animation instance.
* @param {!Function} getShapeVertices A lazy-executed closure that returns
* the shape vertices, for creating the new shape instance.
* @param {!number} duration The duration of the creation animation, in
* number of frames, for creating the new instance.
* @private
*/
getOrCreateShapeInstance_(id, getShapeVertices, duration) {
if (this.checkDuplicateId_(id)) {
throw new Error('AnimS id must not be duplicate in the same p5.js frame.');
}
if (this.instances_.has(id)) {
return this.instances_.get(id);
}
else {
const instance = new Shape(this.p5obj, getShapeVertices(), this.p5obj.frameCount, duration);
this.instances_.set(id, instance);
return instance;
}
}
/**
* Checks if the id is duplicate for the current frame. Duplicate IDs may
* occur in different frames, but not in the same frame.
* @param {string} id
* @private
*/
checkDuplicateId_(id) {
let key = id + '@' + this.p5obj.frameCount;
if (this.dedup_.has(key)) {
return true;
} else {
this.dedup_.add(key);
return false;
}
}
/**
* Removes all the cached shape animation instances so that new shape
* creations result in new animations.
*/
reset() {
this.instances_.clear();
this.dedup_.clear();
}
/**
* Draws an arc while playing its creation animation. The arc mode is always
* OPEN. The elipse mode is always CENTER.
* @param {!string} id A unique string ID to identify the shape animation.
* @param {!number} duration The duration of the creation animation, in
* number of frames.
* @param {!Number} x The x-coordinate of the arc's ellipse.
* @param {!Number} y The y-coordinate of the arc's ellipse.
* @param {!Number} w The width of the arc's ellipse by default.
* @param {!Number} h The height of the arc's ellipse by default.
* @param {!Number} start The angle to start the arc, in radians.
* @param {!Number} stop The angle to stop the arc, in radians.
*/
arc(id, duration, x, y, w, h, start, stop) {
const epsilon = 0.00001;
if (start >= stop || stop - start < epsilon)
return;
const createShapeVertices = () => {
x = x - w * 0.5;
y = y - h * 0.5;
w = Math.abs(w);
h = Math.abs(h);
const rx = w / 2.0;
const ry = h / 2.0;
let arcToDraw = 0;
x += rx;
y += ry;
const curves = [];
while (stop - start >= epsilon) {
arcToDraw = Math.min(stop - start, Math.PI / 2);
curves.push(arcToBezier(start, arcToDraw));
start += arcToDraw;
}
const shapeVertices = [];
curves.forEach((curve, index) => {
if (index === 0)
shapeVertices.push(new Vertex(x + curve.x1 * rx, y + curve.y1 * ry));
shapeVertices.push(new BezierVertex(
x + curve.x2 * rx, y + curve.y2 * ry,
x + curve.x3 * rx, y + curve.y3 * ry,
x + curve.x4 * rx, y + curve.y4 * ry));
});
return shapeVertices;
};
const instance = this.getOrCreateShapeInstance_(id, createShapeVertices, duration);
instance.update();
}
/**
* Draws an elipse (oval) while playing its creation animation. The elipse
* mode is always CENTER.
* @param {!string} id A unique string ID to identify the shape animation.
* @param {!number} duration The duration of the creation animation, in
* number of frames.
* @param {!number} x The x-coordinate of the center of ellipse.
* @param {!number} y The y-coordinate of the center of ellipse.
* @param {!number} w The width of the ellipse.
* @param {!number} h The height of the ellipse.
*/
ellipse(id, duration, x, y, w, h) {
const instance = this.getOrCreateShapeInstance_(id, () => {
x = x - w * 0.5;
y = y - h * 0.5;
w = Math.abs(w);
h = Math.abs(h);
const kappa = 0.5522847498,
ox = w / 2 * kappa, oy = h / 2 * kappa,
xe = x + w, ye = y + h,
xm = x + w / 2, ym = y + h / 2;
return [
new Vertex(x, ym),
new BezierVertex(x, ym - oy, xm - ox, y, xm, y),
new BezierVertex(xm + ox, y, xe, ym - oy, xe, ym),
new BezierVertex(xe, ym + oy, xm + ox, ye, xm, ye),
new BezierVertex(xm - ox, ye, x, ym + oy, x, ym),
];
}, duration);
instance.update();
}
/**
* Draws a circle while playing its creation animation.
* @param {!string} id A unique string ID to identify the shape animation.
* @param {!number} duration The duration of the creation animation, in
* number of frames.
* @param {!number} x The x-coordinate of the centre of the circle.
* @param {!number} y The y-coordinate of the centre of the circle.
* @param {!number} d The diameter of the circle.
*/
circle(id, duration, x, y, d) {
d = Math.abs(d);
this.ellipse(id, duration, x, y, d, d);
}
/**
* Draws a line while playing its creation animation.
* @param {!string} id A unique string ID to identify the shape animation.
* @param {!number} duration The duration of the creation animation, in
* number of frames.
* @param {!number} x1 The x-coordinate of the first point.
* @param {!number} y1 The y-coordinate of the first point.
* @param {!number} x2 The x-coordinate of the second point.
* @param {!number} y2 The y-coordinate of the second point.
*/
line(id, duration, x1, y1, x2, y2) {
const instance = this.getOrCreateShapeInstance_(id, () => {
return [new Vertex(x1, y1), new Vertex(x2, y2)];
}, duration);
instance.update();
}
/**
* Draws a quad while playing its creation animation.
* @param {!string} id A unique string ID to identify the shape animation.
* @param {!number} duration The duration of the creation animation, in
* number of frames.
* @param {!number} x1 The x-coordinate of the first point.
* @param {!number} y1 The y-coordinate of the first point.
* @param {!number} x2 The x-coordinate of the second point.
* @param {!number} y2 The y-coordinate of the second point.
* @param {!number} x3 The x-coordinate of the third point.
* @param {!number} y3 The y-coordinate of the third point.
* @param {!number} x4 The x-coordinate of the fourth point.
* @param {!number} y4 The y-coordinate of the fourth point.
*/
quad(id, duration, x1, y1, x2, y2, x3, y3, x4, y4) {
const instance = this.getOrCreateShapeInstance_(id, () => {
return [new Vertex(x1, y1), new Vertex(x2, y2),
new Vertex(x3, y3), new Vertex(x4, y4),
new Vertex(x1, y1)];
}, duration);
instance.update();
}
/**
* Draws a rectangle while playing its creation animation.
* @param {!string} id A unique string ID to identify the shape animation.
* @param {!number} duration The duration of the creation animation, in
* number of frames.
* @param {!number} x The x-coordinate of the rectangle.
* @param {!number} y The y-coordinate of the rectangle.
* @param {!number} w The width of the rectangle.
* @param {!number} h The height of the rectangle.
*/
rect(id, duration, x, y, w, h) {
w = Math.abs(w);
h = Math.abs(h);
this.quad(id, duration, x, y, x + w, y, x + w, y + h, x, y + h);
}
/**
* Draws a square while playing its creation animation.
* @param {!string} id A unique string ID to identify the shape animation.
* @param {!number} duration The duration of the creation animation, in
* number of frames.
* @param {!number} x The x-coordinate of the square.
* @param {!number} y The y-coordinate of the square.
* @param {!number} s The side size of the square.
*/
square(id, duration, x, y, s) {
s = Math.abs(s);
this.rect(id, duration, x, y, s, s);
}
/**
* Draws a triangle while playing its creation animation.
* @param {!string} id A unique string ID to identify the shape animation.
* @param {!number} duration The duration of the creation animation, in
* number of frames.
* @param {!number} x1 The x-coordinate of the first point.
* @param {!number} y1 The y-coordinate of the first point.
* @param {!number} x2 The x-coordinate of the second point.
* @param {!number} y2 The y-coordinate of the second point.
* @param {!number} x3 The x-coordinate of the third point.
* @param {!number} y3 The y-coordinate of the third point.
*/
triangle(id, duration, x1, y1, x2, y2, x3, y3) {
const instance = this.getOrCreateShapeInstance_(id, () => {
return [new Vertex(x1, y1), new Vertex(x2, y2),
new Vertex(x3, y3), new Vertex(x1, y1)];
}, duration);
instance.update();
}
/**
* Draws a shape while playing its creation animation. The shape is always
* OPEN unless the first vertex and the last vertex are equal.
* @param {!string} id A unique string ID to identify the shape animation.
* @param {!number} duration The duration of the creation animation, in
* number of frames.
* @param {!Array<Array<number>>} vertices The vertices that define the
* shape. Each element of the array may contain eithr two coordinate
* numbers (for simple vertices) or six coordinate numbers (for Bezier
* vertices).
*/
shape(id, duration, vertices) {
const instance = this.getOrCreateShapeInstance_(id, () => {
const shapeVertices = [];
for (const v of vertices) {
if (v.length == 2) {
shapeVertices.push(new Vertex(v[0], v[1]));
} else if (v.length == 6) {
shapeVertices.push(new BezierVertex(v[0], v[1], v[2], v[3], v[4], v[5]));
} else {
throw new Error('Only simple vertices (x, y) or Bezier vertices' +
' (x2, y2, x3, y3, x4, y4) are supported.');
}
}
return shapeVertices;
}, duration);
instance.update();
}
}
/**
* @fileoverview The main entry of the p5.animS lib.
*/
/**
* The default instance to access the animS functions.
*/
const defaultAnimS = new AnimShapes();
/**
* Activates the "instance mode" and associates a new animS instance with the
* specified p5 object. See p5() of p5.js for more details.
* @param {Object} p5obj The instance of the p5 object.
* @returns {Object} The animS instance.
*/
function newAnimS(p5obj) {
return new AnimShapes(p5obj);
}
/**
* 'Global' adapter of AnimShapes.reset
*
* Removes all the cached shape animation instances so that new shape
* creations result in new animations.
*/
function reset() {
defaultAnimS.reset();
}
/**
* 'Global' adapter of AnimShapes.arc
*
* Draws an arc while playing its creation animation. The arc mode is always
* OPEN. The elipse mode is always CENTER.
* @param {!string} id A unique string ID to identify the shape animation.
* @param {!number} duration The duration of the creation animation, in
* number of frames.
* @param {!Number} x The x-coordinate of the arc's ellipse.
* @param {!Number} y The y-coordinate of the arc's ellipse.
* @param {!Number} w The width of the arc's ellipse by default.
* @param {!Number} h The height of the arc's ellipse by default.
* @param {!Number} start The angle to start the arc, in radians.
* @param {!Number} stop The angle to stop the arc, in radians.
*/
function arc(id, duration, x, y, w, h, start, stop) {
defaultAnimS.arc(id, duration, x, y, w, h, start, stop);
}
/**
* 'Global' adapter of AnimShapes.ellipse
*
* Draws an elipse (oval) while playing its creation animation. The elipse
* mode is always CENTER.
* @param {!string} id A unique string ID to identify the shape animation.
* @param {!number} duration The duration of the creation animation, in
* number of frames.
* @param {!number} x The x-coordinate of the center of ellipse.
* @param {!number} y The y-coordinate of the center of ellipse.
* @param {!number} w The width of the ellipse.
* @param {!number} h The height of the ellipse.
*/
function ellipse(id, duration, x, y, w, h) {
defaultAnimS.ellipse(id, duration, x, y, w, h);
}
/**
* 'Global' adapter of AnimShapes.circle
*
* Draws a circle while playing its creation animation.
* @param {!string} id A unique string ID to identify the shape animation.
* @param {!number} duration The duration of the creation animation, in
* number of frames.
* @param {!number} x The x-coordinate of the centre of the circle.
* @param {!number} y The y-coordinate of the centre of the circle.
* @param {!number} d The diameter of the circle.
*/
function circle(id, duration, x, y, d) {
defaultAnimS.circle(id, duration, x, y, d);
}
/**
* 'Global' adapter of AnimShapes.line
*
* Draws a line while playing its creation animation.
* @param {!string} id A unique string ID to identify the shape animation.
* @param {!number} duration The duration of the creation animation, in
* number of frames.
* @param {!number} x1 The x-coordinate of the first point.
* @param {!number} y1 The y-coordinate of the first point.
* @param {!number} x2 The x-coordinate of the second point.
* @param {!number} y2 The y-coordinate of the second point.
*/
function line(id, duration, x1, y1, x2, y2) {
defaultAnimS.line(id, duration, x1, y1, x2, y2);
}
/**
* 'Global' adapter of AnimShapes.quad
*
* Draws a quad while playing its creation animation.
* @param {!string} id A unique string ID to identify the shape animation.
* @param {!number} duration The duration of the creation animation, in
* number of frames.
* @param {!number} x1 The x-coordinate of the first point.
* @param {!number} y1 The y-coordinate of the first point.
* @param {!number} x2 The x-coordinate of the second point.
* @param {!number} y2 The y-coordinate of the second point.
* @param {!number} x3 The x-coordinate of the third point.
* @param {!number} y3 The y-coordinate of the third point.
* @param {!number} x4 The x-coordinate of the fourth point.
* @param {!number} y4 The y-coordinate of the fourth point.
*/
function quad(id, duration, x1, y1, x2, y2, x3, y3, x4, y4) {
defaultAnimS.quad(id, duration, x1, y1, x2, y2, x3, y3, x4, y4);
}
/**
* 'Global' adapter of AnimShapes.rect
*
* Draws a rectangle while playing its creation animation.
* @param {!string} id A unique string ID to identify the shape animation.
* @param {!number} duration The duration of the creation animation, in
* number of frames.
* @param {!number} x The x-coordinate of the rectangle.
* @param {!number} y The y-coordinate of the rectangle.
* @param {!number} w The width of the rectangle.
* @param {!number} h The height of the rectangle.
*/
function rect(id, duration, x, y, w, h) {
defaultAnimS.rect(id, duration, x, y, w, h);
}
/**
* 'Global' adapter of AnimShapes.square
*
* Draws a square while playing its creation animation.
* @param {!string} id A unique string ID to identify the shape animation.
* @param {!number} duration The duration of the creation animation, in
* number of frames.
* @param {!number} x The x-coordinate of the square.
* @param {!number} y The y-coordinate of the square.
* @param {!number} s The side size of the square.
*/
function square(id, duration, x, y, s) {
defaultAnimS.square(id, duration, x, y, s);
}
/**
* 'Global' adapter of AnimShapes.triangle
*
* Draws a triangle while playing its creation animation.
* @param {!string} id A unique string ID to identify the shape animation.
* @param {!number} duration The duration of the creation animation, in
* number of frames.
* @param {!number} x1 The x-coordinate of the first point.
* @param {!number} y1 The y-coordinate of the first point.
* @param {!number} x2 The x-coordinate of the second point.
* @param {!number} y2 The y-coordinate of the second point.
* @param {!number} x3 The x-coordinate of the third point.
* @param {!number} y3 The y-coordinate of the third point.
*/
function triangle(id, duration, x1, y1, x2, y2, x3, y3) {
defaultAnimS.triangle(id, duration, x1, y1, x2, y2, x3, y3);
}
/**
* 'Global' adapter of AnimShapes.shape
*
* Draws a shape while playing its creation animation. The shape is always
* OPEN unless the first vertex and the last vertex are equal.
* @param {!string} id A unique string ID to identify the shape animation.
* @param {!number} duration The duration of the creation animation, in
* number of frames.
* @param {!Array<Array<number>>} vertices The vertices that define the
* shape. Each element of the array may contain eithr two coordinate
* numbers (for simple vertices) or six coordinate numbers (for Bezier
* vertices).
*/
function shape(id, duration, vertices) {
defaultAnimS.shape(id, duration, vertices);
}
exports.arc = arc;
exports.circle = circle;
exports.ellipse = ellipse;
exports.line = line;
exports.newAnimS = newAnimS;
exports.quad = quad;
exports.rect = rect;
exports.reset = reset;
exports.shape = shape;
exports.square = square;
exports.triangle = triangle;
Object.defineProperty(exports, '__esModule', { value: true });
})));