Skip to content

Commit 9bb02d5

Browse files
committed
improve typings: getPoints functions
1 parent 265bfc7 commit 9bb02d5

5 files changed

Lines changed: 15 additions & 9 deletions

File tree

src/curves/Curve.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,8 @@ var Curve = new Class({
295295
* @method Phaser.Curves.Curve#getPoints
296296
* @since 3.0.0
297297
*
298+
* @generic {Phaser.Math.Vector2[]} O - [out,$return]
299+
*
298300
* @param {integer} divisions - The number of evenly spaced points from the curve to return. If falsy, step param will be used to calculate the number of points.
299301
* @param {number} step - Step between points. Used to calculate the number of points to return when divisions is falsy. Ignored if divisions is positive.
300302
* @param {(array|Phaser.Math.Vector2[])} [out] - An optional array to store the points in.

src/geom/ellipse/Ellipse.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,13 @@ var Ellipse = new Class({
135135
* @method Phaser.Geom.Ellipse#getPoints
136136
* @since 3.0.0
137137
*
138+
* @generic {Phaser.Geom.Point[]} O - [output,$return]
139+
*
138140
* @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead.
139141
* @param {number} [stepRate] - Sets the quantity by getting the circumference of the ellipse and dividing it by the stepRate.
140-
* @param {array} [output] - An array to insert the points in to. If not provided a new array will be created.
142+
* @param {(array|Phaser.Geom.Point[])} [output] - An array to insert the points in to. If not provided a new array will be created.
141143
*
142-
* @return {Phaser.Geom.Point[]} An array of Point objects pertaining to the points around the circumference of the ellipse.
144+
* @return {(array|Phaser.Geom.Point[])} An array of Point objects pertaining to the points around the circumference of the ellipse.
143145
*/
144146
getPoints: function (quantity, stepRate, output)
145147
{

src/geom/line/Line.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ var Line = new Class({
113113
* @method Phaser.Geom.Line#getPoints
114114
* @since 3.0.0
115115
*
116-
* @generic {Phaser.Geom.Point} O - [output,$return]
116+
* @generic {Phaser.Geom.Point[]} O - [output,$return]
117117
*
118118
* @param {integer} quantity - The number of points to place on the line. Set to `0` to use `stepRate` instead.
119119
* @param {integer} [stepRate] - The distance between each point on the line. When set, `quantity` is implied and should be set to `0`.

src/geom/polygon/Polygon.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,13 @@ var Polygon = new Class({
211211
* @method Phaser.Geom.Polygon#getPoints
212212
* @since 3.12.0
213213
*
214+
* @generic {Phaser.Geom.Point[]} O - [output,$return]
215+
*
214216
* @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead.
215217
* @param {number} [stepRate] - Sets the quantity by getting the perimeter of the Polygon and dividing it by the stepRate.
216-
* @param {array} [output] - An array to insert the points in to. If not provided a new array will be created.
218+
* @param {(array|Phaser.Geom.Point[])} [output] - An array to insert the points in to. If not provided a new array will be created.
217219
*
218-
* @return {Phaser.Geom.Point[]} An array of Point objects pertaining to the points around the perimeter of the Polygon.
220+
* @return {(array|Phaser.Geom.Point[])} An array of Point objects pertaining to the points around the perimeter of the Polygon.
219221
*/
220222
getPoints: function (quantity, step, output)
221223
{

types/phaser.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5178,7 +5178,7 @@ declare namespace Phaser {
51785178
* @param step Step between points. Used to calculate the number of points to return when divisions is falsy. Ignored if divisions is positive.
51795179
* @param out An optional array to store the points in.
51805180
*/
5181-
getPoints(divisions: integer, step: number, out?: any[] | Phaser.Math.Vector2[]): any[] | Phaser.Math.Vector2[];
5181+
getPoints<O extends Phaser.Math.Vector2[]>(divisions: integer, step: number, out?: O): O;
51825182

51835183
/**
51845184
* [description]
@@ -38275,7 +38275,7 @@ declare namespace Phaser {
3827538275
* @param stepRate Sets the quantity by getting the circumference of the ellipse and dividing it by the stepRate.
3827638276
* @param output An array to insert the points in to. If not provided a new array will be created.
3827738277
*/
38278-
getPoints(quantity: integer, stepRate?: number, output?: any[]): Phaser.Geom.Point[];
38278+
getPoints<O extends Phaser.Geom.Point[]>(quantity: integer, stepRate?: number, output?: O): O;
3827938279

3828038280
/**
3828138281
* Returns a uniformly distributed random point from anywhere within the given Ellipse.
@@ -38807,7 +38807,7 @@ declare namespace Phaser {
3880738807
* @param stepRate The distance between each point on the line. When set, `quantity` is implied and should be set to `0`.
3880838808
* @param output An optional array of Points, or point-like objects, to store the coordinates of the points on the line.
3880938809
*/
38810-
getPoints<O extends Phaser.Geom.Point>(quantity: integer, stepRate?: integer, output?: O): O;
38810+
getPoints<O extends Phaser.Geom.Point[]>(quantity: integer, stepRate?: integer, output?: O): O;
3881138811

3881238812
/**
3881338813
* Get a random Point on the Line.
@@ -39218,7 +39218,7 @@ declare namespace Phaser {
3921839218
* @param stepRate Sets the quantity by getting the perimeter of the Polygon and dividing it by the stepRate.
3921939219
* @param output An array to insert the points in to. If not provided a new array will be created.
3922039220
*/
39221-
getPoints(quantity: integer, stepRate?: number, output?: any[]): Phaser.Geom.Point[];
39221+
getPoints<O extends Phaser.Geom.Point[]>(quantity: integer, stepRate?: number, output?: O): O;
3922239222

3922339223
/**
3922439224
* Reverses the order of the points of a Polygon.

0 commit comments

Comments
 (0)