1- // Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog)
2-
31var Class = require ( '../../utils/Class' ) ;
42var FromPoints = require ( '../../geom/rectangle/FromPoints' ) ;
53var Rectangle = require ( '../../geom/rectangle/Rectangle' ) ;
64var Vector2 = require ( '../../math/Vector2' ) ;
75
8- // Our Base Curve which all other curves extend
9-
106var Curve = new Class ( {
117
128 initialize :
139
1410 /**
15- * [description]
11+ * A Base Curve class, which all other curve types extend.
12+ *
13+ * Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog)
1614 *
1715 * @class Curve
1816 * @memberOf Phaser.Curves
@@ -24,40 +22,45 @@ var Curve = new Class({
2422 function Curve ( type )
2523 {
2624 /**
27- * String based identifier
25+ * String based identifier for the type of curve.
2826 *
2927 * @property {string } type
28+ * @since 3.0.0
3029 */
3130 this . type = type ;
3231
3332 /**
34- * [description]
33+ * The default number of divisions within the curve.
3534 *
3635 * @property {integer } defaultDivisions
36+ * @since 3.0.0
3737 * @default 5
3838 */
3939 this . defaultDivisions = 5 ;
4040
4141 /**
42- * [description]
42+ * The quantity of arc length divisions within the curve.
4343 *
4444 * @property {integer } arcLengthDivisions
45+ * @since 3.0.0
4546 * @default 100
4647 */
4748 this . arcLengthDivisions = 100 ;
4849
4950 /**
50- * [description]
51+ * An array of cached arc length values.
5152 *
5253 * @property {array } cacheArcLengths
54+ * @since 3.0.0
5355 * @default []
5456 */
5557 this . cacheArcLengths = [ ] ;
5658
5759 /**
58- * [description]
60+ * Does the data of this curve need updating?
5961 *
6062 * @property {boolean } needsUpdate
63+ * @since 3.0.0
6164 * @default true
6265 */
6366 this . needsUpdate = true ;
@@ -66,37 +69,43 @@ var Curve = new Class({
6669 * [description]
6770 *
6871 * @property {boolean } active
72+ * @since 3.0.0
6973 * @default true
7074 */
7175 this . active = true ;
7276
7377 /**
74- * [description]
78+ * A temporary calculation Vector.
7579 *
7680 * @property {Phaser.Math.Vector2 } _tmpVec2A
81+ * @since 3.0.0
7782 * @private
7883 */
7984 this . _tmpVec2A = new Vector2 ( ) ;
8085
8186 /**
82- * [description]
87+ * A temporary calculation Vector.
8388 *
8489 * @property {Phaser.Math.Vector2 } _tmpVec2B
90+ * @since 3.0.0
8591 * @private
8692 */
8793 this . _tmpVec2B = new Vector2 ( ) ;
8894 } ,
8995
9096 /**
91- * [description]
97+ * Draws this curve on the given Graphics object.
98+ *
99+ * The curve is drawn using `Graphics.strokePoints` so will be drawn at whatever the present Graphics stroke color is.
100+ * The Graphics object is not cleared before the draw, so the curve will appear on-top of anything else already rendered to it.
92101 *
93102 * @method Phaser.Curves.Curve#draw
94103 * @since 3.0.0
95104 *
96- * @param {Phaser.GameObjects.Graphics } graphics - [description]
97- * @param {integer } [pointsTotal=32] - [description]
105+ * @param {Phaser.GameObjects.Graphics } graphics - The Graphics instance onto which this curve will be drawn.
106+ * @param {integer } [pointsTotal=32] - The resolution of the curve. The higher the value the smoother it will render, at the cost of rendering performance.
98107 *
99- * @return {Phaser.GameObjects.Graphics } [description]
108+ * @return {Phaser.GameObjects.Graphics } The Graphics object to which the curve was drawn.
100109 */
101110 draw : function ( graphics , pointsTotal )
102111 {
@@ -107,19 +116,22 @@ var Curve = new Class({
107116 } ,
108117
109118 /**
110- * [description]
119+ * Returns a Rectangle where the position and dimensions match the bounds of this Curve.
120+ *
121+ * You can control the accuracy of the bounds. The value given is used to work out how many points
122+ * to plot across the curve. Higher values are more accurate at the cost of calculation speed.
111123 *
112124 * @method Phaser.Curves.Curve#getBounds
113125 * @since 3.0.0
114126 *
115- * @param {Phaser.Geom.Rectangle } out - [description]
116- * @param {integer } [accuracy=16] - [description]
127+ * @param {Phaser.Geom.Rectangle } out - The Rectangle to store the bounds in. If falsey a new object will be created.
128+ * @param {integer } [accuracy=16] - The accuracy of the bounds calculations.
117129 *
118- * @return {Phaser.Geom.Rectangle } [description]
130+ * @return {Phaser.Geom.Rectangle } A Rectangle containing the bounds values of this Curve.
119131 */
120132 getBounds : function ( out , accuracy )
121133 {
122- if ( out === undefined ) { out = new Rectangle ( ) ; }
134+ if ( ! out ) { out = new Rectangle ( ) ; }
123135 if ( accuracy === undefined ) { accuracy = 16 ; }
124136
125137 var len = this . getLength ( ) ;
@@ -137,17 +149,16 @@ var Curve = new Class({
137149 return FromPoints ( this . getSpacedPoints ( spaced ) , out ) ;
138150 } ,
139151
140- // Return an array of points, spaced out X distance pixels apart
141-
142152 /**
143- * [description]
153+ * Returns an array of points, spaced out X distance pixels apart.
154+ * The smaller the distance, the larger the array will be.
144155 *
145156 * @method Phaser.Curves.Curve#getDistancePoints
146157 * @since 3.0.0
147158 *
148- * @param {integer } distance - [description]
159+ * @param {integer } distance - The distance, in pixels, between each point along the curve.
149160 *
150- * @return {Phaser.Geom.Point[] } [description]
161+ * @return {Phaser.Geom.Point[] } An Array of Point objects.
151162 */
152163 getDistancePoints : function ( distance )
153164 {
0 commit comments