Skip to content

Commit bee0a96

Browse files
committed
Docs for Phaser.Curves.Curve and Phaser.Curves.Path
And whitespace
1 parent 5e027f7 commit bee0a96

2 files changed

Lines changed: 60 additions & 40 deletions

File tree

src/curves/Curve.js

Lines changed: 55 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var Vector2 = require('../math/Vector2');
2020
* @constructor
2121
* @since 3.0.0
2222
*
23-
* @param {string} type - [description]
23+
* @param {string} type - The curve type.
2424
*/
2525
var Curve = new Class({
2626

@@ -78,7 +78,7 @@ var Curve = new Class({
7878
this.needsUpdate = true;
7979

8080
/**
81-
* [description]
81+
* For a curve on a Path, `false` means the Path will ignore this curve.
8282
*
8383
* @name Phaser.Curves.Curve#active
8484
* @type {boolean}
@@ -131,7 +131,7 @@ var Curve = new Class({
131131
// So you can chain graphics calls
132132
return graphics.strokePoints(this.getPoints(pointsTotal));
133133
},
134-
134+
135135
/**
136136
* Returns a Rectangle where the position and dimensions match the bounds of this Curve.
137137
*
@@ -187,7 +187,7 @@ var Curve = new Class({
187187
},
188188

189189
/**
190-
* [description]
190+
* Get a point at the end of the curve.
191191
*
192192
* @method Phaser.Curves.Curve#getEndPoint
193193
* @since 3.0.0
@@ -209,7 +209,7 @@ var Curve = new Class({
209209
* @method Phaser.Curves.Curve#getLength
210210
* @since 3.0.0
211211
*
212-
* @return {number} [description]
212+
* @return {number} The total length of the curve.
213213
*/
214214
getLength: function ()
215215
{
@@ -220,14 +220,22 @@ var Curve = new Class({
220220

221221

222222
/**
223-
* Get list of cumulative segment lengths
223+
* Get a list of cumulative segment lengths.
224+
*
225+
* These lengths are
226+
*
227+
* - [0] 0
228+
* - [1] The first segment
229+
* - [2] The first and second segment
230+
* - ...
231+
* - [divisions] All segments
224232
*
225233
* @method Phaser.Curves.Curve#getLengths
226234
* @since 3.0.0
227235
*
228-
* @param {integer} [divisions] - [description]
236+
* @param {integer} [divisions] - The number of divisions or segments.
229237
*
230-
* @return {number[]} [description]
238+
* @return {number[]} An array of cumulative lengths.
231239
*/
232240
getLengths: function (divisions)
233241
{
@@ -268,17 +276,17 @@ var Curve = new Class({
268276
// - u [0 .. 1]
269277

270278
/**
271-
* [description]
279+
* Get a point at a relative position on the curve, by arc length.
272280
*
273281
* @method Phaser.Curves.Curve#getPointAt
274282
* @since 3.0.0
275283
*
276284
* @generic {Phaser.Math.Vector2} O - [out,$return]
277285
*
278-
* @param {number} u - [description]
279-
* @param {Phaser.Math.Vector2} [out] - [description]
286+
* @param {number} u - The relative position, [0..1].
287+
* @param {Phaser.Math.Vector2} [out] - A point to store the result in.
280288
*
281-
* @return {Phaser.Math.Vector2} [description]
289+
* @return {Phaser.Math.Vector2} The point.
282290
*/
283291
getPointAt: function (u, out)
284292
{
@@ -290,13 +298,23 @@ var Curve = new Class({
290298
// Get sequence of points using getPoint( t )
291299

292300
/**
293-
* [description]
301+
* Get a sequence of evenly spaced points from the curve.
302+
*
303+
* You can pass `divisions`, `stepRate`, or neither.
304+
*
305+
* The number of divisions will be
306+
*
307+
* 1. `divisions`, if `divisions` > 0; or
308+
* 2. `this.getLength / stepRate`, if `stepRate` > 0; or
309+
* 3. `this.defaultDivisions`
310+
*
311+
* `1 + divisions` points will be returned.
294312
*
295313
* @method Phaser.Curves.Curve#getPoints
296314
* @since 3.0.0
297315
*
298-
* @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.
299-
* @param {number} step - Step between points. Used to calculate the number of points to return when divisions is falsy. Ignored if divisions is positive.
316+
* @param {integer} [divisions] - The number of divisions to make.
317+
* @param {number} [stepRate] - The curve distance between points, implying `divisions`.
300318
* @param {(array|Phaser.Math.Vector2[])} [out] - An optional array to store the points in.
301319
*
302320
* @return {(array|Phaser.Math.Vector2[])} An array of Points from the curve.
@@ -327,16 +345,16 @@ var Curve = new Class({
327345
},
328346

329347
/**
330-
* [description]
348+
* Get a random point from the curve.
331349
*
332350
* @method Phaser.Curves.Curve#getRandomPoint
333351
* @since 3.0.0
334352
*
335353
* @generic {Phaser.Math.Vector2} O - [out,$return]
336354
*
337-
* @param {Phaser.Math.Vector2} [out] - [description]
355+
* @param {Phaser.Math.Vector2} [out] - A point object to store the result in.
338356
*
339-
* @return {Phaser.Math.Vector2} [description]
357+
* @return {Phaser.Math.Vector2} The point.
340358
*/
341359
getRandomPoint: function (out)
342360
{
@@ -348,16 +366,18 @@ var Curve = new Class({
348366
// Get sequence of points using getPointAt( u )
349367

350368
/**
351-
* [description]
369+
* Get a sequence of equally spaced points (by arc distance) from the curve.
370+
*
371+
* `1 + divisions` points will be returned.
352372
*
353373
* @method Phaser.Curves.Curve#getSpacedPoints
354374
* @since 3.0.0
355375
*
356-
* @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.
357-
* @param {number} [step] - Step between points. Used to calculate the number of points to return when divisions is falsy. Ignored if divisions is positive.
376+
* @param {integer} [divisions=this.defaultDivisions] - The number of divisions to make.
377+
* @param {number} [stepRate] - Step between points. Used to calculate the number of points to return when divisions is falsy. Ignored if divisions is positive.
358378
* @param {(array|Phaser.Math.Vector2[])} [out] - An optional array to store the points in.
359379
*
360-
* @return {Phaser.Math.Vector2[]} [description]
380+
* @return {Phaser.Math.Vector2[]} An array of points.
361381
*/
362382
getSpacedPoints: function (divisions, stepRate, out)
363383
{
@@ -387,16 +407,16 @@ var Curve = new Class({
387407
},
388408

389409
/**
390-
* [description]
410+
* Get a point at the start of the curve.
391411
*
392412
* @method Phaser.Curves.Curve#getStartPoint
393413
* @since 3.0.0
394414
*
395415
* @generic {Phaser.Math.Vector2} O - [out,$return]
396416
*
397-
* @param {Phaser.Math.Vector2} [out] - [description]
417+
* @param {Phaser.Math.Vector2} [out] - A point to store the result in.
398418
*
399-
* @return {Phaser.Math.Vector2} [description]
419+
* @return {Phaser.Math.Vector2} The point.
400420
*/
401421
getStartPoint: function (out)
402422
{
@@ -406,7 +426,7 @@ var Curve = new Class({
406426
},
407427

408428
/**
409-
* Returns a unit vector tangent at t
429+
* Get a unit vector tangent at a relative position on the curve.
410430
* In case any sub curve does not implement its tangent derivation,
411431
* 2 points a small delta apart will be used to find its gradient
412432
* which seems to give a reasonable approximation
@@ -416,8 +436,8 @@ var Curve = new Class({
416436
*
417437
* @generic {Phaser.Math.Vector2} O - [out,$return]
418438
*
419-
* @param {number} t - [description]
420-
* @param {Phaser.Math.Vector2} [out] - [description]
439+
* @param {number} t - The relative position on the curve, [0..1].
440+
* @param {Phaser.Math.Vector2} [out] - A vector to store the result in.
421441
*
422442
* @return {Phaser.Math.Vector2} Vector approximating the tangent line at the point t (delta +/- 0.0001)
423443
*/
@@ -448,17 +468,17 @@ var Curve = new Class({
448468
},
449469

450470
/**
451-
* [description]
471+
* Get a unit vector tangent at a relative position on the curve, by arc length.
452472
*
453473
* @method Phaser.Curves.Curve#getTangentAt
454474
* @since 3.0.0
455475
*
456476
* @generic {Phaser.Math.Vector2} O - [out,$return]
457477
*
458-
* @param {number} u - [description]
459-
* @param {Phaser.Math.Vector2} [out] - [description]
478+
* @param {number} u - The relative position on the curve, [0..1].
479+
* @param {Phaser.Math.Vector2} [out] - A vector to store the result in.
460480
*
461-
* @return {Phaser.Math.Vector2} [description]
481+
* @return {Phaser.Math.Vector2} The tangent vector.
462482
*/
463483
getTangentAt: function (u, out)
464484
{
@@ -573,10 +593,12 @@ var Curve = new Class({
573593
},
574594

575595
/**
576-
* [description]
596+
* Calculate and cache the arc lengths.
577597
*
578598
* @method Phaser.Curves.Curve#updateArcLengths
579599
* @since 3.0.0
600+
*
601+
* @see Phaser.Curves.Curve#getLengths()
580602
*/
581603
updateArcLengths: function ()
582604
{

src/curves/path/Path.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -569,14 +569,12 @@ var Path = new Class({
569569
},
570570

571571
/**
572-
* Returns the defined starting point of the Path.
573-
*
574-
* This is not necessarily equal to the starting point of the first Curve if it differs from {@link startPoint}.
572+
* Get a sequence of points on the path.
575573
*
576574
* @method Phaser.Curves.Path#getPoints
577575
* @since 3.0.0
578576
*
579-
* @param {integer} [divisions=12] - The number of points to divide the path in to.
577+
* @param {integer} [divisions=12] - The number of divisions per resolution per curve.
580578
*
581579
* @return {Phaser.Math.Vector2[]} An array of Vector2 objects that containing the points along the Path.
582580
*/
@@ -626,7 +624,7 @@ var Path = new Class({
626624

627625
/**
628626
* Returns a randomly chosen point anywhere on the path. This follows the same rules as `getPoint` in that it may return a point on any Curve inside this path.
629-
*
627+
*
630628
* When calling this method multiple times, the points are not guaranteed to be equally spaced spatially.
631629
*
632630
* @method Phaser.Curves.Path#getRandomPoint
@@ -647,7 +645,7 @@ var Path = new Class({
647645

648646
/**
649647
* Divides this Path into a set of equally spaced points,
650-
*
648+
*
651649
* The resulting points are equally spaced with respect to the points' position on the path, but not necessarily equally spaced spatially.
652650
*
653651
* @method Phaser.Curves.Path#getSpacedPoints
@@ -741,7 +739,7 @@ var Path = new Class({
741739

742740
/**
743741
* Creates a "gap" in this path from the path's current end point to the given coordinates.
744-
*
742+
*
745743
* After calling this function, this Path's end point will be equal to the given coordinates
746744
*
747745
* @method Phaser.Curves.Path#moveTo

0 commit comments

Comments
 (0)