@@ -36,7 +36,7 @@ var Render = require('./GraphicsRender');
3636/**
3737 * Graphics style settings.
3838 *
39- * @typedef {object } GraphicsStyle
39+ * @typedef {object } GraphicsStyles
4040 *
4141 * @property {GraphicsLineStyle } lineStyle - The style applied to shape outlines.
4242 * @property {GraphicsFillStyle } fillStyle - The style applied to shape areas.
@@ -46,15 +46,52 @@ var Render = require('./GraphicsRender');
4646 * Options for the Graphics game Object.
4747 *
4848 * @typedef {object } GraphicsOptions
49- * @extends GraphicsStyle
49+ * @extends GraphicsStyles
5050 *
5151 * @property {number } x - The x coordinate of the Graphics.
5252 * @property {number } y - The y coordinate of the Graphics.
5353 */
5454
5555/**
5656 * @classdesc
57- * [description]
57+ * A Graphics object is a way to draw primitive shapes to you game. Primitives include forms of geometry, such as
58+ * Rectangles, Circles, and Polygons. They also include lines, arcs and curves. When you initially create a Graphics
59+ * object it will be empty.
60+ *
61+ * To draw to it you must first specify a line style or fill style (or both), draw shapes using paths, and finally
62+ * fill or stroke them. For example:
63+ *
64+ * ```javascript
65+ * graphics.lineStyle(5, 0xFF00FF, 1.0);
66+ * graphics.beginPath();
67+ * graphics.moveTo(100, 100);
68+ * graphics.lineTo(200, 200);
69+ * graphics.closePath();
70+ * graphics.strokePath();
71+ * ```
72+ *
73+ * There are also many helpful methods that draw and fill/stroke common shapes for you.
74+ *
75+ * ```javascript
76+ * graphics.lineStyle(5, 0xFF00FF, 1.0);
77+ * graphics.fillStyle(0xFFFFFF, 1.0);
78+ * graphics.fillRect(50, 50, 200, 200);
79+ * graphics.strokeRect(50, 50, 200, 200);
80+ * ```
81+ *
82+ * When a Graphics object is rendered it will render differently based on if the game is running under Canvas or WebGL.
83+ * Under Canvas it will use the HTML Canvas context drawing operations to draw the path.
84+ * Under WebGL the graphics data is decomposed into polygons. Both of these are expensive processes, especially with
85+ * complex shapes.
86+ *
87+ * If your Graphics object doesn't change much (or at all) once you've drawn your shape to it, then you will help
88+ * performance by calling {@link Phaser.GameObjects.Graphics#generateTexture}. This will 'bake' the Graphics object into
89+ * a Texture, and return it. You can then use this Texture for Sprites or other display objects. If your Graphics object
90+ * updates frequently then you should avoid doing this, as it will constantly generate new textures, which will consume
91+ * memory.
92+ *
93+ * As you can tell, Graphics objects are a bit of a trade-off. While they are extremely useful, you need to be careful
94+ * in their complexity and quantity of them in your game.
5895 *
5996 * @class Graphics
6097 * @extends Phaser.GameObjects.GameObject
@@ -103,7 +140,7 @@ var Graphics = new Class({
103140 this . initPipeline ( 'FlatTintPipeline' ) ;
104141
105142 /**
106- * [description]
143+ * The horizontal display origin of the Graphics.
107144 *
108145 * @name Phaser.GameObjects.Graphics#displayOriginX
109146 * @type {number }
@@ -113,7 +150,7 @@ var Graphics = new Class({
113150 this . displayOriginX = 0 ;
114151
115152 /**
116- * [description]
153+ * The vertical display origin of the Graphics.
117154 *
118155 * @name Phaser.GameObjects.Graphics#displayOriginY
119156 * @type {number }
@@ -183,7 +220,7 @@ var Graphics = new Class({
183220 this . defaultStrokeAlpha = 1 ;
184221
185222 /**
186- * [description]
223+ * Internal property that keeps track of the line width style setting.
187224 *
188225 * @name Phaser.GameObjects.Graphics#_lineWidth
189226 * @type {number }
@@ -201,7 +238,7 @@ var Graphics = new Class({
201238 * @method Phaser.GameObjects.Graphics#setDefaultStyles
202239 * @since 3.0.0
203240 *
204- * @param {object } options - The styles to set as defaults.
241+ * @param {GraphicsStyles } options - The styles to set as defaults.
205242 *
206243 * @return {Phaser.GameObjects.Graphics } This Game Object.
207244 */
@@ -1039,13 +1076,13 @@ var Graphics = new Class({
10391076 } ,
10401077
10411078 /**
1042- * [description]
1079+ * Translate the graphics.
10431080 *
10441081 * @method Phaser.GameObjects.Graphics#translate
10451082 * @since 3.0.0
10461083 *
1047- * @param {number } x - [description]
1048- * @param {number } y - [description]
1084+ * @param {number } x - The horizontal translation to apply.
1085+ * @param {number } y - The vertical translation to apply.
10491086 *
10501087 * @return {Phaser.GameObjects.Graphics } This Game Object.
10511088 */
@@ -1060,13 +1097,13 @@ var Graphics = new Class({
10601097 } ,
10611098
10621099 /**
1063- * [description]
1100+ * Scale the graphics.
10641101 *
10651102 * @method Phaser.GameObjects.Graphics#scale
10661103 * @since 3.0.0
10671104 *
1068- * @param {number } x - [description]
1069- * @param {number } y - [description]
1105+ * @param {number } x - The horizontal scale to apply.
1106+ * @param {number } y - The vertical scale to apply.
10701107 *
10711108 * @return {Phaser.GameObjects.Graphics } This Game Object.
10721109 */
@@ -1081,12 +1118,12 @@ var Graphics = new Class({
10811118 } ,
10821119
10831120 /**
1084- * [description]
1121+ * Rotate the graphics.
10851122 *
10861123 * @method Phaser.GameObjects.Graphics#rotate
10871124 * @since 3.0.0
10881125 *
1089- * @param {number } radians - [description]
1126+ * @param {number } radians - The rotation angle, in radians.
10901127 *
10911128 * @return {Phaser.GameObjects.Graphics } This Game Object.
10921129 */
@@ -1101,7 +1138,7 @@ var Graphics = new Class({
11011138 } ,
11021139
11031140 /**
1104- * [description]
1141+ * Clear the command buffer and reset the fill style and line style to their defaults.
11051142 *
11061143 * @method Phaser.GameObjects.Graphics#clear
11071144 * @since 3.0.0
0 commit comments