From 7a6b643e996114d8ea9343bb05e51dd03b70ab9c Mon Sep 17 00:00:00 2001 From: Richard Davey <rdavey@gmail.com> Date: Sun, 19 Mar 2017 23:07:41 +0000 Subject: [PATCH] Make Graphics methods chainable. --- v3/src/checksum.js | 2 +- v3/src/gameobjects/graphics/Graphics.js | 38 ++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/v3/src/checksum.js b/v3/src/checksum.js index ec4cd42c9..37126136e 100644 --- a/v3/src/checksum.js +++ b/v3/src/checksum.js @@ -1,4 +1,4 @@ var CHECKSUM = { -build: 'd4e14b10-09d8-11e7-baf9-7d39f1ceeee3' +build: 'cf740780-0cf8-11e7-883f-4325c3e47acb' }; module.exports = CHECKSUM; \ No newline at end of file diff --git a/v3/src/gameobjects/graphics/Graphics.js b/v3/src/gameobjects/graphics/Graphics.js index b8909572e..8deae7c85 100644 --- a/v3/src/gameobjects/graphics/Graphics.js +++ b/v3/src/gameobjects/graphics/Graphics.js @@ -32,6 +32,8 @@ var Graphics = new Class({ Commands.ARC, x, y, radius, startAngle, endAngle, anticlockwise ); + + return this; }, lineStyle: function (lineWidth, color, alpha) @@ -40,6 +42,8 @@ var Graphics = new Class({ Commands.LINE_STYLE, lineWidth, color, alpha ); + + return this; }, fillStyle: function (color, alpha) @@ -50,6 +54,8 @@ var Graphics = new Class({ Commands.FILL_STYLE, color, alpha ); + + return this; }, beginPath: function () @@ -57,6 +63,8 @@ var Graphics = new Class({ this.commandBuffer.push( Commands.BEGIN_PATH ); + + return this; }, closePath: function () @@ -64,6 +72,8 @@ var Graphics = new Class({ this.commandBuffer.push( Commands.CLOSE_PATH ); + + return this; }, fillPath: function () @@ -71,6 +81,8 @@ var Graphics = new Class({ this.commandBuffer.push( Commands.FILL_PATH ); + + return this; }, strokePath: function () @@ -78,6 +90,8 @@ var Graphics = new Class({ this.commandBuffer.push( Commands.STROKE_PATH ); + + return this; }, fillCircle: function (x, y, radius) @@ -86,6 +100,8 @@ var Graphics = new Class({ this.arc(x, y, radius, 0, MATH_CONST.PI2); this.fillPath(); this.closePath(); + + return this; }, fillRect: function (x, y, width, height) @@ -94,6 +110,8 @@ var Graphics = new Class({ Commands.FILL_RECT, x, y, width, height ); + + return this; }, fillTriangle: function (x0, y0, x1, y1, x2, y2) @@ -102,6 +120,8 @@ var Graphics = new Class({ Commands.FILL_TRIANGLE, x0, y0, x1, y1, x2, y2 ); + + return this; }, strokeCircle: function (x, y, radius) @@ -110,6 +130,8 @@ var Graphics = new Class({ this.arc(x, y, radius, 0, MATH_CONST.PI2); this.closePath(); this.strokePath(); + + return this; }, strokeRect: function (x, y, width, height) @@ -122,6 +144,8 @@ var Graphics = new Class({ this.lineTo(x, y); this.strokePath(); this.closePath(); + + return this; }, strokeTriangle: function (x0, y0, x1, y1, x2, y2) @@ -130,6 +154,8 @@ var Graphics = new Class({ Commands.STROKE_TRIANGLE, x0, y0, x1, y1, x2, y2 ); + + return this; }, lineTo: function (x, y) @@ -138,6 +164,8 @@ var Graphics = new Class({ Commands.LINE_TO, x, y ); + + return this; }, moveTo: function (x, y) @@ -146,6 +174,8 @@ var Graphics = new Class({ Commands.MOVE_TO, x, y ); + + return this; }, lineFxTo: function (x, y, width, rgb) @@ -153,7 +183,9 @@ var Graphics = new Class({ this.commandBuffer.push( Commands.LINE_FX_TO, x, y, width, rgb, 1 - ); + ); + + return this; }, moveFxTo: function (x, y, width, rgb) @@ -162,11 +194,15 @@ var Graphics = new Class({ Commands.MOVE_FX_TO, x, y, width, rgb, 1 ); + + return this; }, clear: function () { this.commandBuffer.length = 0; + + return this; } });