@@ -33,8 +33,8 @@ var Line = require('../../geom/line/Line');
3333 * @extends Phaser.GameObjects.Components.Visible
3434 *
3535 * @param {Phaser.Scene } scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time.
36- * @param {number } x - The horizontal position of this Game Object in the world .
37- * @param {number } y - The vertical position of this Game Object in the world .
36+ * @param {string } [type] - The internal type of the Shape .
37+ * @param {any } [data] - The data of the source shape geometry, if any .
3838 */
3939var Shape = new Class ( {
4040
@@ -63,29 +63,143 @@ var Shape = new Class({
6363
6464 GameObject . call ( this , scene , type ) ;
6565
66+ /**
67+ * The source Shape data. Typically a geometry object.
68+ * You should not manipulate this directly.
69+ *
70+ * @name Phaser.GameObjects.Shape#data
71+ * @type {any }
72+ * @readonly
73+ * @since 3.13.0
74+ */
6675 this . data = data ;
6776
68- // Holds earcut polygon fill data
77+ /**
78+ * Holds the polygon path data for filled rendering.
79+ *
80+ * @name Phaser.GameObjects.Shape#pathData
81+ * @type {number[] }
82+ * @readonly
83+ * @since 3.13.0
84+ */
6985 this . pathData = [ ] ;
86+
87+ /**
88+ * Holds the earcut polygon path index data for filled rendering.
89+ *
90+ * @name Phaser.GameObjects.Shape#pathIndexes
91+ * @type {integer[] }
92+ * @readonly
93+ * @since 3.13.0
94+ */
7095 this . pathIndexes = [ ] ;
7196
97+ /**
98+ * The fill color used by this Shape.
99+ *
100+ * @name Phaser.GameObjects.Shape#fillColor
101+ * @type {number }
102+ * @since 3.13.0
103+ */
72104 this . fillColor = 0xffffff ;
105+
106+ /**
107+ * The fill alpha value used by this Shape.
108+ *
109+ * @name Phaser.GameObjects.Shape#fillAlpha
110+ * @type {number }
111+ * @since 3.13.0
112+ */
73113 this . fillAlpha = 1 ;
74114
75- this . lineWidth = 1 ;
115+ /**
116+ * The stroke color used by this Shape.
117+ *
118+ * @name Phaser.GameObjects.Shape#strokeColor
119+ * @type {number }
120+ * @since 3.13.0
121+ */
76122 this . strokeColor = 0xffffff ;
123+
124+ /**
125+ * The stroke alpha value used by this Shape.
126+ *
127+ * @name Phaser.GameObjects.Shape#strokeAlpha
128+ * @type {number }
129+ * @since 3.13.0
130+ */
77131 this . strokeAlpha = 1 ;
78132
133+ /**
134+ * The stroke line width used by this Shape.
135+ *
136+ * @name Phaser.GameObjects.Shape#lineWidth
137+ * @type {number }
138+ * @since 3.13.0
139+ */
140+ this . lineWidth = 1 ;
141+
142+ /**
143+ * Controls if this Shape is filled or not.
144+ * Note that some Shapes do not support being filled (such as Line shapes)
145+ *
146+ * @name Phaser.GameObjects.Shape#isFilled
147+ * @type {boolean }
148+ * @since 3.13.0
149+ */
79150 this . isFilled = false ;
151+
152+ /**
153+ * Controls if this Shape is stroked or not.
154+ * Note that some Shapes do not support being stroked (such as Iso Box shapes)
155+ *
156+ * @name Phaser.GameObjects.Shape#isStroked
157+ * @type {boolean }
158+ * @since 3.13.0
159+ */
80160 this . isStroked = false ;
81161
162+ /**
163+ * Controls if this Shape path is closed during rendering when stroked.
164+ * Note that some Shapes are always closed when stroked (such as Ellipse shapes)
165+ *
166+ * @name Phaser.GameObjects.Shape#closePath
167+ * @type {boolean }
168+ * @since 3.13.0
169+ */
82170 this . closePath = true ;
83171
172+ /**
173+ * Private internal value.
174+ * A Line used when parsing internal path data to avoid constant object re-creation.
175+ *
176+ * @name Phaser.GameObjects.Curve#_tempLine
177+ * @type {Phaser.Geom.Line }
178+ * @private
179+ * @since 3.13.0
180+ */
84181 this . _tempLine = new Line ( ) ;
85182
86183 this . initPipeline ( ) ;
87184 } ,
88185
186+ /**
187+ * Sets the fill color and alpha for this Shape.
188+ *
189+ * If you wish for the Shape to not be filled then call this method with no arguments, or just set `isFilled` to `false`.
190+ *
191+ * Note that some Shapes do not support fill colors, such as the Line shape.
192+ *
193+ * This call can be chained.
194+ *
195+ * @method Phaser.GameObjects.Shape#setFillStyle
196+ * @since 3.13.0
197+ *
198+ * @param {number } [color] - The color used to fill this shape. If not provided the Shape will not be filled.
199+ * @param {number } [alpha=1] - The alpha value used when filling this shape, if a fill color is given.
200+ *
201+ * @return {this } This Game Object instance.
202+ */
89203 setFillStyle : function ( color , alpha )
90204 {
91205 if ( alpha === undefined ) { alpha = 1 ; }
@@ -104,6 +218,23 @@ var Shape = new Class({
104218 return this ;
105219 } ,
106220
221+ /**
222+ * Sets the stroke color and alpha for this Shape.
223+ *
224+ * If you wish for the Shape to not be stroked then call this method with no arguments, or just set `isStroked` to `false`.
225+ *
226+ * Note that some Shapes do not support being stroked, such as the Iso Box shape.
227+ *
228+ * This call can be chained.
229+ *
230+ * @method Phaser.GameObjects.Shape#setStrokeStyle
231+ * @since 3.13.0
232+ *
233+ * @param {number } [color] - The color used to stroke this shape. If not provided the Shape will not be stroked.
234+ * @param {number } [alpha=1] - The alpha value used when stroking this shape, if a stroke color is given.
235+ *
236+ * @return {this } This Game Object instance.
237+ */
107238 setStrokeStyle : function ( lineWidth , color , alpha )
108239 {
109240 if ( alpha === undefined ) { alpha = 1 ; }
@@ -123,6 +254,19 @@ var Shape = new Class({
123254 return this ;
124255 } ,
125256
257+ /**
258+ * Sets if this Shape path is closed during rendering when stroked.
259+ * Note that some Shapes are always closed when stroked (such as Ellipse shapes)
260+ *
261+ * This call can be chained.
262+ *
263+ * @method Phaser.GameObjects.Shape#setClosePath
264+ * @since 3.13.0
265+ *
266+ * @param {boolean } value - Set to `true` if the Shape should be closed when stroked, otherwise `false`.
267+ *
268+ * @return {this } This Game Object instance.
269+ */
126270 setClosePath : function ( value )
127271 {
128272 this . closePath = value ;
0 commit comments