Skip to content

Commit 1ded1d1

Browse files
committed
Fix types and add generic in Curves
1 parent 7a33233 commit 1ded1d1

8 files changed

Lines changed: 80 additions & 9 deletions

File tree

src/curves/CubicBezierCurve.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ var CubicBezierCurve = new Class({
8787
* @method Phaser.Curves.CubicBezierCurve#getStartPoint
8888
* @since 3.0.0
8989
*
90+
* @generic {Phaser.Math.Vector2} O - [out,$return]
91+
*
9092
* @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created.
9193
*
9294
* @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned.
@@ -119,6 +121,8 @@ var CubicBezierCurve = new Class({
119121
* @method Phaser.Curves.CubicBezierCurve#getPoint
120122
* @since 3.0.0
121123
*
124+
* @generic {Phaser.Math.Vector2} O - [out,$return]
125+
*
122126
* @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end.
123127
* @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created.
124128
*
@@ -142,6 +146,8 @@ var CubicBezierCurve = new Class({
142146
* @method Phaser.Curves.CubicBezierCurve#draw
143147
* @since 3.0.0
144148
*
149+
* @generic {Phaser.GameObjects.Graphics} G - [out,$return]
150+
*
145151
* @param {Phaser.GameObjects.Graphics} graphics - [description]
146152
* @param {integer} [pointsTotal=32] - [description]
147153
*

src/curves/Curve.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ var Curve = new Class({
117117
* @method Phaser.Curves.Curve#draw
118118
* @since 3.0.0
119119
*
120+
* @generic {Phaser.GameObjects.Graphics} G - [out,$return]
121+
*
120122
* @param {Phaser.GameObjects.Graphics} graphics - The Graphics instance onto which this curve will be drawn.
121123
* @param {integer} [pointsTotal=32] - The resolution of the curve. The higher the value the smoother it will render, at the cost of rendering performance.
122124
*
@@ -274,6 +276,8 @@ var Curve = new Class({
274276
* @method Phaser.Curves.Curve#getPointAt
275277
* @since 3.0.0
276278
*
279+
* @generic {Phaser.Math.Vector2} O - [out,$return]
280+
*
277281
* @param {float} u - [description]
278282
* @param {Phaser.Math.Vector2} [out] - [description]
279283
*
@@ -318,6 +322,8 @@ var Curve = new Class({
318322
* @method Phaser.Curves.Curve#getRandomPoint
319323
* @since 3.0.0
320324
*
325+
* @generic {Phaser.Math.Vector2} O - [out,$return]
326+
*
321327
* @param {Phaser.Math.Vector2} [out] - [description]
322328
*
323329
* @return {Phaser.Math.Vector2} [description]
@@ -363,6 +369,8 @@ var Curve = new Class({
363369
* @method Phaser.Curves.Curve#getStartPoint
364370
* @since 3.0.0
365371
*
372+
* @generic {Phaser.Math.Vector2} O - [out,$return]
373+
*
366374
* @param {Phaser.Math.Vector2} [out] - [description]
367375
*
368376
* @return {Phaser.Math.Vector2} [description]
@@ -385,6 +393,8 @@ var Curve = new Class({
385393
* @method Phaser.Curves.Curve#getTangent
386394
* @since 3.0.0
387395
*
396+
* @generic {Phaser.Math.Vector2} O - [out,$return]
397+
*
388398
* @param {number} t - [description]
389399
* @param {Phaser.Math.Vector2} [out] - [description]
390400
*
@@ -422,6 +432,8 @@ var Curve = new Class({
422432
* @method Phaser.Curves.Curve#getTangentAt
423433
* @since 3.0.0
424434
*
435+
* @generic {Phaser.Math.Vector2} O - [out,$return]
436+
*
425437
* @param {float} u - [description]
426438
* @param {Phaser.Math.Vector2} [out] - [description]
427439
*

src/curves/EllipseCurve.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,19 @@ var Vector2 = require('../math/Vector2');
2727
* @property {integer} rotation - The rotation of ellipse.
2828
*/
2929

30+
/**
31+
* @typedef {object} EllipseCurveConfig
32+
*
33+
* @property {number} [x=0] - [description]
34+
* @property {number} [y=0] - [description]
35+
* @property {number} [xRadius=0] - [description]
36+
* @property {number} [yRadius=0] - [description]
37+
* @property {integer} [startAngle=0] - [description]
38+
* @property {integer} [endAngle=360] - [description]
39+
* @property {boolean} [clockwise=false] - [description]
40+
* @property {integer} [rotation=0] - [description]
41+
*/
42+
3043
/**
3144
* @classdesc
3245
* [description]
@@ -37,14 +50,14 @@ var Vector2 = require('../math/Vector2');
3750
* @constructor
3851
* @since 3.0.0
3952
*
40-
* @param {number} [x=0] - [description]
53+
* @param {(number|EllipseCurveConfig)} [x=0] - [description]
4154
* @param {number} [y=0] - [description]
4255
* @param {number} [xRadius=0] - [description]
4356
* @param {number} [yRadius=0] - [description]
44-
* @param {number} [startAngle=0] - [description]
45-
* @param {number} [endAngle=360] - [description]
57+
* @param {integer} [startAngle=0] - [description]
58+
* @param {integer} [endAngle=360] - [description]
4659
* @param {boolean} [clockwise=false] - [description]
47-
* @param {number} [rotation=0] - [description]
60+
* @param {integer} [rotation=0] - [description]
4861
*/
4962
var EllipseCurve = new Class({
5063

@@ -158,6 +171,8 @@ var EllipseCurve = new Class({
158171
* @method Phaser.Curves.EllipseCurve#getStartPoint
159172
* @since 3.0.0
160173
*
174+
* @generic {Phaser.Math.Vector2} O - [out,$return]
175+
*
161176
* @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created.
162177
*
163178
* @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned.
@@ -190,6 +205,8 @@ var EllipseCurve = new Class({
190205
* @method Phaser.Curves.EllipseCurve#getPoint
191206
* @since 3.0.0
192207
*
208+
* @generic {Phaser.Math.Vector2} O - [out,$return]
209+
*
193210
* @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end.
194211
* @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created.
195212
*

src/curves/LineCurve.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ var tmpVec2 = new Vector2();
2424
* @constructor
2525
* @since 3.0.0
2626
*
27-
* @param {Phaser.Math.Vector2} p0 - [description]
28-
* @param {Phaser.Math.Vector2} p1 - [description]
27+
* @param {(Phaser.Math.Vector2|number[])} p0 - [description]
28+
* @param {Phaser.Math.Vector2} [p1] - [description]
2929
*/
3030
var LineCurve = new Class({
3131

@@ -69,6 +69,8 @@ var LineCurve = new Class({
6969
* @method Phaser.Curves.LineCurve#getBounds
7070
* @since 3.0.0
7171
*
72+
* @generic {Phaser.Geom.Rectangle} O - [out,$return]
73+
*
7274
* @param {Phaser.Geom.Rectangle} [out] - A Rectangle object to store the bounds in. If not given a new Rectangle will be created.
7375
*
7476
* @return {Phaser.Geom.Rectangle} A Rectangle object holding the bounds of this curve. If `out` was given it will be this object.
@@ -86,6 +88,8 @@ var LineCurve = new Class({
8688
* @method Phaser.Curves.LineCurve#getStartPoint
8789
* @since 3.0.0
8890
*
91+
* @generic {Phaser.Math.Vector2} O - [out,$return]
92+
*
8993
* @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created.
9094
*
9195
* @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned.
@@ -116,6 +120,8 @@ var LineCurve = new Class({
116120
* @method Phaser.Curves.LineCurve#getPoint
117121
* @since 3.0.0
118122
*
123+
* @generic {Phaser.Math.Vector2} O - [out,$return]
124+
*
119125
* @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end.
120126
* @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created.
121127
*
@@ -143,6 +149,8 @@ var LineCurve = new Class({
143149
* @method Phaser.Curves.LineCurve#getPointAt
144150
* @since 3.0.0
145151
*
152+
* @generic {Phaser.Math.Vector2} O - [out,$return]
153+
*
146154
* @param {float} u - The position along the curve to return. Where 0 is the start and 1 is the end.
147155
* @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created.
148156
*
@@ -179,6 +187,8 @@ var LineCurve = new Class({
179187
* @method Phaser.Curves.LineCurve#draw
180188
* @since 3.0.0
181189
*
190+
* @generic {Phaser.GameObjects.Graphics} G - [graphics,$return]
191+
*
182192
* @param {Phaser.GameObjects.Graphics} graphics - The Graphics instance onto which this curve will be drawn.
183193
*
184194
* @return {Phaser.GameObjects.Graphics} The Graphics object to which the curve was drawn.

src/curves/QuadraticBezierCurve.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ var Vector2 = require('../math/Vector2');
1919
* @constructor
2020
* @since 3.2.0
2121
*
22-
* @param {(Phaser.Math.Vector2|Phaser.Math.Vector2[])} p0 - Start point, or an array of point pairs.
22+
* @param {(Phaser.Math.Vector2|number[])} p0 - Start point, or an array of point pairs.
2323
* @param {Phaser.Math.Vector2} p1 - Control Point 1.
2424
* @param {Phaser.Math.Vector2} p2 - Control Point 2.
2525
*/
@@ -74,6 +74,8 @@ var QuadraticBezier = new Class({
7474
* @method Phaser.Curves.QuadraticBezier#getStartPoint
7575
* @since 3.2.0
7676
*
77+
* @generic {Phaser.Math.Vector2} O - [out,$return]
78+
*
7779
* @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created.
7880
*
7981
* @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned.
@@ -106,6 +108,8 @@ var QuadraticBezier = new Class({
106108
* @method Phaser.Curves.QuadraticBezier#getPoint
107109
* @since 3.2.0
108110
*
111+
* @generic {Phaser.Math.Vector2} O - [out,$return]
112+
*
109113
* @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end.
110114
* @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created.
111115
*
@@ -131,6 +135,8 @@ var QuadraticBezier = new Class({
131135
* @method Phaser.Curves.QuadraticBezier#draw
132136
* @since 3.2.0
133137
*
138+
* @generic {Phaser.GameObjects.Graphics} G - [graphics,$return]
139+
*
134140
* @param {Phaser.GameObjects.Graphics} graphics - [description]
135141
* @param {integer} [pointsTotal=32] - [description]
136142
*

src/curves/SplineCurve.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ var SplineCurve = new Class({
5454
* @method Phaser.Curves.SplineCurve#addPoints
5555
* @since 3.0.0
5656
*
57-
* @param {Phaser.Math.Vector2[]} points - [description]
57+
* @param {(Phaser.Math.Vector2[]|number[]|number[][])} points - [description]
5858
*
5959
* @return {Phaser.Curves.SplineCurve} This curve object.
6060
*/
@@ -114,6 +114,8 @@ var SplineCurve = new Class({
114114
* @method Phaser.Curves.SplineCurve#getStartPoint
115115
* @since 3.0.0
116116
*
117+
* @generic {Phaser.Math.Vector2} O - [out,$return]
118+
*
117119
* @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created.
118120
*
119121
* @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned.
@@ -146,6 +148,8 @@ var SplineCurve = new Class({
146148
* @method Phaser.Curves.SplineCurve#getPoint
147149
* @since 3.0.0
148150
*
151+
* @generic {Phaser.Math.Vector2} O - [out,$return]
152+
*
149153
* @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end.
150154
* @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created.
151155
*

src/curves/path/MoveTo.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ var MoveTo = new Class({
5353
* @method Phaser.Curves.MoveTo#getPoint
5454
* @since 3.0.0
5555
*
56+
* @generic {Phaser.Math.Vector2} O - [out,$return]
57+
*
5658
* @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end.
5759
* @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created.
5860
*
@@ -71,6 +73,8 @@ var MoveTo = new Class({
7173
* @method Phaser.Curves.MoveTo#getPointAt
7274
* @since 3.0.0
7375
*
76+
* @generic {Phaser.Math.Vector2} O - [out,$return]
77+
*
7478
* @param {float} u - [description]
7579
* @param {Phaser.Math.Vector2} [out] - [description]
7680
*

src/curves/path/Path.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ var Path = new Class({
269269
* @method Phaser.Curves.Path#draw
270270
* @since 3.0.0
271271
*
272+
* @generic {Phaser.GameObjects.Graphics} G - [out,$return]
273+
*
272274
* @param {Phaser.GameObjects.Graphics} graphics - [description]
273275
* @param {integer} [pointsTotal=32] - [description]
274276
*
@@ -381,6 +383,8 @@ var Path = new Class({
381383
* @method Phaser.Curves.Path#getBounds
382384
* @since 3.0.0
383385
*
386+
* @generic {Phaser.Math.Vector2} O - [out,$return]
387+
*
384388
* @param {Phaser.Geom.Rectangle} [out] - [description]
385389
* @param {integer} [accuracy=16] - [description]
386390
*
@@ -428,7 +432,7 @@ var Path = new Class({
428432
* @method Phaser.Curves.Path#getCurveLengths
429433
* @since 3.0.0
430434
*
431-
* @return {array} [description]
435+
* @return {number[]} [description]
432436
*/
433437
getCurveLengths: function ()
434438
{
@@ -463,6 +467,8 @@ var Path = new Class({
463467
* @method Phaser.Curves.Path#getEndPoint
464468
* @since 3.0.0
465469
*
470+
* @generic {Phaser.Math.Vector2} O - [out,$return]
471+
*
466472
* @param {Phaser.Math.Vector2} [out] - [description]
467473
*
468474
* @return {Phaser.Math.Vector2} [description]
@@ -513,6 +519,8 @@ var Path = new Class({
513519
* @method Phaser.Curves.Path#getPoint
514520
* @since 3.0.0
515521
*
522+
* @generic {Phaser.Math.Vector2} O - [out,$return]
523+
*
516524
* @param {number} t - [description]
517525
* @param {Phaser.Math.Vector2} [out] - [description]
518526
*
@@ -606,6 +614,8 @@ var Path = new Class({
606614
* @method Phaser.Curves.Path#getRandomPoint
607615
* @since 3.0.0
608616
*
617+
* @generic {Phaser.Math.Vector2} O - [out,$return]
618+
*
609619
* @param {Phaser.Math.Vector2} [out] - [description]
610620
*
611621
* @return {Phaser.Math.Vector2} [description]
@@ -652,6 +662,8 @@ var Path = new Class({
652662
* @method Phaser.Curves.Path#getStartPoint
653663
* @since 3.0.0
654664
*
665+
* @generic {Phaser.Math.Vector2} O - [out,$return]
666+
*
655667
* @param {Phaser.Math.Vector2} [out] - [description]
656668
*
657669
* @return {Phaser.Math.Vector2} [description]

0 commit comments

Comments
 (0)