-
-
Notifications
You must be signed in to change notification settings - Fork 455
/
types.d.ts
4814 lines (4780 loc) · 167 KB
/
types.d.ts
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
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
declare module 'two.js/src/utils/path-commands' {
export interface Commands {
move: 'M';
line: 'L';
curve: 'C';
arc: 'A';
close: 'Z';
}
}
declare module 'two.js/src/utils/root' {
export let root: any;
}
declare module 'two.js/src/utils/math' {
/**
* @name Two.Utils.decomposeMatrix
* @function
* @param {Matrix} matrix - The matrix to decompose.
* @returns {Object} An object containing relevant skew values.
* @description Decompose a 2D 3x3 Matrix to find the skew.
*/
export function decomposeMatrix(matrix: Matrix): any;
export function decomposeMatrix(
a: number,
b: number,
c: number,
d: number,
e: number,
f: number
): any;
/**
* @name Two.Utils.getComputedMatrix
* @function
* @param {Shape} object - The Two.js object that has a matrix property to calculate from.
* @param {Matrix} [matrix] - The matrix to apply calculated transformations to if available.
* @returns {Matrix} The computed matrix of a nested object. If no `matrix` was passed in arguments then a `new Two.Matrix` is returned.
* @description Method to get the world space transformation of a given object in a Two.js scene.
*/
export function getComputedMatrix(object: Shape, matrix?: Matrix): Matrix;
export function getPoT(value: any): number;
export function setMatrix(matrix: any): void;
/**
* @name Two.Utils.lerp
* @function
* @param {Number} a - Start value.
* @param {Number} b - End value.
* @param {Number} t - Zero-to-one value describing percentage between a and b.
* @returns {Number}
* @description Linear interpolation between two values `a` and `b` by an amount `t`.
*/
export function lerp(a: number, b: number, t: number): number;
/**
* @name Two.Utils.mod
* @function
* @param {Number} v - The value to modulo
* @param {Number} l - The value to modulo by
* @returns {Number}
* @description Modulo with added functionality to handle negative values in a positive manner.
*/
export function mod(v: number, l: number): number;
export const NumArray: any;
/**
* @name Two.Utils.toFixed
* @function
* @param {Number} v - Any float
* @returns {Number} That float trimmed to the third decimal place.
* @description A pretty fast toFixed(3) alternative.
* @see {@link http://jsperf.com/parsefloat-tofixed-vs-math-round/18}
*/
export function toFixed(v: number): number;
export const TWO_PI: number;
export const HALF_PI: number;
import { Matrix } from 'two.js/src/matrix';
import { Shape } from 'two.js/src/shape';
}
declare module 'two.js/src/events' {
/**
* @name Two.Events
* @class
* @description Object inherited by many Two.js objects in order to facilitate custom events.
*/
export class Events {
/**
* @name Two.Events.Types
* @property {Object} - Object of different types of Two.js specific events.
*/
static Types: {
play: string;
pause: string;
update: string;
render: string;
resize: string;
change: string;
remove: string;
insert: string;
order: string;
load: string;
};
static Methods: string[];
_events: {};
_bound: boolean;
/**
* @name Two.Events#addEventListener
* @function
* @param {String} [name] - The name of the event to bind a function to.
* @param {Function} [handler] - The function to be invoked when the event is dispatched.
* @description Call to add a listener to a specific event name.
*/
addEventListener(name?: string, handler?: Function): Events;
/**
* @name Two.Events#on
* @function
* @description Alias for {@link Two.Events#addEventListener}.
*/
on(...args: any[]): any;
/**
* @name Two.Events#bind
* @function
* @description Alias for {@link Two.Events#addEventListener}.
*/
bind(...args: any[]): any;
/**
* @name Two.Events#removeEventListener
* @function
* @param {String} [name] - The name of the event intended to be removed.
* @param {Function} [handler] - The handler intended to be reomved.
* @description Call to remove listeners from a specific event. If only `name` is passed then all the handlers attached to that `name` will be removed. If no arguments are passed then all handlers for every event on the obejct are removed.
*/
removeEventListener(name?: string, handler?: Function): Events;
/**
* @name Two.Events#off
* @function
* @description Alias for {@link Two.Events#removeEventListener}.
*/
off(...args: any[]): any;
/**
* @name Two.Events#unbind
* @function
* @description Alias for {@link Two.Events#removeEventListener}.
*/
unbind(...args: any[]): any;
/**
* @name Two.Events#dispatchEvent
* @function
* @param {String} name - The name of the event to dispatch.
* @param args - Anything can be passed after the name and those will be passed on to handlers attached to the event in the order they are passed.
* @description Call to trigger a custom event. Any additional arguments passed after the name will be passed along to the attached handlers.
*/
dispatchEvent(name: string, ...args: any[]): Events;
trigger(...args: any[]): any;
listen(obj: any, name: any, handler: any): Events;
ignore(obj: any, name: any, handler: any): Events;
}
}
declare module 'two.js/src/vector' {
/**
* @name Two.Vector
* @class
* @param {Number} [x=0] - Any number to represent the horizontal x-component of the vector.
* @param {Number} [y=0] - Any number to represent the vertical y-component of the vector.
* @description A class to store x / y component vector data. In addition to storing data `Two.Vector` has suped up methods for commonplace mathematical operations.
*/
export class Vector extends Events {
/**
* @name Two.Vector.zero
* @readonly
* @property {Vector} - Handy reference to a vector with component values 0, 0 at all times.
*/
static readonly zero: Vector;
/**
* @name Two.Vector.add
* @function
* @param {Vector} v1
* @param {Vector} v2
* @returns {Vector}
* @description Add two vectors together.
*/
static add(v1: Vector, v2: Vector): Vector;
/**
* @name Two.Vector.sub
* @function
* @param {Vector} v1
* @param {Vector} v2
* @returns {Vector}
* @description Subtract two vectors: `v2` from `v1`.
*/
static sub(v1: Vector, v2: Vector): Vector;
/**
* @name Two.Vector.subtract
* @function
* @description Alias for {@link Two.Vector.sub}.
*/
static subtract(v1: Vector, v2: Vector): Vector;
/**
* @name Two.Vector.ratioBetween
* @function
* @param {Vector} v1
* @param {Vector} v2
* @returns {Number} The ratio betwen two points `v1` and `v2`.
*/
static ratioBetween(v1: Vector, v2: Vector): number;
/**
* @name Two.Vector.angleBetween
* @function
* @param {Vector} v1
* @param {Vector} v2
* @returns {Number} The angle between points `v1` and `v2`.
*/
static angleBetween(v1: Vector, v2: Vector): number;
static angleBetween(x1: number, y1: number, x2: number, y2: number): number;
/**
* @name Two.Vector.distanceBetween
* @function
* @param {Vector} v1
* @param {Vector} v2
* @returns {Number} The distance between points `v1` and `v2`. Distance is always positive.
*/
static distanceBetween(v1: Vector, v2: Vector): number;
/**
* @name Two.Vector.distanceBetweenSquared
* @function
* @param {Vector} v1
* @param {Vector} v2
* @returns {Number} The squared distance between points `v1` and `v2`.
*/
static distanceBetweenSquared(v1: Vector, v2: Vector): number;
constructor(x?: number, y?: number);
/**
* @name Two.Vector#_x
* @private
*/
private _x;
/**
* @name Two.Vector#_y
* @private
*/
private _y;
/**
* @name Two.Vector#x
* @property {Number} - The horizontal x-component of the vector.
* @type {Number}
*/
x: number;
/**
* @name Two.Vector#y
* @property {Number} - The vertical y-component of the vector.
* @type {Number}
*/
y: number;
set(x: number, y: number): Vector;
/**
* @name Two.Vector#copy
* @function
* @param {Vector} v
* @description Copy the x / y components of another object `v`.
*/
copy(v: Vector): Vector;
/**
* @name Two.Vector#clear
* @function
* @description Set the x / y component values of the vector to zero.
*/
clear(): Vector;
/**
* @name Two.Vector#clone
* @function
* @description Create a new vector and copy the existing values onto the newly created instance.
*/
clone(): Vector;
/**
* @name Two.Vector#add
* @function
* @param {Vector} v
* @description Add an object with x / y component values to the instance.
* @overloaded
*/
add(v: Vector): Vector;
/**
* @name Two.Vector#add
* @function
* @param {Number} v
* @description Add the **same** number to both x / y component values of the instance.
* @overloaded
*/
add(v: number): Vector;
/**
* @name Two.Vector#add
* @function
* @param {Number} x
* @param {Number} y
* @description Add `x` / `y` values to their respective component value on the instance.
* @overloaded
*/
add(x: number, y: number): Vector;
/**
* @name Two.Vector#addSelf
* @function
* @description Alias for {@link Two.Vector.add}.
*/
addSelf(x: number, y: number): Vector;
addSelf(v: Vector): Vector;
addSelf(v: number): Vector;
/**
* @name Two.Vector#sub
* @function
* @param {Vector} v
* @description Subtract an object with x / y component values to the instance.
* @overloaded
*/
sub(v: Vector): Vector;
/**
* @name Two.Vector#sub
* @function
* @param {Number} v
* @description Subtract the **same** number to both x / y component values of the instance.
* @overloaded
*/
sub(v: number): Vector;
/**
* @name Two.Vector#sub
* @function
* @param {Number} x
* @param {Number} y
* @description Subtract `x` / `y` values to their respective component value on the instance.
* @overloaded
*/
sub(x: number, y: number): Vector;
/**
* @name Two.Vector#subtract
* @function
* @description Alias for {@link Two.Vector.sub}.
*/
subtract(x: number, y: number): Vector;
subtract(v: number): Vector;
subtract(v: Vector): Vector;
/**
* @name Two.Vector#subSelf
* @function
* @description Alias for {@link Two.Vector.sub}.
*/
subSelf(x: number, y: number): Vector;
subSelf(v: number): Vector;
subSelf(v: Vector): Vector;
/**
* @name Two.Vector#subtractSelf
* @function
* @description Alias for {@link Two.Vector.sub}.
*/
subtractSelft(x: number, y: number): Vector;
subtractSelft(v: number): Vector;
subtractSelft(v: Vector): Vector;
/**
* @name Two.Vector#multiply
* @function
* @param {Vector} v
* @description Multiply an object with x / y component values to the instance.
* @overloaded
*/
multiply(v: number): Vector;
/**
* @name Two.Vector#multiply
* @function
* @param {Number} v
* @description Multiply the **same** number to both x / y component values of the instance.
* @overloaded
*/
multiply(v: Vector): Vector;
/**
* @name Two.Vector#multiply
* @function
* @param {Number} x
* @param {Number} y
* @description Multiply `x` / `y` values to their respective component value on the instance.
* @overloaded
*/
multiply(x: number, y: number): Vector;
/**
* @name Two.Vector#multiplySelf
* @function
* @description Alias for {@link Two.Vector.multiply}.
*/
multiplySelf(v: any, ...args: any[]): any;
/**
* @name Two.Vector#multiplyScalar
* @function
* @param {Number} s - The scalar to multiply by.
* @description Mulitiply the vector by a single number. Shorthand to call {@link Two.Vector#multiply} directly.
*/
multiplyScalar(s: number): Vector;
/**
* @name Two.Vector#divide
* @function
* @param {Vector} v
* @description Divide an object with x / y component values to the instance.
* @overloaded
*/
divide(v: Vector): Vector;
/**
* @name Two.Vector#divide
* @function
* @param {Number} v
* @description Divide the **same** number to both x / y component values of the instance.
* @overloaded
*/
divide(v: number): Vector;
/**
* @name Two.Vector#divide
* @function
* @param {Number} x
* @param {Number} y
* @description Divide `x` / `y` values to their respective component value on the instance.
* @overloaded
*/
divide(x: number, y: number): Vector;
/**
* @name Two.Vector#divideSelf
* @function
* @description Alias for {@link Two.Vector.divide}.
*/
divideSelf(x: number, y: number): Vector;
divideSelf(v: number): Vector;
divideSelf(v: Vector): Vector;
/**
* @name Two.Vector#divideScalar
* @function
* @param {Number} s - The scalar to divide by.
* @description Divide the vector by a single number. Shorthand to call {@link Two.Vector#divide} directly.
*/
divideScalar(s: number): Vector;
/**
* @name Two.Vector#negate
* @function
* @description Invert each component's sign value.
*/
negate(): Vector;
/**
* @name Two.Vector#negate
* @function
* @returns {Number}
* @description Get the [dot product](https://en.wikipedia.org/wiki/Dot_product) of the vector.
*/
dot(v: Vector): number;
/**
* @name Two.Vector#length
* @function
* @returns {Number}
* @description Get the length of a vector.
*/
length(): number;
/**
* @name Two.Vector#lengthSquared
* @function
* @returns {Number}
* @description Get the length of the vector to the power of two. Widely used as less expensive than {@link Two.Vector#length} because it isn't square-rooting any numbers.
*/
lengthSquared(): number;
/**
* @name Two.Vector#normalize
* @function
* @description Normalize the vector from negative one to one.
*/
normalize(): Vector;
/**
* @name Two.Vector#distanceTo
* @function
* @returns {Number}
* @description Get the distance between two vectors.
*/
distanceTo(v: any): number;
/**
* @name Two.Vector#distanceToSquared
* @function
* @returns {Number}
* @description Get the distance between two vectors to the power of two. Widely used as less expensive than {@link Two.Vector#distanceTo} because it isn't square-rooting any numbers.
*/
distanceToSquared(v: Vector): number;
/**
* @name Two.Vector#setLength
* @function
* @param {Number} l - length to set vector to.
* @description Set the length of a vector.
*/
setLength(l: number): Vector;
/**
* @name Two.Vector#equals
* @function
* @param {Vector} v - The vector to compare against.
* @param {Number} [eps=0.0001] - An options epsilon for precision.
* @returns {Boolean}
* @description Qualify if one vector roughly equal another. With a margin of error defined by epsilon.
*/
equals(v: Vector, eps?: number): boolean;
/**
* @name Two.Vector#lerp
* @function
* @param {Vector} v - The destination vector to step towards.
* @param {Number} t - The zero to one value of how close the current vector gets to the destination vector.
* @description Linear interpolate one vector to another by an amount `t` defined as a zero to one number.
* @see [Matt DesLauriers](https://twitter.com/mattdesl/status/1031305279227478016) has a good thread about this.
*/
lerp(v: Vector, t: number): Vector;
/**
* @name Two.Vector#isZero
* @function
* @param {Number} [eps=0.0001] - Optional precision amount to check against.
* @returns {Boolean}
* @description Check to see if vector is roughly zero, based on the `epsilon` precision value.
*/
isZero(eps?: number): boolean;
/**
* @name Two.Vector#toObject
* @function
* @returns {Object}
* @description Return a JSON compatible plain object that represents the vector.
*/
toObject(): any;
/**
* @name Two.Vector#rotate
* @function
* @param {Number} radians - The amount to rotate the vector by in radians.
* @description Rotate a vector.
*/
rotate(radians: number): Vector;
}
import { Events } from 'two.js/src/events';
}
declare module 'two.js/src/anchor' {
/**
* @class
* @name Two.Anchor
* @param {Number} [x=0] - The x position of the root anchor point.
* @param {Number} [y=0] - The y position of the root anchor point.
* @param {Number} [ax=0] - The x position of the left handle point.
* @param {Number} [ay=0] - The y position of the left handle point.
* @param {Number} [bx=0] - The x position of the right handle point.
* @param {Number} [by=0] - The y position of the right handle point.
* @param {String} [command=Two.Commands.move] - The command to describe how to render. Applicable commands are {@link Two.Commands}
* @description An object that holds 3 {@link Two.Vector}s, the anchor point and its corresponding handles: `left` and `right`. In order to properly describe the bezier curve about the point there is also a command property to describe what type of drawing should occur when Two.js renders the anchors.
*/
export class Anchor extends Vector {
static makeBroadcast(scope: any): () => void;
constructor(
x?: number,
y?: number,
ax?: number,
ay?: number,
bx?: number,
by?: number,
command?: string
);
controls: {
left: Vector;
right: Vector;
};
_command: string;
_relative: boolean;
_rx: number;
_ry: number;
_xAxisRotation: number;
_largeArcFlag: number;
_sweepFlag: number;
command: string;
relative: boolean;
rx: any;
ry: any;
xAxisRotation: any;
largeArcFlag: any;
sweepFlag: any;
}
import { Vector } from 'two.js/src/vector';
}
declare module 'two.js/src/constants' {
export interface Constants {
nextFrameID: number;
Types: {
webgl: string;
svg: string;
canvas: string;
};
Version: string;
PublishDate: string;
Identifier: string;
Resolution: number;
AutoCalculateImportedMatrices: boolean;
Instances: any[];
uniqueId(): number;
}
}
declare module 'two.js/src/utils/curves' {
export interface Curve {
CollinearityEpsilon: number;
RecursionLimit: number;
CuspLimit: number;
Tolerance: {
distance: number;
angle: number;
epsilon: number;
};
abscissas: number[][];
weights: number[][];
}
/**
* @name Two.Utils.getComponentOnCubicBezier
* @function
* @param {Number} t - Zero-to-one value describing what percentage to calculate.
* @param {Number} a - The firt point's component value.
* @param {Number} b - The first point's bezier component value.
* @param {Number} c - The second point's bezier component value.
* @param {Number} d - The second point's component value.
* @returns {Number} The coordinate value for a specific component along a cubic bezier curve by `t`.
*/
export function getComponentOnCubicBezier(
t: number,
a: number,
b: number,
c: number,
d: number
): number;
/**
* @name Two.Utils.subdivide
* @function
* @param {Number} x1 - x position of first anchor point.
* @param {Number} y1 - y position of first anchor point.
* @param {Number} x2 - x position of first anchor point's "right" bezier handle.
* @param {Number} y2 - y position of first anchor point's "right" bezier handle.
* @param {Number} x3 - x position of second anchor point's "left" bezier handle.
* @param {Number} y3 - y position of second anchor point's "left" bezier handle.
* @param {Number} x4 - x position of second anchor point.
* @param {Number} y4 - y position of second anchor point.
* @param {Number} [limit=Two.Utils.Curve.RecursionLimit] - The amount of vertices to create by subdividing.
* @returns {Anchor[]} A list of anchor points ordered in between `x1`, `y1` and `x4`, `y4`
* @description Given 2 points (a, b) and corresponding control point for each return an array of points that represent points plotted along the curve. The number of returned points is determined by `limit`.
*/
export function subdivide(
x1: number,
y1: number,
x2: number,
y2: number,
x3: number,
y3: number,
x4: number,
y4: number,
limit?: number
): Anchor[];
/**
* @name Two.Utils.getCurveLength
* @function
* @param {Number} x1 - x position of first anchor point.
* @param {Number} y1 - y position of first anchor point.
* @param {Number} x2 - x position of first anchor point's "right" bezier handle.
* @param {Number} y2 - y position of first anchor point's "right" bezier handle.
* @param {Number} x3 - x position of second anchor point's "left" bezier handle.
* @param {Number} y3 - y position of second anchor point's "left" bezier handle.
* @param {Number} x4 - x position of second anchor point.
* @param {Number} y4 - y position of second anchor point.
* @param {Number} [limit=Two.Utils.Curve.RecursionLimit] - The amount of vertices to create by subdividing.
* @returns {Number} The length of a curve.
* @description Given 2 points (a, b) and corresponding control point for each, return a float that represents the length of the curve using Gauss-Legendre algorithm. Limit iterations of calculation by `limit`.
*/
export function getCurveLength(
x1: number,
y1: number,
x2: number,
y2: number,
x3: number,
y3: number,
x4: number,
y4: number,
limit?: number
): number;
/**
* @name Two.Utils.getCurveBoundingBox
* @function
* @param {Number} x1 - x position of first anchor point.
* @param {Number} y1 - y position of first anchor point.
* @param {Number} x2 - x position of first anchor point's "right" bezier handle.
* @param {Number} y2 - y position of first anchor point's "right" bezier handle.
* @param {Number} x3 - x position of second anchor point's "left" bezier handle.
* @param {Number} y3 - y position of second anchor point's "left" bezier handle.
* @param {Number} x4 - x position of second anchor point.
* @param {Number} y4 - y position of second anchor point.
* @returns {Object} Object contains min and max `x` / `y` bounds.
* @see {@link https://github.com/adobe-webplatform/Snap.svg/blob/master/src/path.js#L856}
*/
export function getCurveBoundingBox(
x1: number,
y1: number,
x2: number,
y2: number,
x3: number,
y3: number,
x4: number,
y4: number
): any;
/**
* @name Two.Utils.integrate
* @function
* @param {Function} f
* @param {Number} a
* @param {Number} b
* @param {Number} n
* @description Integration for `getCurveLength` calculations.
* @see [Paper.js](@link https://github.com/paperjs/paper.js/blob/master/src/util/Numerical.js#L101)
*/
export function integrate(
f: Function,
a: number,
b: number,
n: number
): number;
/**
* @name Two.Utils.getCurveFromPoints
* @function
* @param {Anchor[]} points
* @param {Boolean} closed
* @description Sets the bezier handles on {@link Anchor}s in the `points` list with estimated values to create a catmull-rom like curve. Used by {@link Two.Path#plot}.
*/
export function getCurveFromPoints(points: Anchor[], closed: boolean): void;
/**
* @name Two.Utils.getControlPoints
* @function
* @param {Anchor} a
* @param {Anchor} b
* @param {Anchor} c
* @returns {Anchor} Returns the passed middle point `b`.
* @description Given three coordinates set the control points for the middle, b, vertex based on its position with the adjacent points.
*/
export function getControlPoints(a: Anchor, b: Anchor, c: Anchor): Anchor;
/**
* @name Two.Utils.getReflection
* @function
* @param {Vector} a
* @param {Vector} b
* @param {Boolean} [relative=false]
* @returns {Vector} New {@link Vector} that represents the reflection point.
* @description Get the reflection of a point `b` about point `a`. Where `a` is in absolute space and `b` is relative to `a`.
* @see {@link http://www.w3.org/TR/SVG11/implnote.html#PathElementImplementationNotes}
*/
export function getReflection(
a: Vector,
b: Vector,
relative?: boolean
): Vector;
/**
* @name Two.Utils.getAnchorsFromArcData
* @function
* @param {Vector} center
* @param {Number} xAxisRotation
* @param {Number} rx - x radius
* @param {Number} ry - y radius
* @param {Number} ts
* @param {Number} td
* @param {Boolean} [ccw=false] - Set path traversal to counter-clockwise
*/
export function getAnchorsFromArcData(
center: Vector,
xAxisRotation: number,
rx: number,
ry: number,
ts: number,
td: number,
ccw?: boolean
): void;
import { Anchor } from 'two.js/src/anchor';
import { Vector } from 'two.js/src/vector';
}
declare module 'two.js/src/utils/device-pixel-ratio' {
/**
* @name Two.Utils.getRatio
* @function
* @param {CanvasRenderingContext2D} ctx
* @returns {Number} The ratio of a unit in Two.js to the pixel density of a session's screen.
* @see [High DPI Rendering](http://www.html5rocks.com/en/tutorials/canvas/hidpi/)
*/
export function getRatio(ctx: CanvasRenderingContext2D): number;
}
declare module 'two.js/src/utils/underscore' {
export interface _ {
isNaN(obj: any): boolean;
isElement(obj: any): boolean;
isObject(obj: any): boolean;
extend(base: any, ...args: any[]): any;
defaults(base: any, ...args: any[]): any;
each(obj: any, iteratee: any, context: any): any;
performance: { now: () => number };
}
}
declare module 'two.js/src/element' {
/**
* @name Two.Element
* @class
* @description The foundational object for the Two.js scenegraph.
*/
export class Element extends Events {
/**
* @name Two.Element#_flagId
* @private
* @property {Boolean} - Determines whether the {@link Two.Element#id} needs updating.
*/
private _flagId;
/**
* @name Two.Element#_flagClassName
* @private
* @property {Boolean} - Determines whether the {@link Two.Group#className} need updating.
*/
private _flagClassName;
/**
* @name Two.Element#renderer
* @property {Object} - Object access to store relevant renderer specific variables. Warning: manipulating this object can create unintended consequences.
* @nota-bene With the {@link Two.SVGRenderer} you can access the underlying SVG element created via `shape.renderer.elem`.
*/
_renderer: {};
/**
* @name Two.Element#id
* @property {String} - Session specific unique identifier.
* @nota-bene In the {@link Two.SVGRenderer} change this to change the underlying SVG element's id too.
*/
_id: string;
/**
* @name Two.Element#className
* @property {String} - A class to be applied to the element to be compatible with CSS styling.
* @nota-bene Only available for the SVG renderer.
*/
_className: string;
/**
* @name Two.Element#classList
* @property {String[]}
* @description A list of class strings stored if imported / interpreted from an SVG element.
*/
classList: string[];
/**
* @name Two.Element#flagReset
* @function
* @description Called internally by Two.js's renderer to reset all flags. Ensures that only properties that change are updated before being sent to the renderer.
*/
flagReset(): void;
}
import { Events } from 'two.js/src/events';
}
declare module 'two.js/src/matrix' {
/**
* @name Two.Matrix
* @class
* @param {Number} [a=1] - The value for element at the first column and first row.
* @param {Number} [b=0] - The value for element at the second column and first row.
* @param {Number} [c=0] - The value for element at the third column and first row.
* @param {Number} [d=0] - The value for element at the first column and second row.
* @param {Number} [e=1] - The value for element at the second column and second row.
* @param {Number} [f=0] - The value for element at the third column and second row.
* @param {Number} [g=0] - The value for element at the first column and third row.
* @param {Number} [h=0] - The value for element at the second column and third row.
* @param {Number} [i=1] - The value for element at the third column and third row.
* @description A class to store 3 x 3 transformation matrix information. In addition to storing data `Two.Matrix` has suped up methods for commonplace mathematical operations.
* @nota-bene Order is based on how to construct transformation strings for the browser.
*/
export class Matrix extends Events {
/**
* @name Two.Matrix.Identity
* @property {Number[]} - A stored reference to the default value of a 3 x 3 matrix.
*/
static Identity: number[];
/**
* @name Two.Matrix.Multiply
* @function
* @param {Matrix} A
* @param {Matrix} B
* @param {Matrix} [C] - An optional matrix to apply the multiplication to.
* @returns {Matrix} - If an optional `C` matrix isn't passed then a new one is created and returned.
* @description Multiply two matrices together and return the result.
*/
static Multiply(A: Matrix, B: Matrix, C?: Matrix): Matrix;
constructor(elements: number[]);
constructor(
a?: number,
b?: number,
c?: number,
d?: number,
e?: number,
f?: number
);
/**
* @name Two.Matrix#elements
* @property {Number[]} - The underlying data stored as an array.
*/
elements: number[];
/**
* @name Two.Matrix#manual
* @property {Boolean} - Determines whether Two.js automatically calculates the values for the matrix or if the developer intends to manage the matrix.
* @nota-bene - Setting to `true` nullifies {@link Two.Shape#translation}, {@link Two.Shape#rotation}, and {@link Two.Shape#scale}.
*/
manual: boolean;
/**
* @name Two.Matrix#set
* @function
* @param {Number} a - The value for element at the first column and first row.
* @param {Number} b - The value for element at the second column and first row.
* @param {Number} c - The value for element at the third column and first row.
* @param {Number} d - The value for element at the first column and second row.
* @param {Number} e - The value for element at the second column and second row.
* @param {Number} f - The value for element at the third column and second row.
* @param {Number} g - The value for element at the first column and third row.
* @param {Number} h - The value for element at the second column and third row.
* @param {Number} i - The value for element at the third column and third row.
* @description Set an array of values onto the matrix. Order described in {@link Two.Matrix}.
*/
/**
* @name Two.Matrix#set
* @function
* @param {Number[]} a - The array of elements to apply.
* @description Set an array of values onto the matrix. Order described in {@link Two.Matrix}.
*/
set(
a: number[],
b: any,
c: any,
d: any,
e: any,
f: any,
g: any,
h: any,
i: any
): any;
/**
* @name Two.Matrix#copy
* @function
* @description Copy the matrix of one to the current instance.
*/
copy(m: any): any;
/**
* @name Two.Matrix#identity
* @function
* @description Turn matrix to the identity, like resetting.
*/
identity(): any;
/**
* @name Two.Matrix#multiply
* @function
* @param {Number} a - The scalar to be multiplied.
* @description Multiply all components of the matrix against a single scalar value.
* @overloaded
*/
multiply(a: number): any;
/**
* @name Two.Matrix#multiply
* @function
* @param {Number} a - The x component to be multiplied.
* @param {Number} b - The y component to be multiplied.
* @param {Number} c - The z component to be multiplied.
* @description Multiply all components of a matrix against a 3 component vector.
* @overloaded
*/
multiply(
a: number,
b: number,
c?: number
): [x: number, y: number, z: number];
/**
* @name Two.Matrix#multiply
* @function
* @param {Number} a - The value at the first column and first row of the matrix to be multiplied.
* @param {Number} b - The value at the second column and first row of the matrix to be multiplied.
* @param {Number} c - The value at the third column and first row of the matrix to be multiplied.
* @param {Number} d - The value at the first column and second row of the matrix to be multiplied.
* @param {Number} e - The value at the second column and second row of the matrix to be multiplied.
* @param {Number} f - The value at the third column and second row of the matrix to be multiplied.
* @param {Number} g - The value at the first column and third row of the matrix to be multiplied.
* @param {Number} h - The value at the second column and third row of the matrix to be multiplied.
* @param {Number} i - The value at the third column and third row of the matrix to be multiplied.
* @description Multiply all components of a matrix against another matrix.
* @overloaded
*/
multiply(
a: number,
b: number,
c: number,
d: number,
e: number,
f: number,
g: number,
h: number,
i: number
): any;
/**
* @name Two.Matrix#inverse
* @function
* @param {Matrix} [out] - The optional matrix to apply the inversion to.
* @description Return an inverted version of the matrix. If no optional one is passed a new matrix is created and returned.
*/
inverse(out?: Matrix): any;
/**
* @name Two.Matrix#scale
* @function
* @param {Number} scale - The one dimensional scale to apply to the matrix.
* @description Uniformly scale the transformation matrix.
*/
/**
* @name Two.Matrix#scale
* @function