all repos — simplyrpg @ dfcba4326868b0ff06cfa12c0f6a4ec2c688eb52

Fork of https://github.com/harperd1/simplyRPG — multi-map VTT, token visibility, dark theme, stream HUD

libraries/EaselJS_docs/files/easeljs_display_Graphics.js.html (view raw)

   1<!DOCTYPE html>
   2<html lang="en">
   3<head>
   4    <meta charset="utf-8">
   5    <link rel="stylesheet" href="../assets/css/yui-cssgrids-min.css">
   6    <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
   7    <link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
   8    <link rel="shortcut icon" type="image/x-icon" href="../assets/favicon.ico">
   9    <script src="../assets/js/yui-source.js"></script>
  10	<title>EaselJS v1.0.0 API Documentation : easeljs/display/Graphics.js</title>
  11</head>
  12<body class="yui3-skin-sam">
  13
  14<div id="doc">
  15    <div id="hd" class="yui3-g header">
  16        <div class="yui3-u-3-4">
  17            
  18                <h1><a href="http://www.createjs.com/easeljs"><img src="../assets/docs-icon-EaselJS.png" title="EaselJS"></a></h1>
  19            
  20        </div>
  21        <div class="version">
  22            <em>API Documentation for: 1.0.0</em>
  23        </div>
  24    </div>
  25    <div id="bd" class="yui3-g">
  26
  27        <div class="yui3-u-1-4">
  28            <div id="docs-sidebar" class="sidebar apidocs">
  29                <div id="api-list">
  30    <h2 class="off-left">APIs</h2>
  31    <div id="api-tabview" class="tabview">
  32        <ul class="tabs">
  33            <li><a href="#api-classes">Classes</a></li>
  34        </ul>
  35
  36        <div id="api-tabview-filter">
  37            <input type="search" id="api-filter" placeholder="Type to filter APIs">
  38        </div>
  39
  40        <div id="api-tabview-panel">
  41            <ul id="api-classes" class="apis classes">
  42            
  43                <li><a href="../classes/AlphaMapFilter.html">AlphaMapFilter</a></li>
  44            
  45                <li><a href="../classes/AlphaMaskFilter.html">AlphaMaskFilter</a></li>
  46            
  47                <li><a href="../classes/Bitmap.html">Bitmap</a></li>
  48            
  49                <li><a href="../classes/BitmapCache.html">BitmapCache</a></li>
  50            
  51                <li><a href="../classes/BitmapText.html">BitmapText</a></li>
  52            
  53                <li><a href="../classes/BlurFilter.html">BlurFilter</a></li>
  54            
  55                <li><a href="../classes/ButtonHelper.html">ButtonHelper</a></li>
  56            
  57                <li><a href="../classes/ColorFilter.html">ColorFilter</a></li>
  58            
  59                <li><a href="../classes/ColorMatrix.html">ColorMatrix</a></li>
  60            
  61                <li><a href="../classes/ColorMatrixFilter.html">ColorMatrixFilter</a></li>
  62            
  63                <li><a href="../classes/Container.html">Container</a></li>
  64            
  65                <li><a href="../classes/DisplayObject.html">DisplayObject</a></li>
  66            
  67                <li><a href="../classes/DisplayProps.html">DisplayProps</a></li>
  68            
  69                <li><a href="../classes/DOMElement.html">DOMElement</a></li>
  70            
  71                <li><a href="../classes/EaselJS.html">EaselJS</a></li>
  72            
  73                <li><a href="../classes/Event.html">Event</a></li>
  74            
  75                <li><a href="../classes/EventDispatcher.html">EventDispatcher</a></li>
  76            
  77                <li><a href="../classes/Filter.html">Filter</a></li>
  78            
  79                <li><a href="../classes/Graphics.html">Graphics</a></li>
  80            
  81                <li><a href="../classes/Graphics.Arc.html">Graphics.Arc</a></li>
  82            
  83                <li><a href="../classes/Graphics.ArcTo.html">Graphics.ArcTo</a></li>
  84            
  85                <li><a href="../classes/Graphics.BeginPath.html">Graphics.BeginPath</a></li>
  86            
  87                <li><a href="../classes/Graphics.BezierCurveTo.html">Graphics.BezierCurveTo</a></li>
  88            
  89                <li><a href="../classes/Graphics.Circle.html">Graphics.Circle</a></li>
  90            
  91                <li><a href="../classes/Graphics.ClosePath.html">Graphics.ClosePath</a></li>
  92            
  93                <li><a href="../classes/Graphics.Ellipse.html">Graphics.Ellipse</a></li>
  94            
  95                <li><a href="../classes/Graphics.Fill.html">Graphics.Fill</a></li>
  96            
  97                <li><a href="../classes/Graphics.LineTo.html">Graphics.LineTo</a></li>
  98            
  99                <li><a href="../classes/Graphics.MoveTo.html">Graphics.MoveTo</a></li>
 100            
 101                <li><a href="../classes/Graphics.PolyStar.html">Graphics.PolyStar</a></li>
 102            
 103                <li><a href="../classes/Graphics.QuadraticCurveTo.html">Graphics.QuadraticCurveTo</a></li>
 104            
 105                <li><a href="../classes/Graphics.Rect.html">Graphics.Rect</a></li>
 106            
 107                <li><a href="../classes/Graphics.RoundRect.html">Graphics.RoundRect</a></li>
 108            
 109                <li><a href="../classes/Graphics.Stroke.html">Graphics.Stroke</a></li>
 110            
 111                <li><a href="../classes/Graphics.StrokeDash.html">Graphics.StrokeDash</a></li>
 112            
 113                <li><a href="../classes/Graphics.StrokeStyle.html">Graphics.StrokeStyle</a></li>
 114            
 115                <li><a href="../classes/Matrix2D.html">Matrix2D</a></li>
 116            
 117                <li><a href="../classes/MouseEvent.html">MouseEvent</a></li>
 118            
 119                <li><a href="../classes/MovieClip.html">MovieClip</a></li>
 120            
 121                <li><a href="../classes/MovieClipPlugin.html">MovieClipPlugin</a></li>
 122            
 123                <li><a href="../classes/Point.html">Point</a></li>
 124            
 125                <li><a href="../classes/Rectangle.html">Rectangle</a></li>
 126            
 127                <li><a href="../classes/Shadow.html">Shadow</a></li>
 128            
 129                <li><a href="../classes/Shape.html">Shape</a></li>
 130            
 131                <li><a href="../classes/Sprite.html">Sprite</a></li>
 132            
 133                <li><a href="../classes/SpriteSheet.html">SpriteSheet</a></li>
 134            
 135                <li><a href="../classes/SpriteSheetBuilder.html">SpriteSheetBuilder</a></li>
 136            
 137                <li><a href="../classes/SpriteSheetUtils.html">SpriteSheetUtils</a></li>
 138            
 139                <li><a href="../classes/Stage.html">Stage</a></li>
 140            
 141                <li><a href="../classes/StageGL.html">StageGL</a></li>
 142            
 143                <li><a href="../classes/Text.html">Text</a></li>
 144            
 145                <li><a href="../classes/Ticker.html">Ticker</a></li>
 146            
 147                <li><a href="../classes/Touch.html">Touch</a></li>
 148            
 149                <li><a href="../classes/UID.html">UID</a></li>
 150            
 151                <li><a href="../classes/Utility Methods.html">Utility Methods</a></li>
 152            
 153                <li><a href="../classes/VideoBuffer.html">VideoBuffer</a></li>
 154            
 155                <li><a href="../classes/WebGLInspector.html">WebGLInspector</a></li>
 156            
 157            </ul>
 158
 159            <ul id="api-modules" class="apis modules">
 160            
 161                <li><a href="../modules/CreateJS.html">CreateJS</a></li>
 162            
 163                <li><a href="../modules/EaselJS.html">EaselJS</a></li>
 164            
 165            </ul>
 166        </div>
 167    </div>
 168</div>
 169
 170            </div>
 171        </div>
 172        <div class="yui3-u-3-4">
 173            <div id="api-options">
 174        Show:
 175        <label for="api-show-inherited">
 176            <input type="checkbox" id="api-show-inherited" checked>
 177            Inherited
 178        </label>
 179
 180        <label for="api-show-protected">
 181            <input type="checkbox" id="api-show-protected">
 182            Protected
 183        </label>
 184
 185        <label for="api-show-private">
 186            <input type="checkbox" id="api-show-private">
 187            Private
 188        </label>
 189        <label for="api-show-deprecated">
 190            <input type="checkbox" id="api-show-deprecated">
 191            Deprecated
 192        </label>
 193
 194    </div>
 195            <div class="apidocs">
 196                <div id="docs-main">
 197                    <div class="content source-content">
 198                        <script>
 199	var name = easeljs/display/Graphics.js      
 200</script>
 201<h1 class="file-heading">File:Graphics.js</h1>
 202
 203<div class="file">
 204    <pre class="code prettyprint linenums">
 205/*
 206* Graphics
 207* Visit http://createjs.com/ for documentation, updates and examples.
 208*
 209* Copyright (c) 2010 gskinner.com, inc.
 210*
 211* Permission is hereby granted, free of charge, to any person
 212* obtaining a copy of this software and associated documentation
 213* files (the &quot;Software&quot;), to deal in the Software without
 214* restriction, including without limitation the rights to use,
 215* copy, modify, merge, publish, distribute, sublicense, and/or sell
 216* copies of the Software, and to permit persons to whom the
 217* Software is furnished to do so, subject to the following
 218* conditions:
 219*
 220* The above copyright notice and this permission notice shall be
 221* included in all copies or substantial portions of the Software.
 222*
 223* THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND,
 224* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 225* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 226* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 227* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 228* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 229* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 230* OTHER DEALINGS IN THE SOFTWARE.
 231*/
 232
 233/**
 234 * @module EaselJS
 235 */
 236
 237// namespace:
 238this.createjs = this.createjs||{};
 239
 240(function() {
 241	&quot;use strict&quot;;
 242
 243
 244// constructor:
 245	/**
 246	 * The Graphics class exposes an easy to use API for generating vector drawing instructions and drawing them to a
 247	 * specified context. Note that you can use Graphics without any dependency on the EaselJS framework by calling {{#crossLink &quot;Graphics/draw&quot;}}{{/crossLink}}
 248	 * directly, or it can be used with the {{#crossLink &quot;Shape&quot;}}{{/crossLink}} object to draw vector graphics within the
 249	 * context of an EaselJS display list.
 250	 *
 251	 * There are two approaches to working with Graphics object: calling methods on a Graphics instance (the &quot;Graphics API&quot;), or
 252	 * instantiating Graphics command objects and adding them to the graphics queue via {{#crossLink &quot;Graphics/append&quot;}}{{/crossLink}}.
 253	 * The former abstracts the latter, simplifying beginning and ending paths, fills, and strokes.
 254	 *
 255	 *      var g = new createjs.Graphics();
 256	 *      g.setStrokeStyle(1);
 257	 *      g.beginStroke(&quot;#000000&quot;);
 258	 *      g.beginFill(&quot;red&quot;);
 259	 *      g.drawCircle(0,0,30);
 260	 *
 261	 * All drawing methods in Graphics return the Graphics instance, so they can be chained together. For example,
 262	 * the following line of code would generate the instructions to draw a rectangle with a red stroke and blue fill:
 263	 *
 264	 *      myGraphics.beginStroke(&quot;red&quot;).beginFill(&quot;blue&quot;).drawRect(20, 20, 100, 50);
 265	 *
 266	 * Each graphics API call generates a command object (see below). The last command to be created can be accessed via
 267	 * {{#crossLink &quot;Graphics/command:property&quot;}}{{/crossLink}}:
 268	 *
 269	 *      var fillCommand = myGraphics.beginFill(&quot;red&quot;).command;
 270	 *      // ... later, update the fill style/color:
 271	 *      fillCommand.style = &quot;blue&quot;;
 272	 *      // or change it to a bitmap fill:
 273	 *      fillCommand.bitmap(myImage);
 274	 *
 275	 * For more direct control of rendering, you can instantiate and append command objects to the graphics queue directly. In this case, you
 276	 * need to manage path creation manually, and ensure that fill/stroke is applied to a defined path:
 277	 *
 278	 *      // start a new path. Graphics.beginCmd is a reusable BeginPath instance:
 279	 *      myGraphics.append(createjs.Graphics.beginCmd);
 280	 *      // we need to define the path before applying the fill:
 281	 *      var circle = new createjs.Graphics.Circle(0,0,30);
 282	 *      myGraphics.append(circle);
 283	 *      // fill the path we just defined:
 284	 *      var fill = new createjs.Graphics.Fill(&quot;red&quot;);
 285	 *      myGraphics.append(fill);
 286	 *
 287	 * These approaches can be used together, for example to insert a custom command:
 288	 *
 289	 *      myGraphics.beginFill(&quot;red&quot;);
 290	 *      var customCommand = new CustomSpiralCommand(etc);
 291	 *      myGraphics.append(customCommand);
 292	 *      myGraphics.beginFill(&quot;blue&quot;);
 293	 *      myGraphics.drawCircle(0, 0, 30);
 294	 *
 295	 * See {{#crossLink &quot;Graphics/append&quot;}}{{/crossLink}} for more info on creating custom commands.
 296	 *
 297	 * &lt;h4&gt;Tiny API&lt;/h4&gt;
 298	 * The Graphics class also includes a &quot;tiny API&quot;, which is one or two-letter methods that are shortcuts for all of the
 299	 * Graphics methods. These methods are great for creating compact instructions, and is used by the Toolkit for CreateJS
 300	 * to generate readable code. All tiny methods are marked as protected, so you can view them by enabling protected
 301	 * descriptions in the docs.
 302	 *
 303	 * &lt;table&gt;
 304	 *     &lt;tr&gt;&lt;td&gt;&lt;b&gt;Tiny&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;b&gt;Method&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;b&gt;Tiny&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;b&gt;Method&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
 305	 *     &lt;tr&gt;&lt;td&gt;mt&lt;/td&gt;&lt;td&gt;{{#crossLink &quot;Graphics/moveTo&quot;}}{{/crossLink}} &lt;/td&gt;
 306	 *     &lt;td&gt;lt&lt;/td&gt; &lt;td&gt;{{#crossLink &quot;Graphics/lineTo&quot;}}{{/crossLink}}&lt;/td&gt;&lt;/tr&gt;
 307	 *     &lt;tr&gt;&lt;td&gt;a/at&lt;/td&gt;&lt;td&gt;{{#crossLink &quot;Graphics/arc&quot;}}{{/crossLink}} / {{#crossLink &quot;Graphics/arcTo&quot;}}{{/crossLink}} &lt;/td&gt;
 308	 *     &lt;td&gt;bt&lt;/td&gt;&lt;td&gt;{{#crossLink &quot;Graphics/bezierCurveTo&quot;}}{{/crossLink}} &lt;/td&gt;&lt;/tr&gt;
 309	 *     &lt;tr&gt;&lt;td&gt;qt&lt;/td&gt;&lt;td&gt;{{#crossLink &quot;Graphics/quadraticCurveTo&quot;}}{{/crossLink}} (also curveTo)&lt;/td&gt;
 310	 *     &lt;td&gt;r&lt;/td&gt;&lt;td&gt;{{#crossLink &quot;Graphics/rect&quot;}}{{/crossLink}} &lt;/td&gt;&lt;/tr&gt;
 311	 *     &lt;tr&gt;&lt;td&gt;cp&lt;/td&gt;&lt;td&gt;{{#crossLink &quot;Graphics/closePath&quot;}}{{/crossLink}} &lt;/td&gt;
 312	 *     &lt;td&gt;c&lt;/td&gt;&lt;td&gt;{{#crossLink &quot;Graphics/clear&quot;}}{{/crossLink}} &lt;/td&gt;&lt;/tr&gt;
 313	 *     &lt;tr&gt;&lt;td&gt;f&lt;/td&gt;&lt;td&gt;{{#crossLink &quot;Graphics/beginFill&quot;}}{{/crossLink}} &lt;/td&gt;
 314	 *     &lt;td&gt;lf&lt;/td&gt;&lt;td&gt;{{#crossLink &quot;Graphics/beginLinearGradientFill&quot;}}{{/crossLink}} &lt;/td&gt;&lt;/tr&gt;
 315	 *     &lt;tr&gt;&lt;td&gt;rf&lt;/td&gt;&lt;td&gt;{{#crossLink &quot;Graphics/beginRadialGradientFill&quot;}}{{/crossLink}} &lt;/td&gt;
 316	 *     &lt;td&gt;bf&lt;/td&gt;&lt;td&gt;{{#crossLink &quot;Graphics/beginBitmapFill&quot;}}{{/crossLink}} &lt;/td&gt;&lt;/tr&gt;
 317	 *     &lt;tr&gt;&lt;td&gt;ef&lt;/td&gt;&lt;td&gt;{{#crossLink &quot;Graphics/endFill&quot;}}{{/crossLink}} &lt;/td&gt;
 318	 *     &lt;td&gt;ss / sd&lt;/td&gt;&lt;td&gt;{{#crossLink &quot;Graphics/setStrokeStyle&quot;}}{{/crossLink}} / {{#crossLink &quot;Graphics/setStrokeDash&quot;}}{{/crossLink}} &lt;/td&gt;&lt;/tr&gt;
 319	 *     &lt;tr&gt;&lt;td&gt;s&lt;/td&gt;&lt;td&gt;{{#crossLink &quot;Graphics/beginStroke&quot;}}{{/crossLink}} &lt;/td&gt;
 320	 *     &lt;td&gt;ls&lt;/td&gt;&lt;td&gt;{{#crossLink &quot;Graphics/beginLinearGradientStroke&quot;}}{{/crossLink}} &lt;/td&gt;&lt;/tr&gt;
 321	 *     &lt;tr&gt;&lt;td&gt;rs&lt;/td&gt;&lt;td&gt;{{#crossLink &quot;Graphics/beginRadialGradientStroke&quot;}}{{/crossLink}} &lt;/td&gt;
 322	 *     &lt;td&gt;bs&lt;/td&gt;&lt;td&gt;{{#crossLink &quot;Graphics/beginBitmapStroke&quot;}}{{/crossLink}} &lt;/td&gt;&lt;/tr&gt;
 323	 *     &lt;tr&gt;&lt;td&gt;es&lt;/td&gt;&lt;td&gt;{{#crossLink &quot;Graphics/endStroke&quot;}}{{/crossLink}} &lt;/td&gt;
 324	 *     &lt;td&gt;dr&lt;/td&gt;&lt;td&gt;{{#crossLink &quot;Graphics/drawRect&quot;}}{{/crossLink}} &lt;/td&gt;&lt;/tr&gt;
 325	 *     &lt;tr&gt;&lt;td&gt;rr&lt;/td&gt;&lt;td&gt;{{#crossLink &quot;Graphics/drawRoundRect&quot;}}{{/crossLink}} &lt;/td&gt;
 326	 *     &lt;td&gt;rc&lt;/td&gt;&lt;td&gt;{{#crossLink &quot;Graphics/drawRoundRectComplex&quot;}}{{/crossLink}} &lt;/td&gt;&lt;/tr&gt;
 327	 *     &lt;tr&gt;&lt;td&gt;dc&lt;/td&gt;&lt;td&gt;{{#crossLink &quot;Graphics/drawCircle&quot;}}{{/crossLink}} &lt;/td&gt;
 328	 *     &lt;td&gt;de&lt;/td&gt;&lt;td&gt;{{#crossLink &quot;Graphics/drawEllipse&quot;}}{{/crossLink}} &lt;/td&gt;&lt;/tr&gt;
 329	 *     &lt;tr&gt;&lt;td&gt;dp&lt;/td&gt;&lt;td&gt;{{#crossLink &quot;Graphics/drawPolyStar&quot;}}{{/crossLink}} &lt;/td&gt;
 330	 *     &lt;td&gt;p&lt;/td&gt;&lt;td&gt;{{#crossLink &quot;Graphics/decodePath&quot;}}{{/crossLink}} &lt;/td&gt;&lt;/tr&gt;
 331	 * &lt;/table&gt;
 332	 *
 333	 * Here is the above example, using the tiny API instead.
 334	 *
 335	 *      myGraphics.s(&quot;red&quot;).f(&quot;blue&quot;).r(20, 20, 100, 50);
 336	 *
 337	 * @class Graphics
 338	 * @constructor
 339	 **/
 340	function Graphics() {
 341
 342
 343	// public properties
 344		/**
 345		 * Holds a reference to the last command that was created or appended. For example, you could retain a reference
 346		 * to a Fill command in order to dynamically update the color later by using:
 347		 *
 348		 * 		var myFill = myGraphics.beginFill(&quot;red&quot;).command;
 349		 * 		// update color later:
 350		 * 		myFill.style = &quot;yellow&quot;;
 351		 *
 352		 * @property command
 353		 * @type Object
 354		 **/
 355		this.command = null;
 356
 357
 358	// private properties
 359		/**
 360		 * @property _stroke
 361		 * @protected
 362		 * @type {Stroke}
 363		 **/
 364		this._stroke = null;
 365
 366		/**
 367		 * @property _strokeStyle
 368		 * @protected
 369		 * @type {StrokeStyle}
 370		 **/
 371		this._strokeStyle = null;
 372		
 373		/**
 374		 * @property _oldStrokeStyle
 375		 * @protected
 376		 * @type {StrokeStyle}
 377		 **/
 378		this._oldStrokeStyle = null;
 379		
 380		/**
 381		 * @property _strokeDash
 382		 * @protected
 383		 * @type {StrokeDash}
 384		 **/
 385		this._strokeDash = null;
 386		
 387		/**
 388		 * @property _oldStrokeDash
 389		 * @protected
 390		 * @type {StrokeDash}
 391		 **/
 392		this._oldStrokeDash = null;
 393
 394		/**
 395		 * @property _strokeIgnoreScale
 396		 * @protected
 397		 * @type Boolean
 398		 **/
 399		this._strokeIgnoreScale = false;
 400
 401		/**
 402		 * @property _fill
 403		 * @protected
 404		 * @type {Fill}
 405		 **/
 406		this._fill = null;
 407
 408		/**
 409		 * @property _instructions
 410		 * @protected
 411		 * @type {Array}
 412		 **/
 413		this._instructions = [];
 414
 415		/**
 416		 * Indicates the last instruction index that was committed.
 417		 * @property _commitIndex
 418		 * @protected
 419		 * @type {Number}
 420		 **/
 421		this._commitIndex = 0;
 422
 423		/**
 424		 * Uncommitted instructions.
 425		 * @property _activeInstructions
 426		 * @protected
 427		 * @type {Array}
 428		 **/
 429		this._activeInstructions = [];
 430
 431		/**
 432		 * This indicates that there have been changes to the activeInstruction list since the last updateInstructions call.
 433		 * @property _dirty
 434		 * @protected
 435		 * @type {Boolean}
 436		 * @default false
 437		 **/
 438		this._dirty = false;
 439
 440		/**
 441		 * Index to draw from if a store operation has happened.
 442		 * @property _storeIndex
 443		 * @protected
 444		 * @type {Number}
 445		 * @default 0
 446		 **/
 447		this._storeIndex = 0;
 448
 449	// setup:
 450		this.clear();
 451	}
 452	var p = Graphics.prototype;
 453	var G = Graphics; // shortcut
 454
 455// static public methods:
 456	/**
 457	 * Returns a CSS compatible color string based on the specified RGB numeric color values in the format
 458	 * &quot;rgba(255,255,255,1.0)&quot;, or if alpha is null then in the format &quot;rgb(255,255,255)&quot;. For example,
 459	 *
 460	 *      createjs.Graphics.getRGB(50, 100, 150, 0.5);
 461	 *      // Returns &quot;rgba(50,100,150,0.5)&quot;
 462	 *
 463	 * It also supports passing a single hex color value as the first param, and an optional alpha value as the second
 464	 * param. For example,
 465	 *
 466	 *      createjs.Graphics.getRGB(0xFF00FF, 0.2);
 467	 *      // Returns &quot;rgba(255,0,255,0.2)&quot;
 468	 *
 469	 * @method getRGB
 470	 * @static
 471	 * @param {Number} r The red component for the color, between 0 and 0xFF (255).
 472	 * @param {Number} g The green component for the color, between 0 and 0xFF (255).
 473	 * @param {Number} b The blue component for the color, between 0 and 0xFF (255).
 474	 * @param {Number} [alpha] The alpha component for the color where 0 is fully transparent and 1 is fully opaque.
 475	 * @return {String} A CSS compatible color string based on the specified RGB numeric color values in the format
 476	 * &quot;rgba(255,255,255,1.0)&quot;, or if alpha is null then in the format &quot;rgb(255,255,255)&quot;.
 477	 **/
 478	Graphics.getRGB = function(r, g, b, alpha) {
 479		if (r != null &amp;&amp; b == null) {
 480			alpha = g;
 481			b = r&amp;0xFF;
 482			g = r&gt;&gt;8&amp;0xFF;
 483			r = r&gt;&gt;16&amp;0xFF;
 484		}
 485		if (alpha == null) {
 486			return &quot;rgb(&quot;+r+&quot;,&quot;+g+&quot;,&quot;+b+&quot;)&quot;;
 487		} else {
 488			return &quot;rgba(&quot;+r+&quot;,&quot;+g+&quot;,&quot;+b+&quot;,&quot;+alpha+&quot;)&quot;;
 489		}
 490	};
 491
 492	/**
 493	 * Returns a CSS compatible color string based on the specified HSL numeric color values in the format &quot;hsla(360,100,100,1.0)&quot;,
 494	 * or if alpha is null then in the format &quot;hsl(360,100,100)&quot;.
 495	 *
 496	 *      createjs.Graphics.getHSL(150, 100, 70);
 497	 *      // Returns &quot;hsl(150,100,70)&quot;
 498	 *
 499	 * @method getHSL
 500	 * @static
 501	 * @param {Number} hue The hue component for the color, between 0 and 360.
 502	 * @param {Number} saturation The saturation component for the color, between 0 and 100.
 503	 * @param {Number} lightness The lightness component for the color, between 0 and 100.
 504	 * @param {Number} [alpha] The alpha component for the color where 0 is fully transparent and 1 is fully opaque.
 505	 * @return {String} A CSS compatible color string based on the specified HSL numeric color values in the format
 506	 * &quot;hsla(360,100,100,1.0)&quot;, or if alpha is null then in the format &quot;hsl(360,100,100)&quot;.
 507	 **/
 508	Graphics.getHSL = function(hue, saturation, lightness, alpha) {
 509		if (alpha == null) {
 510			return &quot;hsl(&quot;+(hue%360)+&quot;,&quot;+saturation+&quot;%,&quot;+lightness+&quot;%)&quot;;
 511		} else {
 512			return &quot;hsla(&quot;+(hue%360)+&quot;,&quot;+saturation+&quot;%,&quot;+lightness+&quot;%,&quot;+alpha+&quot;)&quot;;
 513		}
 514	};
 515
 516
 517// static properties:
 518	/**
 519	 * A reusable instance of {{#crossLink &quot;Graphics/BeginPath&quot;}}{{/crossLink}} to avoid
 520	 * unnecessary instantiation.
 521	 * @property beginCmd
 522	 * @type {Graphics.BeginPath}
 523	 * @static
 524	 **/
 525	 // defined at the bottom of this file.
 526
 527	/**
 528	 * Map of Base64 characters to values. Used by {{#crossLink &quot;Graphics/decodePath&quot;}}{{/crossLink}}.
 529	 * @property BASE_64
 530	 * @static
 531	 * @final
 532	 * @readonly
 533	 * @type {Object}
 534	 **/
 535	Graphics.BASE_64 = {&quot;A&quot;:0,&quot;B&quot;:1,&quot;C&quot;:2,&quot;D&quot;:3,&quot;E&quot;:4,&quot;F&quot;:5,&quot;G&quot;:6,&quot;H&quot;:7,&quot;I&quot;:8,&quot;J&quot;:9,&quot;K&quot;:10,&quot;L&quot;:11,&quot;M&quot;:12,&quot;N&quot;:13,&quot;O&quot;:14,&quot;P&quot;:15,&quot;Q&quot;:16,&quot;R&quot;:17,&quot;S&quot;:18,&quot;T&quot;:19,&quot;U&quot;:20,&quot;V&quot;:21,&quot;W&quot;:22,&quot;X&quot;:23,&quot;Y&quot;:24,&quot;Z&quot;:25,&quot;a&quot;:26,&quot;b&quot;:27,&quot;c&quot;:28,&quot;d&quot;:29,&quot;e&quot;:30,&quot;f&quot;:31,&quot;g&quot;:32,&quot;h&quot;:33,&quot;i&quot;:34,&quot;j&quot;:35,&quot;k&quot;:36,&quot;l&quot;:37,&quot;m&quot;:38,&quot;n&quot;:39,&quot;o&quot;:40,&quot;p&quot;:41,&quot;q&quot;:42,&quot;r&quot;:43,&quot;s&quot;:44,&quot;t&quot;:45,&quot;u&quot;:46,&quot;v&quot;:47,&quot;w&quot;:48,&quot;x&quot;:49,&quot;y&quot;:50,&quot;z&quot;:51,&quot;0&quot;:52,&quot;1&quot;:53,&quot;2&quot;:54,&quot;3&quot;:55,&quot;4&quot;:56,&quot;5&quot;:57,&quot;6&quot;:58,&quot;7&quot;:59,&quot;8&quot;:60,&quot;9&quot;:61,&quot;+&quot;:62,&quot;/&quot;:63};
 536
 537	/**
 538	 * Maps numeric values for the caps parameter of {{#crossLink &quot;Graphics/setStrokeStyle&quot;}}{{/crossLink}} to
 539	 * corresponding string values. This is primarily for use with the tiny API. The mappings are as follows: 0 to
 540	 * &quot;butt&quot;, 1 to &quot;round&quot;, and 2 to &quot;square&quot;.
 541	 * For example, to set the line caps to &quot;square&quot;:
 542	 *
 543	 *      myGraphics.ss(16, 2);
 544	 *
 545	 * @property STROKE_CAPS_MAP
 546	 * @static
 547	 * @final
 548	 * @readonly
 549	 * @type {Array}
 550	 **/
 551	Graphics.STROKE_CAPS_MAP = [&quot;butt&quot;, &quot;round&quot;, &quot;square&quot;];
 552
 553	/**
 554	 * Maps numeric values for the joints parameter of {{#crossLink &quot;Graphics/setStrokeStyle&quot;}}{{/crossLink}} to
 555	 * corresponding string values. This is primarily for use with the tiny API. The mappings are as follows: 0 to
 556	 * &quot;miter&quot;, 1 to &quot;round&quot;, and 2 to &quot;bevel&quot;.
 557	 * For example, to set the line joints to &quot;bevel&quot;:
 558	 *
 559	 *      myGraphics.ss(16, 0, 2);
 560	 *
 561	 * @property STROKE_JOINTS_MAP
 562	 * @static
 563	 * @final
 564	 * @readonly
 565	 * @type {Array}
 566	 **/
 567	Graphics.STROKE_JOINTS_MAP = [&quot;miter&quot;, &quot;round&quot;, &quot;bevel&quot;];
 568
 569	/**
 570	 * @property _ctx
 571	 * @static
 572	 * @protected
 573	 * @type {CanvasRenderingContext2D}
 574	 **/
 575	var canvas = (createjs.createCanvas?createjs.createCanvas():document.createElement(&quot;canvas&quot;));
 576	if (canvas.getContext) {
 577		Graphics._ctx = canvas.getContext(&quot;2d&quot;);
 578		canvas.width = canvas.height = 1;
 579	}
 580
 581
 582// getter / setters:
 583	/**
 584	 * Use the {{#crossLink &quot;Graphics/instructions:property&quot;}}{{/crossLink}} property instead.
 585	 * @method _getInstructions
 586	 * @protected
 587	 * @return {Array} The instructions array, useful for chaining
 588	 **/
 589	p._getInstructions = function() {
 590		this._updateInstructions();
 591		return this._instructions;
 592	};
 593	// Graphics.getInstructions is @deprecated. Remove for 1.1+
 594	p.getInstructions = createjs.deprecate(p._getInstructions, &quot;Graphics.getInstructions&quot;);
 595
 596	/**
 597	 * Returns the graphics instructions array. Each entry is a graphics command object (ex. Graphics.Fill, Graphics.Rect)
 598	 * Modifying the returned array directly is not recommended, and is likely to result in unexpected behaviour.
 599	 *
 600	 * This property is mainly intended for introspection of the instructions (ex. for graphics export).
 601	 * @property instructions
 602	 * @type {Array}
 603	 * @readonly
 604	 **/
 605	try {
 606		Object.defineProperties(p, {
 607			instructions: { get: p._getInstructions }
 608		});
 609	} catch (e) {}
 610
 611
 612// public methods:
 613	/**
 614	 * Returns true if this Graphics instance has no drawing commands.
 615	 * @method isEmpty
 616	 * @return {Boolean} Returns true if this Graphics instance has no drawing commands.
 617	 **/
 618	p.isEmpty = function() {
 619		return !(this._instructions.length || this._activeInstructions.length);
 620	};
 621
 622	/**
 623	 * Draws the display object into the specified context ignoring its visible, alpha, shadow, and transform.
 624	 * Returns true if the draw was handled (useful for overriding functionality).
 625	 *
 626	 * NOTE: This method is mainly for internal use, though it may be useful for advanced uses.
 627	 * @method draw
 628	 * @param {CanvasRenderingContext2D} ctx The canvas 2D context object to draw into.
 629	 * @param {Object} data Optional data that is passed to graphics command exec methods. When called from a Shape instance, the shape passes itself as the data parameter. This can be used by custom graphic commands to insert contextual data.
 630	 **/
 631	p.draw = function(ctx, data) {
 632		this._updateInstructions();
 633		var instr = this._instructions;
 634		for (var i=this._storeIndex, l=instr.length; i&lt;l; i++) {
 635			instr[i].exec(ctx, data);
 636		}
 637	};
 638
 639	/**
 640	 * Draws only the path described for this Graphics instance, skipping any non-path instructions, including fill and
 641	 * stroke descriptions. Used for &lt;code&gt;DisplayObject.mask&lt;/code&gt; to draw the clipping path, for example.
 642	 *
 643	 * NOTE: This method is mainly for internal use, though it may be useful for advanced uses.
 644	 * @method drawAsPath
 645	 * @param {CanvasRenderingContext2D} ctx The canvas 2D context object to draw into.
 646	 **/
 647	p.drawAsPath = function(ctx) {
 648		this._updateInstructions();
 649		var instr, instrs = this._instructions;
 650		for (var i=this._storeIndex, l=instrs.length; i&lt;l; i++) {
 651			// the first command is always a beginPath command.
 652			if ((instr = instrs[i]).path !== false) { instr.exec(ctx); }
 653		}
 654	};
 655
 656
 657// public methods that map directly to context 2D calls:
 658	/**
 659	 * Moves the drawing point to the specified position. A tiny API method &quot;mt&quot; also exists.
 660	 * @method moveTo
 661	 * @param {Number} x The x coordinate the drawing point should move to.
 662	 * @param {Number} y The y coordinate the drawing point should move to.
 663	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls).
 664	 * @chainable
 665	 **/
 666	p.moveTo = function(x, y) {
 667		return this.append(new G.MoveTo(x,y), true);
 668	};
 669
 670	/**
 671	 * Draws a line from the current drawing point to the specified position, which become the new current drawing
 672	 * point. Note that you *must* call {{#crossLink &quot;Graphics/moveTo&quot;}}{{/crossLink}} before the first &#x60;lineTo()&#x60;.
 673	 * A tiny API method &quot;lt&quot; also exists.
 674	 *
 675	 * For detailed information, read the
 676	 * &lt;a href=&quot;http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#complex-shapes-(paths)&quot;&gt;
 677	 * whatwg spec&lt;/a&gt;.
 678	 * @method lineTo
 679	 * @param {Number} x The x coordinate the drawing point should draw to.
 680	 * @param {Number} y The y coordinate the drawing point should draw to.
 681	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
 682	 * @chainable
 683	 **/
 684	p.lineTo = function(x, y) {
 685		return this.append(new G.LineTo(x,y));
 686	};
 687
 688	/**
 689	 * Draws an arc with the specified control points and radius.  For detailed information, read the
 690	 * &lt;a href=&quot;http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-arcto&quot;&gt;
 691	 * whatwg spec&lt;/a&gt;. A tiny API method &quot;at&quot; also exists.
 692	 * @method arcTo
 693	 * @param {Number} x1
 694	 * @param {Number} y1
 695	 * @param {Number} x2
 696	 * @param {Number} y2
 697	 * @param {Number} radius
 698	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
 699	 * @chainable
 700	 **/
 701	p.arcTo = function(x1, y1, x2, y2, radius) {
 702		return this.append(new G.ArcTo(x1, y1, x2, y2, radius));
 703	};
 704
 705	/**
 706	 * Draws an arc defined by the radius, startAngle and endAngle arguments, centered at the position (x, y). For
 707	 * example, to draw a full circle with a radius of 20 centered at (100, 100):
 708	 *
 709	 *      arc(100, 100, 20, 0, Math.PI*2);
 710	 *
 711	 * For detailed information, read the
 712	 * &lt;a href=&quot;http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-arc&quot;&gt;whatwg spec&lt;/a&gt;.
 713	 * A tiny API method &quot;a&quot; also exists.
 714	 * @method arc
 715	 * @param {Number} x
 716	 * @param {Number} y
 717	 * @param {Number} radius
 718	 * @param {Number} startAngle Measured in radians.
 719	 * @param {Number} endAngle Measured in radians.
 720	 * @param {Boolean} anticlockwise
 721	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
 722	 * @chainable
 723	 **/
 724	p.arc = function(x, y, radius, startAngle, endAngle, anticlockwise) {
 725		return this.append(new G.Arc(x, y, radius, startAngle, endAngle, anticlockwise));
 726	};
 727
 728	/**
 729	 * Draws a quadratic curve from the current drawing point to (x, y) using the control point (cpx, cpy). For detailed
 730	 * information, read the &lt;a href=&quot;http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-quadraticcurveto&quot;&gt;
 731	 * whatwg spec&lt;/a&gt;. A tiny API method &quot;qt&quot; also exists.
 732	 * @method quadraticCurveTo
 733	 * @param {Number} cpx
 734	 * @param {Number} cpy
 735	 * @param {Number} x
 736	 * @param {Number} y
 737	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
 738	 * @chainable
 739	 **/
 740	p.quadraticCurveTo = function(cpx, cpy, x, y) {
 741		return this.append(new G.QuadraticCurveTo(cpx, cpy, x, y));
 742	};
 743
 744	/**
 745	 * Draws a bezier curve from the current drawing point to (x, y) using the control points (cp1x, cp1y) and (cp2x,
 746	 * cp2y). For detailed information, read the
 747	 * &lt;a href=&quot;http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-beziercurveto&quot;&gt;
 748	 * whatwg spec&lt;/a&gt;. A tiny API method &quot;bt&quot; also exists.
 749	 * @method bezierCurveTo
 750	 * @param {Number} cp1x
 751	 * @param {Number} cp1y
 752	 * @param {Number} cp2x
 753	 * @param {Number} cp2y
 754	 * @param {Number} x
 755	 * @param {Number} y
 756	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
 757	 * @chainable
 758	 **/
 759	p.bezierCurveTo = function(cp1x, cp1y, cp2x, cp2y, x, y) {
 760		return this.append(new G.BezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y));
 761	};
 762
 763	/**
 764	 * Draws a rectangle at (x, y) with the specified width and height using the current fill and/or stroke.
 765	 * For detailed information, read the
 766	 * &lt;a href=&quot;http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-rect&quot;&gt;
 767	 * whatwg spec&lt;/a&gt;. A tiny API method &quot;r&quot; also exists.
 768	 * @method rect
 769	 * @param {Number} x
 770	 * @param {Number} y
 771	 * @param {Number} w Width of the rectangle
 772	 * @param {Number} h Height of the rectangle
 773	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
 774	 * @chainable
 775	 **/
 776	p.rect = function(x, y, w, h) {
 777		return this.append(new G.Rect(x, y, w, h));
 778	};
 779
 780	/**
 781	 * Closes the current path, effectively drawing a line from the current drawing point to the first drawing point specified
 782	 * since the fill or stroke was last set. A tiny API method &quot;cp&quot; also exists.
 783	 * @method closePath
 784	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
 785	 * @chainable
 786	 **/
 787	p.closePath = function() {
 788		return this._activeInstructions.length ? this.append(new G.ClosePath()) : this;
 789	};
 790
 791
 792// public methods that roughly map to Adobe Flash/Animate graphics APIs:
 793	/**
 794	 * Clears all drawing instructions, effectively resetting this Graphics instance. Any line and fill styles will need
 795	 * to be redefined to draw shapes following a clear call. A tiny API method &quot;c&quot; also exists.
 796	 * @method clear
 797	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
 798	 * @chainable
 799	 **/
 800	p.clear = function() {
 801		this._instructions.length = this._activeInstructions.length = this._commitIndex = 0;
 802		this._strokeStyle = this._oldStrokeStyle = this._stroke = this._fill = this._strokeDash = this._oldStrokeDash = null;
 803		this._dirty = this._strokeIgnoreScale = false;
 804		return this;
 805	};
 806
 807	/**
 808	 * Begins a fill with the specified color. This ends the current sub-path. A tiny API method &quot;f&quot; also exists.
 809	 * @method beginFill
 810	 * @param {String} color A CSS compatible color value (ex. &quot;red&quot;, &quot;#FF0000&quot;, or &quot;rgba(255,0,0,0.5)&quot;). Setting to
 811	 * null will result in no fill.
 812	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
 813	 * @chainable
 814	 **/
 815	p.beginFill = function(color) {
 816		return this._setFill(color ? new G.Fill(color) : null);
 817	};
 818
 819	/**
 820	 * Begins a linear gradient fill defined by the line (x0, y0) to (x1, y1). This ends the current sub-path. For
 821	 * example, the following code defines a black to white vertical gradient ranging from 20px to 120px, and draws a
 822	 * square to display it:
 823	 *
 824	 *      myGraphics.beginLinearGradientFill([&quot;#000&quot;,&quot;#FFF&quot;], [0, 1], 0, 20, 0, 120).drawRect(20, 20, 120, 120);
 825	 *
 826	 * A tiny API method &quot;lf&quot; also exists.
 827	 * @method beginLinearGradientFill
 828	 * @param {Array} colors An array of CSS compatible color values. For example, [&quot;#F00&quot;,&quot;#00F&quot;] would define a gradient
 829	 * drawing from red to blue.
 830	 * @param {Array} ratios An array of gradient positions which correspond to the colors. For example, [0.1, 0.9] would draw
 831	 * the first color to 10% then interpolating to the second color at 90%.
 832	 * @param {Number} x0 The position of the first point defining the line that defines the gradient direction and size.
 833	 * @param {Number} y0 The position of the first point defining the line that defines the gradient direction and size.
 834	 * @param {Number} x1 The position of the second point defining the line that defines the gradient direction and size.
 835	 * @param {Number} y1 The position of the second point defining the line that defines the gradient direction and size.
 836	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
 837	 * @chainable
 838	 **/
 839	p.beginLinearGradientFill = function(colors, ratios, x0, y0, x1, y1) {
 840		return this._setFill(new G.Fill().linearGradient(colors, ratios, x0, y0, x1, y1));
 841	};
 842
 843	/**
 844	 * Begins a radial gradient fill. This ends the current sub-path. For example, the following code defines a red to
 845	 * blue radial gradient centered at (100, 100), with a radius of 50, and draws a circle to display it:
 846	 *
 847	 *      myGraphics.beginRadialGradientFill([&quot;#F00&quot;,&quot;#00F&quot;], [0, 1], 100, 100, 0, 100, 100, 50).drawCircle(100, 100, 50);
 848	 *
 849	 * A tiny API method &quot;rf&quot; also exists.
 850	 * @method beginRadialGradientFill
 851	 * @param {Array} colors An array of CSS compatible color values. For example, [&quot;#F00&quot;,&quot;#00F&quot;] would define
 852	 * a gradient drawing from red to blue.
 853	 * @param {Array} ratios An array of gradient positions which correspond to the colors. For example, [0.1,
 854	 * 0.9] would draw the first color to 10% then interpolating to the second color at 90%.
 855	 * @param {Number} x0 Center position of the inner circle that defines the gradient.
 856	 * @param {Number} y0 Center position of the inner circle that defines the gradient.
 857	 * @param {Number} r0 Radius of the inner circle that defines the gradient.
 858	 * @param {Number} x1 Center position of the outer circle that defines the gradient.
 859	 * @param {Number} y1 Center position of the outer circle that defines the gradient.
 860	 * @param {Number} r1 Radius of the outer circle that defines the gradient.
 861	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
 862	 * @chainable
 863	 **/
 864	p.beginRadialGradientFill = function(colors, ratios, x0, y0, r0, x1, y1, r1) {
 865		return this._setFill(new G.Fill().radialGradient(colors, ratios, x0, y0, r0, x1, y1, r1));
 866	};
 867
 868	/**
 869	 * Begins a pattern fill using the specified image. This ends the current sub-path. A tiny API method &quot;bf&quot; also
 870	 * exists.
 871	 * @method beginBitmapFill
 872	 * @param {HTMLImageElement | HTMLCanvasElement | HTMLVideoElement} image The Image, Canvas, or Video object to use
 873	 * as the pattern. Must be loaded prior to creating a bitmap fill, or the fill will be empty.
 874	 * @param {String} repetition Optional. Indicates whether to repeat the image in the fill area. One of &quot;repeat&quot;,
 875	 * &quot;repeat-x&quot;, &quot;repeat-y&quot;, or &quot;no-repeat&quot;. Defaults to &quot;repeat&quot;. Note that Firefox does not support &quot;repeat-x&quot; or
 876	 * &quot;repeat-y&quot; (latest tests were in FF 20.0), and will default to &quot;repeat&quot;.
 877	 * @param {Matrix2D} matrix Optional. Specifies a transformation matrix for the bitmap fill. This transformation
 878	 * will be applied relative to the parent transform.
 879	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
 880	 * @chainable
 881	 **/
 882	p.beginBitmapFill = function(image, repetition, matrix) {
 883		return this._setFill(new G.Fill(null,matrix).bitmap(image, repetition));
 884	};
 885
 886	/**
 887	 * Ends the current sub-path, and begins a new one with no fill. Functionally identical to &lt;code&gt;beginFill(null)&lt;/code&gt;.
 888	 * A tiny API method &quot;ef&quot; also exists.
 889	 * @method endFill
 890	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
 891	 * @chainable
 892	 **/
 893	p.endFill = function() {
 894		return this.beginFill();
 895	};
 896
 897	/**
 898	 * Sets the stroke style. Like all drawing methods, this can be chained, so you can define
 899	 * the stroke style and color in a single line of code like so:
 900	 *
 901	 * 	myGraphics.setStrokeStyle(8,&quot;round&quot;).beginStroke(&quot;#F00&quot;);
 902	 *
 903	 * A tiny API method &quot;ss&quot; also exists.
 904	 * @method setStrokeStyle
 905	 * @param {Number} thickness The width of the stroke.
 906	 * @param {String | Number} [caps=0] Indicates the type of caps to use at the end of lines. One of butt,
 907	 * round, or square. Defaults to &quot;butt&quot;. Also accepts the values 0 (butt), 1 (round), and 2 (square) for use with
 908	 * the tiny API.
 909	 * @param {String | Number} [joints=0] Specifies the type of joints that should be used where two lines meet.
 910	 * One of bevel, round, or miter. Defaults to &quot;miter&quot;. Also accepts the values 0 (miter), 1 (round), and 2 (bevel)
 911	 * for use with the tiny API.
 912	 * @param {Number} [miterLimit=10] If joints is set to &quot;miter&quot;, then you can specify a miter limit ratio which
 913	 * controls at what point a mitered joint will be clipped.
 914	 * @param {Boolean} [ignoreScale=false] If true, the stroke will be drawn at the specified thickness regardless
 915	 * of active transformations.
 916	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
 917	 * @chainable
 918	 **/
 919	p.setStrokeStyle = function(thickness, caps, joints, miterLimit, ignoreScale) {
 920		this._updateInstructions(true);
 921		this._strokeStyle = this.command = new G.StrokeStyle(thickness, caps, joints, miterLimit, ignoreScale);
 922
 923		// ignoreScale lives on Stroke, not StrokeStyle, so we do a little trickery:
 924		if (this._stroke) { this._stroke.ignoreScale = ignoreScale; }
 925		this._strokeIgnoreScale = ignoreScale;
 926		return this;
 927	};
 928	
 929	/**
 930	 * Sets or clears the stroke dash pattern.
 931	 *
 932	 * 	myGraphics.setStrokeDash([20, 10], 0);
 933	 *
 934	 * A tiny API method &#x60;sd&#x60; also exists.
 935	 * @method setStrokeDash
 936	 * @param {Array} [segments] An array specifying the dash pattern, alternating between line and gap.
 937	 * For example, &#x60;[20,10]&#x60; would create a pattern of 20 pixel lines with 10 pixel gaps between them.
 938	 * Passing null or an empty array will clear the existing stroke dash.
 939	 * @param {Number} [offset=0] The offset of the dash pattern. For example, you could increment this value to create a &quot;marching ants&quot; effect.
 940	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
 941	 * @chainable
 942	 **/
 943	p.setStrokeDash = function(segments, offset) {
 944		this._updateInstructions(true);
 945		this._strokeDash = this.command = new G.StrokeDash(segments, offset);
 946		return this;
 947	};
 948
 949	/**
 950	 * Begins a stroke with the specified color. This ends the current sub-path. A tiny API method &quot;s&quot; also exists.
 951	 * @method beginStroke
 952	 * @param {String} color A CSS compatible color value (ex. &quot;#FF0000&quot;, &quot;red&quot;, or &quot;rgba(255,0,0,0.5)&quot;). Setting to
 953	 * null will result in no stroke.
 954	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
 955	 * @chainable
 956	 **/
 957	p.beginStroke = function(color) {
 958		return this._setStroke(color ? new G.Stroke(color) : null);
 959	};
 960
 961	/**
 962	 * Begins a linear gradient stroke defined by the line (x0, y0) to (x1, y1). This ends the current sub-path. For
 963	 * example, the following code defines a black to white vertical gradient ranging from 20px to 120px, and draws a
 964	 * square to display it:
 965	 *
 966	 *      myGraphics.setStrokeStyle(10).
 967	 *          beginLinearGradientStroke([&quot;#000&quot;,&quot;#FFF&quot;], [0, 1], 0, 20, 0, 120).drawRect(20, 20, 120, 120);
 968	 *
 969	 * A tiny API method &quot;ls&quot; also exists.
 970	 * @method beginLinearGradientStroke
 971	 * @param {Array} colors An array of CSS compatible color values. For example, [&quot;#F00&quot;,&quot;#00F&quot;] would define
 972	 * a gradient drawing from red to blue.
 973	 * @param {Array} ratios An array of gradient positions which correspond to the colors. For example, [0.1,
 974	 * 0.9] would draw the first color to 10% then interpolating to the second color at 90%.
 975	 * @param {Number} x0 The position of the first point defining the line that defines the gradient direction and size.
 976	 * @param {Number} y0 The position of the first point defining the line that defines the gradient direction and size.
 977	 * @param {Number} x1 The position of the second point defining the line that defines the gradient direction and size.
 978	 * @param {Number} y1 The position of the second point defining the line that defines the gradient direction and size.
 979	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
 980	 * @chainable
 981	 **/
 982	p.beginLinearGradientStroke = function(colors, ratios, x0, y0, x1, y1) {
 983		return this._setStroke(new G.Stroke().linearGradient(colors, ratios, x0, y0, x1, y1));
 984	};
 985
 986	/**
 987	 * Begins a radial gradient stroke. This ends the current sub-path. For example, the following code defines a red to
 988	 * blue radial gradient centered at (100, 100), with a radius of 50, and draws a rectangle to display it:
 989	 *
 990	 *      myGraphics.setStrokeStyle(10)
 991	 *          .beginRadialGradientStroke([&quot;#F00&quot;,&quot;#00F&quot;], [0, 1], 100, 100, 0, 100, 100, 50)
 992	 *          .drawRect(50, 90, 150, 110);
 993	 *
 994	 * A tiny API method &quot;rs&quot; also exists.
 995	 * @method beginRadialGradientStroke
 996	 * @param {Array} colors An array of CSS compatible color values. For example, [&quot;#F00&quot;,&quot;#00F&quot;] would define
 997	 * a gradient drawing from red to blue.
 998	 * @param {Array} ratios An array of gradient positions which correspond to the colors. For example, [0.1,
 999	 * 0.9] would draw the first color to 10% then interpolating to the second color at 90%, then draw the second color
1000	 * to 100%.
1001	 * @param {Number} x0 Center position of the inner circle that defines the gradient.
1002	 * @param {Number} y0 Center position of the inner circle that defines the gradient.
1003	 * @param {Number} r0 Radius of the inner circle that defines the gradient.
1004	 * @param {Number} x1 Center position of the outer circle that defines the gradient.
1005	 * @param {Number} y1 Center position of the outer circle that defines the gradient.
1006	 * @param {Number} r1 Radius of the outer circle that defines the gradient.
1007	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1008	 * @chainable
1009	 **/
1010	p.beginRadialGradientStroke = function(colors, ratios, x0, y0, r0, x1, y1, r1) {
1011		return this._setStroke(new G.Stroke().radialGradient(colors, ratios, x0, y0, r0, x1, y1, r1));
1012	};
1013
1014	/**
1015	 * Begins a pattern fill using the specified image. This ends the current sub-path. Note that unlike bitmap fills,
1016	 * strokes do not currently support a matrix parameter due to limitations in the canvas API. A tiny API method &quot;bs&quot;
1017	 * also exists.
1018	 * @method beginBitmapStroke
1019	 * @param {HTMLImageElement | HTMLCanvasElement | HTMLVideoElement} image The Image, Canvas, or Video object to use
1020	 * as the pattern. Must be loaded prior to creating a bitmap fill, or the fill will be empty.
1021	 * @param {String} [repetition=repeat] Optional. Indicates whether to repeat the image in the fill area. One of
1022	 * &quot;repeat&quot;, &quot;repeat-x&quot;, &quot;repeat-y&quot;, or &quot;no-repeat&quot;. Defaults to &quot;repeat&quot;.
1023	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1024	 * @chainable
1025	 **/
1026	p.beginBitmapStroke = function(image, repetition) {
1027		// NOTE: matrix is not supported for stroke because transforms on strokes also affect the drawn stroke width.
1028		return this._setStroke(new G.Stroke().bitmap(image, repetition));
1029	};
1030
1031	/**
1032	 * Ends the current sub-path, and begins a new one with no stroke. Functionally identical to &lt;code&gt;beginStroke(null)&lt;/code&gt;.
1033	 * A tiny API method &quot;es&quot; also exists.
1034	 * @method endStroke
1035	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1036	 * @chainable
1037	 **/
1038	p.endStroke = function() {
1039		return this.beginStroke();
1040	};
1041
1042	/**
1043	 * Maps the familiar ActionScript &lt;code&gt;curveTo()&lt;/code&gt; method to the functionally similar {{#crossLink &quot;Graphics/quadraticCurveTo&quot;}}{{/crossLink}}
1044	 * method.
1045	 * @method curveTo
1046	 * @param {Number} cpx
1047	 * @param {Number} cpy
1048	 * @param {Number} x
1049	 * @param {Number} y
1050	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1051	 * @chainable
1052	 **/
1053	p.curveTo = p.quadraticCurveTo;
1054
1055	/**
1056	 *
1057	 * Maps the familiar ActionScript &lt;code&gt;drawRect()&lt;/code&gt; method to the functionally similar {{#crossLink &quot;Graphics/rect&quot;}}{{/crossLink}}
1058	 * method.
1059	 * @method drawRect
1060	 * @param {Number} x
1061	 * @param {Number} y
1062	 * @param {Number} w Width of the rectangle
1063	 * @param {Number} h Height of the rectangle
1064	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1065	 * @chainable
1066	 **/
1067	p.drawRect = p.rect;
1068
1069	/**
1070	 * Draws a rounded rectangle with all corners with the specified radius.
1071	 * @method drawRoundRect
1072	 * @param {Number} x
1073	 * @param {Number} y
1074	 * @param {Number} w
1075	 * @param {Number} h
1076	 * @param {Number} radius Corner radius.
1077	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1078	 * @chainable
1079	 **/
1080	p.drawRoundRect = function(x, y, w, h, radius) {
1081		return this.drawRoundRectComplex(x, y, w, h, radius, radius, radius, radius);
1082	};
1083
1084	/**
1085	 * Draws a rounded rectangle with different corner radii. Supports positive and negative corner radii. A tiny API
1086	 * method &quot;rc&quot; also exists.
1087	 * @method drawRoundRectComplex
1088	 * @param {Number} x The horizontal coordinate to draw the round rect.
1089	 * @param {Number} y The vertical coordinate to draw the round rect.
1090	 * @param {Number} w The width of the round rect.
1091	 * @param {Number} h The height of the round rect.
1092	 * @param {Number} radiusTL Top left corner radius.
1093	 * @param {Number} radiusTR Top right corner radius.
1094	 * @param {Number} radiusBR Bottom right corner radius.
1095	 * @param {Number} radiusBL Bottom left corner radius.
1096	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1097	 * @chainable
1098	 **/
1099	p.drawRoundRectComplex = function(x, y, w, h, radiusTL, radiusTR, radiusBR, radiusBL) {
1100		return this.append(new G.RoundRect(x, y, w, h, radiusTL, radiusTR, radiusBR, radiusBL));
1101	};
1102
1103	/**
1104	 * Draws a circle with the specified radius at (x, y).
1105	 *
1106	 *      var g = new createjs.Graphics();
1107	 *	    g.setStrokeStyle(1);
1108	 *	    g.beginStroke(createjs.Graphics.getRGB(0,0,0));
1109	 *	    g.beginFill(createjs.Graphics.getRGB(255,0,0));
1110	 *	    g.drawCircle(0,0,3);
1111	 *
1112	 *	    var s = new createjs.Shape(g);
1113	 *		s.x = 100;
1114	 *		s.y = 100;
1115	 *
1116	 *	    stage.addChild(s);
1117	 *	    stage.update();
1118	 *
1119	 * A tiny API method &quot;dc&quot; also exists.
1120	 * @method drawCircle
1121	 * @param {Number} x x coordinate center point of circle.
1122	 * @param {Number} y y coordinate center point of circle.
1123	 * @param {Number} radius Radius of circle.
1124	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1125	 * @chainable
1126	 **/
1127	p.drawCircle = function(x, y, radius) {
1128		return this.append(new G.Circle(x, y, radius));
1129	};
1130
1131	/**
1132	 * Draws an ellipse (oval) with a specified width (w) and height (h). Similar to {{#crossLink &quot;Graphics/drawCircle&quot;}}{{/crossLink}},
1133	 * except the width and height can be different. A tiny API method &quot;de&quot; also exists.
1134	 * @method drawEllipse
1135	 * @param {Number} x The left coordinate point of the ellipse. Note that this is different from {{#crossLink &quot;Graphics/drawCircle&quot;}}{{/crossLink}}
1136	 * which draws from center.
1137	 * @param {Number} y The top coordinate point of the ellipse. Note that this is different from {{#crossLink &quot;Graphics/drawCircle&quot;}}{{/crossLink}}
1138	 * which draws from the center.
1139	 * @param {Number} w The height (horizontal diameter) of the ellipse. The horizontal radius will be half of this
1140	 * number.
1141	 * @param {Number} h The width (vertical diameter) of the ellipse. The vertical radius will be half of this number.
1142	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1143	 * @chainable
1144	 **/
1145	p.drawEllipse = function(x, y, w, h) {
1146		return this.append(new G.Ellipse(x, y, w, h));
1147	};
1148
1149	/**
1150	 * Draws a star if pointSize is greater than 0, or a regular polygon if pointSize is 0 with the specified number of
1151	 * points. For example, the following code will draw a familiar 5 pointed star shape centered at 100, 100 and with a
1152	 * radius of 50:
1153	 *
1154	 *      myGraphics.beginFill(&quot;#FF0&quot;).drawPolyStar(100, 100, 50, 5, 0.6, -90);
1155	 *      // Note: -90 makes the first point vertical
1156	 *
1157	 * A tiny API method &quot;dp&quot; also exists.
1158	 *
1159	 * @method drawPolyStar
1160	 * @param {Number} x Position of the center of the shape.
1161	 * @param {Number} y Position of the center of the shape.
1162	 * @param {Number} radius The outer radius of the shape.
1163	 * @param {Number} sides The number of points on the star or sides on the polygon.
1164	 * @param {Number} pointSize The depth or &quot;pointy-ness&quot; of the star points. A pointSize of 0 will draw a regular
1165	 * polygon (no points), a pointSize of 1 will draw nothing because the points are infinitely pointy.
1166	 * @param {Number} angle The angle of the first point / corner. For example a value of 0 will draw the first point
1167	 * directly to the right of the center.
1168	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1169	 * @chainable
1170	 **/
1171	p.drawPolyStar = function(x, y, radius, sides, pointSize, angle) {
1172		return this.append(new G.PolyStar(x, y, radius, sides, pointSize, angle));
1173	};
1174
1175	/**
1176	 * Appends a graphics command object to the graphics queue. Command objects expose an &quot;exec&quot; method
1177	 * that accepts two parameters: the Context2D to operate on, and an arbitrary data object passed into
1178	 * {{#crossLink &quot;Graphics/draw&quot;}}{{/crossLink}}. The latter will usually be the Shape instance that called draw.
1179	 *
1180	 * This method is used internally by Graphics methods, such as drawCircle, but can also be used directly to insert
1181	 * built-in or custom graphics commands. For example:
1182	 *
1183	 * 		// attach data to our shape, so we can access it during the draw:
1184	 * 		myShape.color = &quot;red&quot;;
1185	 *
1186	 * 		// append a Circle command object:
1187	 * 		myShape.graphics.append(new createjs.Graphics.Circle(50, 50, 30));
1188	 *
1189	 * 		// append a custom command object with an exec method that sets the fill style
1190	 * 		// based on the shape&#x27;s data, and then fills the circle.
1191	 * 		myShape.graphics.append({exec:function(ctx, shape) {
1192	 * 			ctx.fillStyle = shape.color;
1193	 * 			ctx.fill();
1194	 * 		}});
1195	 *
1196	 * @method append
1197	 * @param {Object} command A graphics command object exposing an &quot;exec&quot; method.
1198	 * @param {boolean} clean The clean param is primarily for internal use. A value of true indicates that a command does not generate a path that should be stroked or filled.
1199	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1200	 * @chainable
1201	 **/
1202	p.append = function(command, clean) {
1203		this._activeInstructions.push(command);
1204		this.command = command;
1205		if (!clean) { this._dirty = true; }
1206		return this;
1207	};
1208
1209	/**
1210	 * Decodes a compact encoded path string into a series of draw instructions.
1211	 * This format is not intended to be human readable, and is meant for use by authoring tools.
1212	 * The format uses a base64 character set, with each character representing 6 bits, to define a series of draw
1213	 * commands.
1214	 *
1215	 * Each command is comprised of a single &quot;header&quot; character followed by a variable number of alternating x and y
1216	 * position values. Reading the header bits from left to right (most to least significant): bits 1 to 3 specify the
1217	 * type of operation (0-moveTo, 1-lineTo, 2-quadraticCurveTo, 3-bezierCurveTo, 4-closePath, 5-7 unused). Bit 4
1218	 * indicates whether position values use 12 bits (2 characters) or 18 bits (3 characters), with a one indicating the
1219	 * latter. Bits 5 and 6 are currently unused.
1220	 *
1221	 * Following the header is a series of 0 (closePath), 2 (moveTo, lineTo), 4 (quadraticCurveTo), or 6 (bezierCurveTo)
1222	 * parameters. These parameters are alternating x/y positions represented by 2 or 3 characters (as indicated by the
1223	 * 4th bit in the command char). These characters consist of a 1 bit sign (1 is negative, 0 is positive), followed
1224	 * by an 11 (2 char) or 17 (3 char) bit integer value. All position values are in tenths of a pixel. Except in the
1225	 * case of move operations which are absolute, this value is a delta from the previous x or y position (as
1226	 * appropriate).
1227	 *
1228	 * For example, the string &quot;A3cAAMAu4AAA&quot; represents a line starting at -150,0 and ending at 150,0.
1229	 * &lt;br /&gt;A - bits 000000. First 3 bits (000) indicate a moveTo operation. 4th bit (0) indicates 2 chars per
1230	 * parameter.
1231	 * &lt;br /&gt;n0 - 110111011100. Absolute x position of -150.0px. First bit indicates a negative value, remaining bits
1232	 * indicate 1500 tenths of a pixel.
1233	 * &lt;br /&gt;AA - 000000000000. Absolute y position of 0.
1234	 * &lt;br /&gt;I - 001100. First 3 bits (001) indicate a lineTo operation. 4th bit (1) indicates 3 chars per parameter.
1235	 * &lt;br /&gt;Au4 - 000000101110111000. An x delta of 300.0px, which is added to the previous x value of -150.0px to
1236	 * provide an absolute position of +150.0px.
1237	 * &lt;br /&gt;AAA - 000000000000000000. A y delta value of 0.
1238	 *
1239	 * A tiny API method &quot;p&quot; also exists.
1240	 * @method decodePath
1241	 * @param {String} str The path string to decode.
1242	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1243	 * @chainable
1244	 **/
1245	p.decodePath = function(str) {
1246		var instructions = [this.moveTo, this.lineTo, this.quadraticCurveTo, this.bezierCurveTo, this.closePath];
1247		var paramCount = [2, 2, 4, 6, 0];
1248		var i=0, l=str.length;
1249		var params = [];
1250		var x=0, y=0;
1251		var base64 = Graphics.BASE_64;
1252
1253		while (i&lt;l) {
1254			var c = str.charAt(i);
1255			var n = base64[c];
1256			var fi = n&gt;&gt;3; // highest order bits 1-3 code for operation.
1257			var f = instructions[fi];
1258			// check that we have a valid instruction &amp; that the unused bits are empty:
1259			if (!f || (n&amp;3)) { throw(&quot;bad path data (@&quot;+i+&quot;): &quot;+c); }
1260			var pl = paramCount[fi];
1261			if (!fi) { x=y=0; } // move operations reset the position.
1262			params.length = 0;
1263			i++;
1264			var charCount = (n&gt;&gt;2&amp;1)+2;  // 4th header bit indicates number size for this operation.
1265			for (var p=0; p&lt;pl; p++) {
1266				var num = base64[str.charAt(i)];
1267				var sign = (num&gt;&gt;5) ? -1 : 1;
1268				num = ((num&amp;31)&lt;&lt;6)|(base64[str.charAt(i+1)]);
1269				if (charCount == 3) { num = (num&lt;&lt;6)|(base64[str.charAt(i+2)]); }
1270				num = sign*num/10;
1271				if (p%2) { x = (num += x); }
1272				else { y = (num += y); }
1273				params[p] = num;
1274				i += charCount;
1275			}
1276			f.apply(this,params);
1277		}
1278		return this;
1279	};
1280
1281	/**
1282	 * Stores all graphics commands so they won&#x27;t be executed in future draws. Calling store() a second time adds to
1283	 * the existing store. This also affects &#x60;drawAsPath()&#x60;.
1284	 *
1285	 * This is useful in cases where you are creating vector graphics in an iterative manner (ex. generative art), so
1286	 * that only new graphics need to be drawn (which can provide huge performance benefits), but you wish to retain all
1287	 * of the vector instructions for later use (ex. scaling, modifying, or exporting).
1288	 *
1289	 * Note that calling store() will force the active path (if any) to be ended in a manner similar to changing
1290	 * the fill or stroke.
1291	 *
1292	 * For example, consider a application where the user draws lines with the mouse. As each line segment (or collection of
1293	 * segments) are added to a Shape, it can be rasterized using {{#crossLink &quot;DisplayObject/updateCache&quot;}}{{/crossLink}},
1294	 * and then stored, so that it can be redrawn at a different scale when the application is resized, or exported to SVG.
1295	 *
1296	 * 	// set up cache:
1297	 * 	myShape.cache(0,0,500,500,scale);
1298	 *
1299	 * 	// when the user drags, draw a new line:
1300	 * 	myShape.graphics.moveTo(oldX,oldY).lineTo(newX,newY);
1301	 * 	// then draw it into the existing cache:
1302	 * 	myShape.updateCache(&quot;source-over&quot;);
1303	 * 	// store the new line, so it isn&#x27;t redrawn next time:
1304	 * 	myShape.store();
1305	 *
1306	 * 	// then, when the window resizes, we can re-render at a different scale:
1307	 * 	// first, unstore all our lines:
1308	 * 	myShape.unstore();
1309	 * 	// then cache using the new scale:
1310	 * 	myShape.cache(0,0,500,500,newScale);
1311	 * 	// finally, store the existing commands again:
1312	 * 	myShape.store();
1313	 *
1314	 * @method store
1315	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1316	 * @chainable
1317	 **/
1318	p.store = function() {
1319		this._updateInstructions(true);
1320		this._storeIndex = this._instructions.length;
1321		return this;
1322	};
1323
1324	/**
1325	 * Unstores any graphics commands that were previously stored using {{#crossLink &quot;Graphics/store&quot;}}{{/crossLink}}
1326	 * so that they will be executed in subsequent draw calls.
1327	 *
1328	 * @method unstore
1329	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1330	 * @chainable
1331	 **/
1332	p.unstore = function() {
1333		this._storeIndex = 0;
1334		return this;
1335	};
1336
1337	/**
1338	 * Returns a clone of this Graphics instance. Note that the individual command objects are not cloned.
1339	 * @method clone
1340	 * @return {Graphics} A clone of the current Graphics instance.
1341	 **/
1342	p.clone = function() {
1343		var o = new Graphics();
1344		o.command = this.command;
1345		o._stroke = this._stroke;
1346		o._strokeStyle = this._strokeStyle;
1347		o._strokeDash = this._strokeDash;
1348		o._strokeIgnoreScale = this._strokeIgnoreScale;
1349		o._fill = this._fill;
1350		o._instructions = this._instructions.slice();
1351		o._commitIndex = this._commitIndex;
1352		o._activeInstructions = this._activeInstructions.slice();
1353		o._dirty = this._dirty;
1354		o._storeIndex = this._storeIndex;
1355		return o;
1356	};
1357
1358	/**
1359	 * Returns a string representation of this object.
1360	 * @method toString
1361	 * @return {String} a string representation of the instance.
1362	 **/
1363	p.toString = function() {
1364		return &quot;[Graphics]&quot;;
1365	};
1366
1367
1368// tiny API:
1369	/**
1370	 * Shortcut to moveTo.
1371	 * @method mt
1372	 * @param {Number} x The x coordinate the drawing point should move to.
1373	 * @param {Number} y The y coordinate the drawing point should move to.
1374	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls).
1375	 * @chainable
1376	 * @protected
1377	 **/
1378	p.mt = p.moveTo;
1379
1380	/**
1381	 * Shortcut to lineTo.
1382	 * @method lt
1383	 * @param {Number} x The x coordinate the drawing point should draw to.
1384	 * @param {Number} y The y coordinate the drawing point should draw to.
1385	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1386	 * @chainable
1387	 * @protected
1388	 **/
1389	p.lt = p.lineTo;
1390
1391	/**
1392	 * Shortcut to arcTo.
1393	 * @method at
1394	 * @param {Number} x1
1395	 * @param {Number} y1
1396	 * @param {Number} x2
1397	 * @param {Number} y2
1398	 * @param {Number} radius
1399	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1400	 * @chainable
1401	 * @protected
1402	 **/
1403	p.at = p.arcTo;
1404
1405	/**
1406	 * Shortcut to bezierCurveTo.
1407	 * @method bt
1408	 * @param {Number} cp1x
1409	 * @param {Number} cp1y
1410	 * @param {Number} cp2x
1411	 * @param {Number} cp2y
1412	 * @param {Number} x
1413	 * @param {Number} y
1414	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1415	 * @chainable
1416	 * @protected
1417	 **/
1418	p.bt = p.bezierCurveTo;
1419
1420	/**
1421	 * Shortcut to quadraticCurveTo / curveTo.
1422	 * @method qt
1423	 * @param {Number} cpx
1424	 * @param {Number} cpy
1425	 * @param {Number} x
1426	 * @param {Number} y
1427	 * @protected
1428	 * @chainable
1429	 **/
1430	p.qt = p.quadraticCurveTo;
1431
1432	/**
1433	 * Shortcut to arc.
1434	 * @method a
1435	 * @param {Number} x
1436	 * @param {Number} y
1437	 * @param {Number} radius
1438	 * @param {Number} startAngle Measured in radians.
1439	 * @param {Number} endAngle Measured in radians.
1440	 * @param {Boolean} anticlockwise
1441	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1442	 * @protected
1443	 * @chainable
1444	 **/
1445	p.a = p.arc;
1446
1447	/**
1448	 * Shortcut to rect.
1449	 * @method r
1450	 * @param {Number} x
1451	 * @param {Number} y
1452	 * @param {Number} w Width of the rectangle
1453	 * @param {Number} h Height of the rectangle
1454	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1455	 * @chainable
1456	 * @protected
1457	 **/
1458	p.r = p.rect;
1459
1460	/**
1461	 * Shortcut to closePath.
1462	 * @method cp
1463	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1464	 * @chainable
1465	 * @protected
1466	 **/
1467	p.cp = p.closePath;
1468
1469	/**
1470	 * Shortcut to clear.
1471	 * @method c
1472	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1473	 * @chainable
1474	 * @protected
1475	 **/
1476	p.c = p.clear;
1477
1478	/**
1479	 * Shortcut to beginFill.
1480	 * @method f
1481	 * @param {String} color A CSS compatible color value (ex. &quot;red&quot;, &quot;#FF0000&quot;, or &quot;rgba(255,0,0,0.5)&quot;). Setting to
1482	 * null will result in no fill.
1483	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1484	 * @chainable
1485	 * @protected
1486	 **/
1487	p.f = p.beginFill;
1488
1489	/**
1490	 * Shortcut to beginLinearGradientFill.
1491	 * @method lf
1492	 * @param {Array} colors An array of CSS compatible color values. For example, [&quot;#F00&quot;,&quot;#00F&quot;] would define a gradient
1493	 * drawing from red to blue.
1494	 * @param {Array} ratios An array of gradient positions which correspond to the colors. For example, [0.1, 0.9] would draw
1495	 * the first color to 10% then interpolating to the second color at 90%.
1496	 * @param {Number} x0 The position of the first point defining the line that defines the gradient direction and size.
1497	 * @param {Number} y0 The position of the first point defining the line that defines the gradient direction and size.
1498	 * @param {Number} x1 The position of the second point defining the line that defines the gradient direction and size.
1499	 * @param {Number} y1 The position of the second point defining the line that defines the gradient direction and size.
1500	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1501	 * @chainable
1502	 * @protected
1503	 **/
1504	p.lf = p.beginLinearGradientFill;
1505
1506	/**
1507	 * Shortcut to beginRadialGradientFill.
1508	 * @method rf
1509	 * @param {Array} colors An array of CSS compatible color values. For example, [&quot;#F00&quot;,&quot;#00F&quot;] would define
1510	 * a gradient drawing from red to blue.
1511	 * @param {Array} ratios An array of gradient positions which correspond to the colors. For example, [0.1,
1512	 * 0.9] would draw the first color to 10% then interpolating to the second color at 90%.
1513	 * @param {Number} x0 Center position of the inner circle that defines the gradient.
1514	 * @param {Number} y0 Center position of the inner circle that defines the gradient.
1515	 * @param {Number} r0 Radius of the inner circle that defines the gradient.
1516	 * @param {Number} x1 Center position of the outer circle that defines the gradient.
1517	 * @param {Number} y1 Center position of the outer circle that defines the gradient.
1518	 * @param {Number} r1 Radius of the outer circle that defines the gradient.
1519	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1520	 * @chainable
1521	 * @protected
1522	 **/
1523	p.rf = p.beginRadialGradientFill;
1524
1525	/**
1526	 * Shortcut to beginBitmapFill.
1527	 * @method bf
1528	 * @param {HTMLImageElement | HTMLCanvasElement | HTMLVideoElement} image The Image, Canvas, or Video object to use
1529	 * as the pattern.
1530	 * @param {String} repetition Optional. Indicates whether to repeat the image in the fill area. One of &quot;repeat&quot;,
1531	 * &quot;repeat-x&quot;, &quot;repeat-y&quot;, or &quot;no-repeat&quot;. Defaults to &quot;repeat&quot;. Note that Firefox does not support &quot;repeat-x&quot; or
1532	 * &quot;repeat-y&quot; (latest tests were in FF 20.0), and will default to &quot;repeat&quot;.
1533	 * @param {Matrix2D} matrix Optional. Specifies a transformation matrix for the bitmap fill. This transformation
1534	 * will be applied relative to the parent transform.
1535	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1536	 * @chainable
1537	 * @protected
1538	 **/
1539	p.bf = p.beginBitmapFill;
1540
1541	/**
1542	 * Shortcut to endFill.
1543	 * @method ef
1544	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1545	 * @chainable
1546	 * @protected
1547	 **/
1548	p.ef = p.endFill;
1549
1550	/**
1551	 * Shortcut to setStrokeStyle.
1552	 * @method ss
1553	 * @param {Number} thickness The width of the stroke.
1554	 * @param {String | Number} [caps=0] Indicates the type of caps to use at the end of lines. One of butt,
1555	 * round, or square. Defaults to &quot;butt&quot;. Also accepts the values 0 (butt), 1 (round), and 2 (square) for use with
1556	 * the tiny API.
1557	 * @param {String | Number} [joints=0] Specifies the type of joints that should be used where two lines meet.
1558	 * One of bevel, round, or miter. Defaults to &quot;miter&quot;. Also accepts the values 0 (miter), 1 (round), and 2 (bevel)
1559	 * for use with the tiny API.
1560	 * @param {Number} [miterLimit=10] If joints is set to &quot;miter&quot;, then you can specify a miter limit ratio which
1561	 * controls at what point a mitered joint will be clipped.
1562	 * @param {Boolean} [ignoreScale=false] If true, the stroke will be drawn at the specified thickness regardless
1563	 * of active transformations.
1564	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1565	 * @chainable
1566	 * @protected
1567	 **/
1568	p.ss = p.setStrokeStyle;
1569	
1570	/**
1571	 * Shortcut to setStrokeDash.
1572	 * @method sd
1573	 * @param {Array} [segments] An array specifying the dash pattern, alternating between line and gap.
1574	 * For example, [20,10] would create a pattern of 20 pixel lines with 10 pixel gaps between them.
1575	 * Passing null or an empty array will clear any existing dash.
1576	 * @param {Number} [offset=0] The offset of the dash pattern. For example, you could increment this value to create a &quot;marching ants&quot; effect.
1577	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1578	 * @chainable
1579	 * @protected
1580	 **/
1581	p.sd = p.setStrokeDash;
1582
1583	/**
1584	 * Shortcut to beginStroke.
1585	 * @method s
1586	 * @param {String} color A CSS compatible color value (ex. &quot;#FF0000&quot;, &quot;red&quot;, or &quot;rgba(255,0,0,0.5)&quot;). Setting to
1587	 * null will result in no stroke.
1588	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1589	 * @chainable
1590	 * @protected
1591	 **/
1592	p.s = p.beginStroke;
1593
1594	/**
1595	 * Shortcut to beginLinearGradientStroke.
1596	 * @method ls
1597	 * @param {Array} colors An array of CSS compatible color values. For example, [&quot;#F00&quot;,&quot;#00F&quot;] would define
1598	 * a gradient drawing from red to blue.
1599	 * @param {Array} ratios An array of gradient positions which correspond to the colors. For example, [0.1,
1600	 * 0.9] would draw the first color to 10% then interpolating to the second color at 90%.
1601	 * @param {Number} x0 The position of the first point defining the line that defines the gradient direction and size.
1602	 * @param {Number} y0 The position of the first point defining the line that defines the gradient direction and size.
1603	 * @param {Number} x1 The position of the second point defining the line that defines the gradient direction and size.
1604	 * @param {Number} y1 The position of the second point defining the line that defines the gradient direction and size.
1605	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1606	 * @chainable
1607	 * @protected
1608	 **/
1609	p.ls = p.beginLinearGradientStroke;
1610
1611	/**
1612	 * Shortcut to beginRadialGradientStroke.
1613	 * @method rs
1614	 * @param {Array} colors An array of CSS compatible color values. For example, [&quot;#F00&quot;,&quot;#00F&quot;] would define
1615	 * a gradient drawing from red to blue.
1616	 * @param {Array} ratios An array of gradient positions which correspond to the colors. For example, [0.1,
1617	 * 0.9] would draw the first color to 10% then interpolating to the second color at 90%, then draw the second color
1618	 * to 100%.
1619	 * @param {Number} x0 Center position of the inner circle that defines the gradient.
1620	 * @param {Number} y0 Center position of the inner circle that defines the gradient.
1621	 * @param {Number} r0 Radius of the inner circle that defines the gradient.
1622	 * @param {Number} x1 Center position of the outer circle that defines the gradient.
1623	 * @param {Number} y1 Center position of the outer circle that defines the gradient.
1624	 * @param {Number} r1 Radius of the outer circle that defines the gradient.
1625	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1626	 * @chainable
1627	 * @protected
1628	 **/
1629	p.rs = p.beginRadialGradientStroke;
1630
1631	/**
1632	 * Shortcut to beginBitmapStroke.
1633	 * @method bs
1634	 * @param {HTMLImageElement | HTMLCanvasElement | HTMLVideoElement} image The Image, Canvas, or Video object to use
1635	 * as the pattern.
1636	 * @param {String} [repetition=repeat] Optional. Indicates whether to repeat the image in the fill area. One of
1637	 * &quot;repeat&quot;, &quot;repeat-x&quot;, &quot;repeat-y&quot;, or &quot;no-repeat&quot;. Defaults to &quot;repeat&quot;.
1638	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1639	 * @chainable
1640	 * @protected
1641	 **/
1642	p.bs = p.beginBitmapStroke;
1643
1644	/**
1645	 * Shortcut to endStroke.
1646	 * @method es
1647	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1648	 * @chainable
1649	 * @protected
1650	 **/
1651	p.es = p.endStroke;
1652
1653	/**
1654	 * Shortcut to drawRect.
1655	 * @method dr
1656	 * @param {Number} x
1657	 * @param {Number} y
1658	 * @param {Number} w Width of the rectangle
1659	 * @param {Number} h Height of the rectangle
1660	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1661	 * @chainable
1662	 * @protected
1663	 **/
1664	p.dr = p.drawRect;
1665
1666	/**
1667	 * Shortcut to drawRoundRect.
1668	 * @method rr
1669	 * @param {Number} x
1670	 * @param {Number} y
1671	 * @param {Number} w
1672	 * @param {Number} h
1673	 * @param {Number} radius Corner radius.
1674	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1675	 * @chainable
1676	 * @protected
1677	 **/
1678	p.rr = p.drawRoundRect;
1679
1680	/**
1681	 * Shortcut to drawRoundRectComplex.
1682	 * @method rc
1683	 * @param {Number} x The horizontal coordinate to draw the round rect.
1684	 * @param {Number} y The vertical coordinate to draw the round rect.
1685	 * @param {Number} w The width of the round rect.
1686	 * @param {Number} h The height of the round rect.
1687	 * @param {Number} radiusTL Top left corner radius.
1688	 * @param {Number} radiusTR Top right corner radius.
1689	 * @param {Number} radiusBR Bottom right corner radius.
1690	 * @param {Number} radiusBL Bottom left corner radius.
1691	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1692	 * @chainable
1693	 * @protected
1694	 **/
1695	p.rc = p.drawRoundRectComplex;
1696
1697	/**
1698	 * Shortcut to drawCircle.
1699	 * @method dc
1700	 * @param {Number} x x coordinate center point of circle.
1701	 * @param {Number} y y coordinate center point of circle.
1702	 * @param {Number} radius Radius of circle.
1703	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1704	 * @chainable
1705	 * @protected
1706	 **/
1707	p.dc = p.drawCircle;
1708
1709	/**
1710	 * Shortcut to drawEllipse.
1711	 * @method de
1712	 * @param {Number} x The left coordinate point of the ellipse. Note that this is different from {{#crossLink &quot;Graphics/drawCircle&quot;}}{{/crossLink}}
1713	 * which draws from center.
1714	 * @param {Number} y The top coordinate point of the ellipse. Note that this is different from {{#crossLink &quot;Graphics/drawCircle&quot;}}{{/crossLink}}
1715	 * which draws from the center.
1716	 * @param {Number} w The height (horizontal diameter) of the ellipse. The horizontal radius will be half of this
1717	 * number.
1718	 * @param {Number} h The width (vertical diameter) of the ellipse. The vertical radius will be half of this number.
1719	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1720	 * @chainable
1721	 * @protected
1722	 **/
1723	p.de = p.drawEllipse;
1724
1725	/**
1726	 * Shortcut to drawPolyStar.
1727	 * @method dp
1728	 * @param {Number} x Position of the center of the shape.
1729	 * @param {Number} y Position of the center of the shape.
1730	 * @param {Number} radius The outer radius of the shape.
1731	 * @param {Number} sides The number of points on the star or sides on the polygon.
1732	 * @param {Number} pointSize The depth or &quot;pointy-ness&quot; of the star points. A pointSize of 0 will draw a regular
1733	 * polygon (no points), a pointSize of 1 will draw nothing because the points are infinitely pointy.
1734	 * @param {Number} angle The angle of the first point / corner. For example a value of 0 will draw the first point
1735	 * directly to the right of the center.
1736	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1737	 * @chainable
1738	 * @protected
1739	 **/
1740	p.dp = p.drawPolyStar;
1741
1742	/**
1743	 * Shortcut to decodePath.
1744	 * @method p
1745	 * @param {String} str The path string to decode.
1746	 * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
1747	 * @chainable
1748	 * @protected
1749	 **/
1750	p.p = p.decodePath;
1751
1752
1753// private methods:
1754	/**
1755	 * @method _updateInstructions
1756	 * @param commit
1757	 * @protected
1758	 **/
1759	p._updateInstructions = function(commit) {
1760		var instr = this._instructions, active = this._activeInstructions, commitIndex = this._commitIndex;
1761
1762		if (this._dirty &amp;&amp; active.length) {
1763			instr.length = commitIndex; // remove old, uncommitted commands
1764			instr.push(Graphics.beginCmd);
1765
1766			var l = active.length, ll = instr.length;
1767			instr.length = ll+l;
1768			for (var i=0; i&lt;l; i++) { instr[i+ll] = active[i]; }
1769
1770			if (this._fill) { instr.push(this._fill); }
1771			if (this._stroke) {
1772				// doesn&#x27;t need to be re-applied if it hasn&#x27;t changed.
1773				if (this._strokeDash !== this._oldStrokeDash) {
1774					instr.push(this._strokeDash);
1775				}
1776				if (this._strokeStyle !== this._oldStrokeStyle) {
1777					instr.push(this._strokeStyle);
1778				}
1779				if (commit) {
1780					this._oldStrokeStyle = this._strokeStyle;
1781					this._oldStrokeDash = this._strokeDash;
1782				}
1783				instr.push(this._stroke);
1784			}
1785
1786			this._dirty = false;
1787		}
1788
1789		if (commit) {
1790			active.length = 0;
1791			this._commitIndex = instr.length;
1792		}
1793	};
1794
1795	/**
1796	 * @method _setFill
1797	 * @param fill
1798	 * @protected
1799	 **/
1800	p._setFill = function(fill) {
1801		this._updateInstructions(true);
1802		this.command = this._fill = fill;
1803		return this;
1804	};
1805
1806	/**
1807	 * @method _setStroke
1808	 * @param stroke
1809	 * @protected
1810	 **/
1811	p._setStroke = function(stroke) {
1812		this._updateInstructions(true);
1813		if (this.command = this._stroke = stroke) {
1814			stroke.ignoreScale = this._strokeIgnoreScale;
1815		}
1816		return this;
1817	};
1818
1819// Command Objects:
1820	/**
1821	 * @namespace Graphics
1822	 */
1823	/**
1824	 * Graphics command object. See {{#crossLink &quot;Graphics/lineTo&quot;}}{{/crossLink}} and {{#crossLink &quot;Graphics/append&quot;}}{{/crossLink}} for more information. See {{#crossLink &quot;Graphics&quot;}}{{/crossLink}} and {{#crossLink &quot;Graphics/append&quot;}}{{/crossLink}} for more information.
1825	 * @class LineTo
1826	 * @constructor
1827	 * @param {Number} x
1828	 * @param {Number} y
1829	 **/
1830	/**
1831	 * @property x
1832	 * @type Number
1833	 */
1834	/**
1835	 * @property y
1836	 * @type Number
1837	 */
1838	/**
1839	 * Execute the Graphics command in the provided Canvas context.
1840	 * @method exec
1841	 * @param {CanvasRenderingContext2D} ctx The canvas rendering context
1842	 */
1843	(G.LineTo = function(x, y) {
1844		this.x = x; this.y = y;
1845	}).prototype.exec = function(ctx) { ctx.lineTo(this.x,this.y); };
1846
1847	/**
1848	 * Graphics command object. See {{#crossLink &quot;Graphics/moveTo&quot;}}{{/crossLink}} and {{#crossLink &quot;Graphics/append&quot;}}{{/crossLink}} for more information.
1849	 * @class MoveTo
1850	 * @constructor
1851	 * @param {Number} x
1852	 * @param {Number} y
1853	 **/
1854	/**
1855	 * @property x
1856	 * @type Number
1857	 */
1858	/**
1859	 * @property y
1860	 * @type Number
1861	 */
1862	/**
1863	 * @method exec
1864	 * @param {CanvasRenderingContext2D} ctx
1865	 */
1866	(G.MoveTo = function(x, y) {
1867		this.x = x; this.y = y;
1868	}).prototype.exec = function(ctx) { ctx.moveTo(this.x, this.y); };
1869
1870
1871	/**
1872	 * Graphics command object. See {{#crossLink &quot;Graphics/arcTo&quot;}}{{/crossLink}} and {{#crossLink &quot;Graphics/append&quot;}}{{/crossLink}} for more information.
1873	 * @class ArcTo
1874	 * @constructor
1875	 * @param {Number} x1
1876	 * @param {Number} y1
1877	 * @param {Number} x2
1878	 * @param {Number} y2
1879	 * @param {Number} radius
1880	 **/
1881	/**
1882	 * @property x1
1883	 * @type Number
1884	 */
1885	/**
1886	 * @property y1
1887	 * @type Number
1888	 */
1889	/**
1890	 * @property x2
1891	 * @type Number
1892	 */
1893	/**
1894	 * @property y2
1895	 * @type Number
1896	 */
1897	/**
1898	 * @property radius
1899	 * @type Number
1900	 */
1901	/**
1902	 * Execute the Graphics command in the provided Canvas context.
1903	 * @method exec
1904	 * @param {CanvasRenderingContext2D} ctx The canvas rendering context
1905	 */
1906	(G.ArcTo = function(x1, y1, x2, y2, radius) {
1907		this.x1 = x1; this.y1 = y1;
1908		this.x2 = x2; this.y2 = y2;
1909		this.radius = radius;
1910	}).prototype.exec = function(ctx) { ctx.arcTo(this.x1, this.y1, this.x2, this.y2, this.radius); };
1911
1912	/**
1913	 * Graphics command object. See {{#crossLink &quot;Graphics/arc&quot;}}{{/crossLink}} and {{#crossLink &quot;Graphics/append&quot;}}{{/crossLink}} for more information.
1914	 * @class Arc
1915	 * @constructor
1916	 * @param {Number} x
1917	 * @param {Number} y
1918	 * @param {Number} radius
1919	 * @param {Number} startAngle
1920	 * @param {Number} endAngle
1921	 * @param {Number} anticlockwise
1922	 **/
1923	/**
1924	 * @property x
1925	 * @type Number
1926	 */
1927	/**
1928	 * @property y
1929	 * @type Number
1930	 */
1931	/**
1932	 * @property radius
1933	 * @type Number
1934	 */
1935	/**
1936	 * @property startAngle
1937	 * @type Number
1938	 */
1939	/**
1940	 * @property endAngle
1941	 * @type Number
1942	 */
1943	/**
1944	 * @property anticlockwise
1945	 * @type Number
1946	 */
1947	/**
1948	 * Execute the Graphics command in the provided Canvas context.
1949	 * @method exec
1950	 * @param {CanvasRenderingContext2D} ctx The canvas rendering context
1951	 */
1952	(G.Arc = function(x, y, radius, startAngle, endAngle, anticlockwise) {
1953		this.x = x; this.y = y;
1954		this.radius = radius;
1955		this.startAngle = startAngle; this.endAngle = endAngle;
1956		this.anticlockwise = !!anticlockwise;
1957	}).prototype.exec = function(ctx) { ctx.arc(this.x, this.y, this.radius, this.startAngle, this.endAngle, this.anticlockwise); };
1958
1959	/**
1960	 * Graphics command object. See {{#crossLink &quot;Graphics/quadraticCurveTo&quot;}}{{/crossLink}} and {{#crossLink &quot;Graphics/append&quot;}}{{/crossLink}} for more information.
1961	 * @class QuadraticCurveTo
1962	 * @constructor
1963	 * @param {Number} cpx
1964	 * @param {Number} cpy
1965	 * @param {Number} x
1966	 * @param {Number} y
1967	 **/
1968	/**
1969	 * @property cpx
1970	 * @type Number
1971	 */
1972	/**
1973	 * @property cpy
1974	 * @type Number
1975	 */
1976	/**
1977	 * @property x
1978	 * @type Number
1979	 */
1980	/**
1981	 * @property y
1982	 * @type Number
1983	 */
1984	/**
1985	 * Execute the Graphics command in the provided Canvas context.
1986	 * @method exec
1987	 * @param {CanvasRenderingContext2D} ctx The canvas rendering context
1988	 */
1989	(G.QuadraticCurveTo = function(cpx, cpy, x, y) {
1990		this.cpx = cpx; this.cpy = cpy;
1991		this.x = x; this.y = y;
1992	}).prototype.exec = function(ctx) { ctx.quadraticCurveTo(this.cpx, this.cpy, this.x, this.y); };
1993
1994	/**
1995	 * Graphics command object. See {{#crossLink &quot;Graphics/bezierCurveTo&quot;}}{{/crossLink}} and {{#crossLink &quot;Graphics/append&quot;}}{{/crossLink}} for more information.
1996	 * @class BezierCurveTo
1997	 * @constructor
1998	 * @param {Number} cp1x
1999	 * @param {Number} cp1y
2000	 * @param {Number} cp2x
2001	 * @param {Number} cp2y
2002	 * @param {Number} x
2003	 * @param {Number} y
2004	 **/
2005	/**
2006	 * @property cp1x
2007	 * @type Number
2008	 */
2009	/**
2010	 * @property cp1y
2011	 * @type Number
2012	 */
2013	/**
2014	 * @property cp2x
2015	 * @type Number
2016	 */
2017	/**
2018	 * @property cp2y
2019	 * @type Number
2020	 */
2021	/**
2022	 * @property x
2023	 * @type Number
2024	 */
2025	/**
2026	 * @property y
2027	 * @type Number
2028	 */
2029	/**
2030	 * Execute the Graphics command in the provided Canvas context.
2031	 * @method exec
2032	 * @param {CanvasRenderingContext2D} ctx The canvas rendering context
2033	 */
2034	(G.BezierCurveTo = function(cp1x, cp1y, cp2x, cp2y, x, y) {
2035		this.cp1x = cp1x; this.cp1y = cp1y;
2036		this.cp2x = cp2x; this.cp2y = cp2y;
2037		this.x = x; this.y = y;
2038	}).prototype.exec = function(ctx) { ctx.bezierCurveTo(this.cp1x, this.cp1y, this.cp2x, this.cp2y, this.x, this.y); };
2039
2040	/**
2041	 * Graphics command object. See {{#crossLink &quot;Graphics/rect&quot;}}{{/crossLink}} and {{#crossLink &quot;Graphics/append&quot;}}{{/crossLink}} for more information.
2042	 * @class Rect
2043	 * @constructor
2044	 * @param {Number} x
2045	 * @param {Number} y
2046	 * @param {Number} w
2047	 * @param {Number} h
2048	 **/
2049	/**
2050	 * @property x
2051	 * @type Number
2052	 */
2053	/**
2054	 * @property y
2055	 * @type Number
2056	 */
2057	/**
2058	 * @property w
2059	 * @type Number
2060	 */
2061	/**
2062	 * @property h
2063	 * @type Number
2064	 */
2065	/**
2066	 * Execute the Graphics command in the provided Canvas context.
2067	 * @method exec
2068	 * @param {CanvasRenderingContext2D} ctx The canvas rendering context
2069	 */
2070	(G.Rect = function(x, y, w, h) {
2071		this.x = x; this.y = y;
2072		this.w = w; this.h = h;
2073	}).prototype.exec = function(ctx) { ctx.rect(this.x, this.y, this.w, this.h); };
2074
2075	/**
2076	 * Graphics command object. See {{#crossLink &quot;Graphics/closePath&quot;}}{{/crossLink}} and {{#crossLink &quot;Graphics/append&quot;}}{{/crossLink}} for more information.
2077	 * @class ClosePath
2078	 * @constructor
2079	 **/
2080	/**
2081	 * Execute the Graphics command in the provided Canvas context.
2082	 * @method exec
2083	 * @param {CanvasRenderingContext2D} ctx The canvas rendering context
2084	 */
2085	(G.ClosePath = function() {
2086	}).prototype.exec = function(ctx) { ctx.closePath(); };
2087
2088	/**
2089	 * Graphics command object to begin a new path. See {{#crossLink &quot;Graphics&quot;}}{{/crossLink}} and {{#crossLink &quot;Graphics/append&quot;}}{{/crossLink}} for more information.
2090	 * @class BeginPath
2091	 * @constructor
2092	 **/
2093	/**
2094	 * Execute the Graphics command in the provided Canvas context.
2095	 * @method exec
2096	 * @param {CanvasRenderingContext2D} ctx The canvas rendering context
2097	 */
2098	(G.BeginPath = function() {
2099	}).prototype.exec = function(ctx) { ctx.beginPath(); };
2100
2101	/**
2102	 * Graphics command object. See {{#crossLink &quot;Graphics/beginFill&quot;}}{{/crossLink}} and {{#crossLink &quot;Graphics/append&quot;}}{{/crossLink}} for more information.
2103	 * @class Fill
2104	 * @constructor
2105	 * @param {Object} style A valid Context2D fillStyle.
2106	 * @param {Matrix2D} matrix
2107	 **/
2108	/**
2109	 * A valid Context2D fillStyle.
2110	 * @property style
2111	 * @type Object
2112	 */
2113	/**
2114	 * @property matrix
2115	 * @type Matrix2D
2116	 */
2117	/**
2118	 * Execute the Graphics command in the provided Canvas context.
2119	 * @method exec
2120	 * @param {CanvasRenderingContext2D} ctx The canvas rendering context
2121	 */
2122	p = (G.Fill = function(style, matrix) {
2123		this.style = style;
2124		this.matrix = matrix;
2125	}).prototype;
2126	p.exec = function(ctx) {
2127		if (!this.style) { return; }
2128		ctx.fillStyle = this.style;
2129		var mtx = this.matrix;
2130		if (mtx) { ctx.save(); ctx.transform(mtx.a, mtx.b, mtx.c, mtx.d, mtx.tx, mtx.ty); }
2131		ctx.fill();
2132		if (mtx) { ctx.restore(); }
2133	};
2134	/**
2135	 * Creates a linear gradient style and assigns it to {{#crossLink &quot;Fill/style:property&quot;}}{{/crossLink}}.
2136	 * See {{#crossLink &quot;Graphics/beginLinearGradientFill&quot;}}{{/crossLink}} for more information.
2137	 * @method linearGradient
2138	 * @param {Array} colors
2139	 *
2140	 * @param {Array} ratios
2141	 * @param {Number} x0
2142	 * @param {Number} y0
2143	 * @param {Number} x1
2144	 * @param {Number} y1
2145	 * @return {Fill} Returns this Fill object for chaining or assignment.
2146	 */
2147	p.linearGradient = function(colors, ratios, x0, y0, x1, y1) {
2148		var o = this.style =  Graphics._ctx.createLinearGradient(x0, y0, x1, y1);
2149		for (var i=0, l=colors.length; i&lt;l; i++) { o.addColorStop(ratios[i], colors[i]); }
2150		o.props = {colors:colors, ratios:ratios, x0:x0, y0:y0, x1:x1, y1:y1, type:&quot;linear&quot;};
2151		return this;
2152	};
2153	/**
2154	 * Creates a radial gradient style and assigns it to {{#crossLink &quot;Fill/style:property&quot;}}{{/crossLink}}.
2155	 * See {{#crossLink &quot;Graphics/beginRadialGradientFill&quot;}}{{/crossLink}} for more information.
2156	 * @method radialGradient
2157	 * @param {Array} colors
2158	 * @param {Array} ratios
2159	 * @param {Number} x0
2160	 * @param {Number} y0
2161	 * @param {Number} r0
2162	 * @param {Number} x1
2163	 * @param {Number} y1
2164	 * @param {Number} r1
2165	 * @return {Fill} Returns this Fill object for chaining or assignment.
2166	 */
2167	p.radialGradient = function(colors, ratios, x0, y0, r0, x1, y1, r1) {
2168		var o = this.style =  Graphics._ctx.createRadialGradient(x0, y0, r0, x1, y1, r1);
2169		for (var i=0, l=colors.length; i&lt;l; i++) { o.addColorStop(ratios[i], colors[i]); }
2170		o.props = {colors:colors, ratios:ratios, x0:x0, y0:y0, r0:r0, x1:x1, y1:y1, r1:r1, type:&quot;radial&quot;};
2171		return this;
2172	};
2173	/**
2174	 * Creates a bitmap fill style and assigns it to the {{#crossLink &quot;Fill/style:property&quot;}}{{/crossLink}}.
2175	 * See {{#crossLink &quot;Graphics/beginBitmapFill&quot;}}{{/crossLink}} for more information.
2176	 * @method bitmap
2177	 * @param {HTMLImageElement | HTMLCanvasElement | HTMLVideoElement} image  Must be loaded prior to creating a bitmap fill, or the fill will be empty.
2178	 * @param {String} [repetition] One of: repeat, repeat-x, repeat-y, or no-repeat.
2179	 * @return {Fill} Returns this Fill object for chaining or assignment.
2180	 */
2181	p.bitmap = function(image, repetition) {
2182		if (image.naturalWidth || image.getContext || image.readyState &gt;= 2) {
2183			var o = this.style = Graphics._ctx.createPattern(image, repetition || &quot;&quot;);
2184			o.props = {image: image, repetition: repetition, type: &quot;bitmap&quot;};
2185		}
2186		return this;
2187	};
2188	p.path = false;
2189
2190	/**
2191	 * Graphics command object. See {{#crossLink &quot;Graphics/beginStroke&quot;}}{{/crossLink}} and {{#crossLink &quot;Graphics/append&quot;}}{{/crossLink}} for more information.
2192	 * @class Stroke
2193	 * @constructor
2194	 * @param {Object} style A valid Context2D fillStyle.
2195	 * @param {Boolean} ignoreScale
2196	 **/
2197	/**
2198	 * A valid Context2D strokeStyle.
2199	 * @property style
2200	 * @type Object
2201	 */
2202	/**
2203	 * @property ignoreScale
2204	 * @type Boolean
2205	 */
2206	/**
2207	 * Execute the Graphics command in the provided Canvas context.
2208	 * @method exec
2209	 * @param {CanvasRenderingContext2D} ctx The canvas rendering context
2210	 */
2211	p = (G.Stroke = function(style, ignoreScale) {
2212		this.style = style;
2213		this.ignoreScale = ignoreScale;
2214	}).prototype;
2215	p.exec = function(ctx) {
2216		if (!this.style) { return; }
2217		ctx.strokeStyle = this.style;
2218		if (this.ignoreScale) { ctx.save(); ctx.setTransform(1,0,0,1,0,0); }
2219		ctx.stroke();
2220		if (this.ignoreScale) { ctx.restore(); }
2221	};
2222	/**
2223	 * Creates a linear gradient style and assigns it to {{#crossLink &quot;Stroke/style:property&quot;}}{{/crossLink}}.
2224	 * See {{#crossLink &quot;Graphics/beginLinearGradientStroke&quot;}}{{/crossLink}} for more information.
2225	 * @method linearGradient
2226	 * @param {Array} colors
2227	 * @param {Array} ratios
2228	 * @param {Number} x0
2229	 * @param {Number} y0
2230	 * @param {Number} x1
2231	 * @param {Number} y1
2232	 * @return {Fill} Returns this Stroke object for chaining or assignment.
2233	 */
2234	p.linearGradient = G.Fill.prototype.linearGradient;
2235	/**
2236	 * Creates a radial gradient style and assigns it to {{#crossLink &quot;Stroke/style:property&quot;}}{{/crossLink}}.
2237	 * See {{#crossLink &quot;Graphics/beginRadialGradientStroke&quot;}}{{/crossLink}} for more information.
2238	 * @method radialGradient
2239	 * @param {Array} colors
2240	 * @param {Array} ratios
2241	 * @param {Number} x0
2242	 * @param {Number} y0
2243	 * @param {Number} r0
2244	 * @param {Number} x1
2245	 * @param {Number} y1
2246	 * @param {Number} r1
2247	 * @return {Fill} Returns this Stroke object for chaining or assignment.
2248	 */
2249	p.radialGradient = G.Fill.prototype.radialGradient;
2250	/**
2251	 * Creates a bitmap fill style and assigns it to {{#crossLink &quot;Stroke/style:property&quot;}}{{/crossLink}}.
2252	 * See {{#crossLink &quot;Graphics/beginBitmapStroke&quot;}}{{/crossLink}} for more information.
2253	 * @method bitmap
2254	 * @param {HTMLImageElement} image
2255	 * @param {String} [repetition] One of: repeat, repeat-x, repeat-y, or no-repeat.
2256	 * @return {Fill} Returns this Stroke object for chaining or assignment.
2257	 */
2258	p.bitmap = G.Fill.prototype.bitmap;
2259	p.path = false;
2260
2261	/**
2262	 * Graphics command object. See {{#crossLink &quot;Graphics/setStrokeStyle&quot;}}{{/crossLink}} and {{#crossLink &quot;Graphics/append&quot;}}{{/crossLink}} for more information.
2263	 * @class StrokeStyle
2264	 * @constructor
2265	 * @param {Number} width
2266	 * @param {String} [caps=butt]
2267	 * @param {String} [joints=miter]
2268	 * @param {Number} [miterLimit=10]
2269	 * @param {Boolean} [ignoreScale=false]
2270	 **/
2271	/**
2272	 * @property width
2273	 * @type Number
2274	 */
2275	/**
2276	 * One of: butt, round, square
2277	 * @property caps
2278	 * @type String
2279	 */
2280	/**
2281	 * One of: round, bevel, miter
2282	 * @property joints
2283	 * @type String
2284	 */
2285	/**
2286	 * @property miterLimit
2287	 * @type Number
2288	 */
2289	/**
2290	 * Execute the Graphics command in the provided Canvas context.
2291	 * @method exec
2292	 * @param {CanvasRenderingContext2D} ctx The canvas rendering context
2293	 */
2294	p = (G.StrokeStyle = function(width, caps, joints, miterLimit, ignoreScale) {
2295		this.width = width;
2296		this.caps = caps;
2297		this.joints = joints;
2298		this.miterLimit = miterLimit;
2299		this.ignoreScale = ignoreScale;
2300	}).prototype;
2301	p.exec = function(ctx) {
2302		ctx.lineWidth = (this.width == null ? &quot;1&quot; : this.width);
2303		ctx.lineCap = (this.caps == null ? &quot;butt&quot; : (isNaN(this.caps) ? this.caps : Graphics.STROKE_CAPS_MAP[this.caps]));
2304		ctx.lineJoin = (this.joints == null ? &quot;miter&quot; : (isNaN(this.joints) ? this.joints : Graphics.STROKE_JOINTS_MAP[this.joints]));
2305		ctx.miterLimit = (this.miterLimit == null ? &quot;10&quot; : this.miterLimit);
2306		ctx.ignoreScale = (this.ignoreScale == null ? false : this.ignoreScale);
2307	};
2308	p.path = false;
2309	
2310	/**
2311	 * Graphics command object. See {{#crossLink &quot;Graphics/setStrokeDash&quot;}}{{/crossLink}} and {{#crossLink &quot;Graphics/append&quot;}}{{/crossLink}} for more information.
2312	 * @class StrokeDash
2313	 * @constructor
2314	 * @param {Array} [segments]
2315	 * @param {Number} [offset=0]
2316	 **/
2317	/**
2318	 * @property segments
2319	 * @type Array
2320	 */
2321	/**
2322	 * @property offset
2323	 * @type Number
2324	 */
2325	/**
2326	 * Execute the Graphics command in the provided Canvas context.
2327	 * @method exec
2328	 * @param {CanvasRenderingContext2D} ctx The canvas rendering context
2329	 */
2330	(G.StrokeDash = function(segments, offset) {
2331		this.segments = segments;
2332		this.offset = offset||0;
2333	}).prototype.exec = function(ctx) {
2334		if (ctx.setLineDash) { // feature detection.
2335			ctx.setLineDash(this.segments|| G.StrokeDash.EMPTY_SEGMENTS); // instead of [] to reduce churn.
2336			ctx.lineDashOffset = this.offset||0;
2337		}
2338	};
2339	/**
2340	 * The default value for segments (ie. no dash).
2341	 * @property EMPTY_SEGMENTS
2342	 * @static
2343	 * @final
2344	 * @readonly
2345	 * @protected
2346	 * @type {Array}
2347	 **/
2348	G.StrokeDash.EMPTY_SEGMENTS = [];
2349
2350	/**
2351	 * Graphics command object. See {{#crossLink &quot;Graphics/drawRoundRectComplex&quot;}}{{/crossLink}} and {{#crossLink &quot;Graphics/append&quot;}}{{/crossLink}} for more information.
2352	 * @class RoundRect
2353	 * @constructor
2354	 * @param {Number} x
2355	 * @param {Number} y
2356	 * @param {Number} w
2357	 * @param {Number} h
2358	 * @param {Number} radiusTL
2359	 * @param {Number} radiusTR
2360	 * @param {Number} radiusBR
2361	 * @param {Number} radiusBL
2362	 **/
2363	/**
2364	 * @property x
2365	 * @type Number
2366	 */
2367	/**
2368	 * @property y
2369	 * @type Number
2370	 */
2371	/**
2372	 * @property w
2373	 * @type Number
2374	 */
2375	/**
2376	 * @property h
2377	 * @type Number
2378	 */
2379	/**
2380	 * @property radiusTL
2381	 * @type Number
2382	 */
2383	/**
2384	 * @property radiusTR
2385	 * @type Number
2386	 */
2387	/**
2388	 * @property radiusBR
2389	 * @type Number
2390	 */
2391	/**
2392	 * @property radiusBL
2393	 * @type Number
2394	 */
2395	/**
2396	 * Execute the Graphics command in the provided Canvas context.
2397	 * @method exec
2398	 * @param {CanvasRenderingContext2D} ctx The canvas rendering context
2399	 */
2400	(G.RoundRect = function(x, y, w, h, radiusTL, radiusTR, radiusBR, radiusBL) {
2401		this.x = x; this.y = y;
2402		this.w = w; this.h = h;
2403		this.radiusTL = radiusTL; this.radiusTR = radiusTR;
2404		this.radiusBR = radiusBR; this.radiusBL = radiusBL;
2405	}).prototype.exec = function(ctx) {
2406		var max = (w&lt;h?w:h)/2;
2407		var mTL=0, mTR=0, mBR=0, mBL=0;
2408		var x = this.x, y = this.y, w = this.w, h = this.h;
2409		var rTL = this.radiusTL, rTR = this.radiusTR, rBR = this.radiusBR, rBL = this.radiusBL;
2410
2411		if (rTL &lt; 0) { rTL *= (mTL=-1); }
2412		if (rTL &gt; max) { rTL = max; }
2413		if (rTR &lt; 0) { rTR *= (mTR=-1); }
2414		if (rTR &gt; max) { rTR = max; }
2415		if (rBR &lt; 0) { rBR *= (mBR=-1); }
2416		if (rBR &gt; max) { rBR = max; }
2417		if (rBL &lt; 0) { rBL *= (mBL=-1); }
2418		if (rBL &gt; max) { rBL = max; }
2419
2420		ctx.moveTo(x+w-rTR, y);
2421		ctx.arcTo(x+w+rTR*mTR, y-rTR*mTR, x+w, y+rTR, rTR);
2422		ctx.lineTo(x+w, y+h-rBR);
2423		ctx.arcTo(x+w+rBR*mBR, y+h+rBR*mBR, x+w-rBR, y+h, rBR);
2424		ctx.lineTo(x+rBL, y+h);
2425		ctx.arcTo(x-rBL*mBL, y+h+rBL*mBL, x, y+h-rBL, rBL);
2426		ctx.lineTo(x, y+rTL);
2427		ctx.arcTo(x-rTL*mTL, y-rTL*mTL, x+rTL, y, rTL);
2428		ctx.closePath();
2429	};
2430
2431	/**
2432	 * Graphics command object. See {{#crossLink &quot;Graphics/drawCircle&quot;}}{{/crossLink}} and {{#crossLink &quot;Graphics/append&quot;}}{{/crossLink}} for more information.
2433	 * @class Circle
2434	 * @constructor
2435	 * @param {Number} x
2436	 * @param {Number} y
2437	 * @param {Number} radius
2438	 **/
2439	/**
2440	 * @property x
2441	 * @type Number
2442	 */
2443	/**
2444	 * @property y
2445	 * @type Number
2446	 */
2447	/**
2448	 * @property radius
2449	 * @type Number
2450	 */
2451	/**
2452	 * Execute the Graphics command in the provided Canvas context.
2453	 * @method exec
2454	 * @param {CanvasRenderingContext2D} ctx The canvas rendering context
2455	 */
2456	(G.Circle = function(x, y, radius) {
2457		this.x = x; this.y = y;
2458		this.radius = radius;
2459	}).prototype.exec = function(ctx) { ctx.arc(this.x, this.y, this.radius, 0, Math.PI*2); };
2460
2461	/**
2462	 * Graphics command object. See {{#crossLink &quot;Graphics/drawEllipse&quot;}}{{/crossLink}} and {{#crossLink &quot;Graphics/append&quot;}}{{/crossLink}} for more information.
2463	 * @class Ellipse
2464	 * @constructor
2465	 * @param {Number} x
2466	 * @param {Number} y
2467	 * @param {Number} w
2468	 * @param {Number} h
2469	 **/
2470	/**
2471	 * @property x
2472	 * @type Number
2473	 */
2474	/**
2475	 * @property y
2476	 * @type Number
2477	 */
2478	/**
2479	 * @property w
2480	 * @type Number
2481	 */
2482	/**
2483	 * @property h
2484	 * @type Number
2485	 */
2486	/**
2487	 * Execute the Graphics command in the provided Canvas context.
2488	 * @method exec
2489	 * @param {CanvasRenderingContext2D} ctx The canvas rendering context
2490	 */
2491	(G.Ellipse = function(x, y, w, h) {
2492		this.x = x; this.y = y;
2493		this.w = w; this.h = h;
2494	}).prototype.exec = function(ctx) {
2495		var x = this.x, y = this.y;
2496		var w = this.w, h = this.h;
2497
2498		var k = 0.5522848;
2499		var ox = (w / 2) * k;
2500		var oy = (h / 2) * k;
2501		var xe = x + w;
2502		var ye = y + h;
2503		var xm = x + w / 2;
2504		var ym = y + h / 2;
2505
2506		ctx.moveTo(x, ym);
2507		ctx.bezierCurveTo(x, ym-oy, xm-ox, y, xm, y);
2508		ctx.bezierCurveTo(xm+ox, y, xe, ym-oy, xe, ym);
2509		ctx.bezierCurveTo(xe, ym+oy, xm+ox, ye, xm, ye);
2510		ctx.bezierCurveTo(xm-ox, ye, x, ym+oy, x, ym);
2511	};
2512
2513	/**
2514	 * Graphics command object. See {{#crossLink &quot;Graphics/drawPolyStar&quot;}}{{/crossLink}} and {{#crossLink &quot;Graphics/append&quot;}}{{/crossLink}} for more information.
2515	 * @class PolyStar
2516	 * @constructor
2517	 * @param {Number} x
2518	 * @param {Number} y
2519	 * @param {Number} radius
2520	 * @param {Number} sides
2521	 * @param {Number} pointSize
2522	 * @param {Number} angle
2523	 **/
2524	/**
2525	 * @property x
2526	 * @type Number
2527	 */
2528	/**
2529	 * @property y
2530	 * @type Number
2531	 */
2532	/**
2533	 * @property radius
2534	 * @type Number
2535	 */
2536	/**
2537	 * @property sides
2538	 * @type Number
2539	 */
2540	/**
2541	 * @property pointSize
2542	 * @type Number
2543	 */
2544	/**
2545	 * @property angle
2546	 * @type Number
2547	 */
2548	/**
2549	 * Execute the Graphics command in the provided Canvas context.
2550	 * @method exec
2551	 * @param {CanvasRenderingContext2D} ctx The canvas rendering context
2552	 */
2553	(G.PolyStar = function(x, y, radius, sides, pointSize, angle) {
2554		this.x = x; this.y = y;
2555		this.radius = radius;
2556		this.sides = sides;
2557		this.pointSize = pointSize;
2558		this.angle = angle;
2559	}).prototype.exec = function(ctx) {
2560		var x = this.x, y = this.y;
2561		var radius = this.radius;
2562		var angle = (this.angle||0)/180*Math.PI;
2563		var sides = this.sides;
2564		var ps = 1-(this.pointSize||0);
2565		var a = Math.PI/sides;
2566
2567		ctx.moveTo(x+Math.cos(angle)*radius, y+Math.sin(angle)*radius);
2568		for (var i=0; i&lt;sides; i++) {
2569			angle += a;
2570			if (ps != 1) {
2571				ctx.lineTo(x+Math.cos(angle)*radius*ps, y+Math.sin(angle)*radius*ps);
2572			}
2573			angle += a;
2574			ctx.lineTo(x+Math.cos(angle)*radius, y+Math.sin(angle)*radius);
2575		}
2576		ctx.closePath();
2577	};
2578
2579	// docced above.
2580	Graphics.beginCmd = new G.BeginPath(); // so we don&#x27;t have to instantiate multiple instances.
2581
2582
2583	createjs.Graphics = Graphics;
2584}());
2585
2586    </pre>
2587</div>
2588
2589                    </div>
2590                </div>
2591            </div>
2592        </div>
2593    </div>
2594</div>
2595<script src="../assets/vendor/prettify/prettify-min.js"></script>
2596<script>prettyPrint();</script>
2597<script src="../assets/js/yui-prettify.js"></script>
2598<script src="../assets/../api.js"></script>
2599<script src="../assets/js/api-filter.js"></script>
2600<script src="../assets/js/api-list.js"></script>
2601<script src="../assets/js/api-search.js"></script>
2602<script src="../assets/js/apidocs.js"></script>
2603</body>
2604</html>