mirror of
https://github.com/photonstorm/phaser
synced 2025-02-19 07:28:31 +00:00
Make Graphics methods chainable.
This commit is contained in:
parent
2cc498e15e
commit
7a6b643e99
2 changed files with 38 additions and 2 deletions
v3/src
|
@ -1,4 +1,4 @@
|
||||||
var CHECKSUM = {
|
var CHECKSUM = {
|
||||||
build: 'd4e14b10-09d8-11e7-baf9-7d39f1ceeee3'
|
build: 'cf740780-0cf8-11e7-883f-4325c3e47acb'
|
||||||
};
|
};
|
||||||
module.exports = CHECKSUM;
|
module.exports = CHECKSUM;
|
|
@ -32,6 +32,8 @@ var Graphics = new Class({
|
||||||
Commands.ARC,
|
Commands.ARC,
|
||||||
x, y, radius, startAngle, endAngle, anticlockwise
|
x, y, radius, startAngle, endAngle, anticlockwise
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
lineStyle: function (lineWidth, color, alpha)
|
lineStyle: function (lineWidth, color, alpha)
|
||||||
|
@ -40,6 +42,8 @@ var Graphics = new Class({
|
||||||
Commands.LINE_STYLE,
|
Commands.LINE_STYLE,
|
||||||
lineWidth, color, alpha
|
lineWidth, color, alpha
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
fillStyle: function (color, alpha)
|
fillStyle: function (color, alpha)
|
||||||
|
@ -50,6 +54,8 @@ var Graphics = new Class({
|
||||||
Commands.FILL_STYLE,
|
Commands.FILL_STYLE,
|
||||||
color, alpha
|
color, alpha
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
beginPath: function ()
|
beginPath: function ()
|
||||||
|
@ -57,6 +63,8 @@ var Graphics = new Class({
|
||||||
this.commandBuffer.push(
|
this.commandBuffer.push(
|
||||||
Commands.BEGIN_PATH
|
Commands.BEGIN_PATH
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
closePath: function ()
|
closePath: function ()
|
||||||
|
@ -64,6 +72,8 @@ var Graphics = new Class({
|
||||||
this.commandBuffer.push(
|
this.commandBuffer.push(
|
||||||
Commands.CLOSE_PATH
|
Commands.CLOSE_PATH
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
fillPath: function ()
|
fillPath: function ()
|
||||||
|
@ -71,6 +81,8 @@ var Graphics = new Class({
|
||||||
this.commandBuffer.push(
|
this.commandBuffer.push(
|
||||||
Commands.FILL_PATH
|
Commands.FILL_PATH
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
strokePath: function ()
|
strokePath: function ()
|
||||||
|
@ -78,6 +90,8 @@ var Graphics = new Class({
|
||||||
this.commandBuffer.push(
|
this.commandBuffer.push(
|
||||||
Commands.STROKE_PATH
|
Commands.STROKE_PATH
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
fillCircle: function (x, y, radius)
|
fillCircle: function (x, y, radius)
|
||||||
|
@ -86,6 +100,8 @@ var Graphics = new Class({
|
||||||
this.arc(x, y, radius, 0, MATH_CONST.PI2);
|
this.arc(x, y, radius, 0, MATH_CONST.PI2);
|
||||||
this.fillPath();
|
this.fillPath();
|
||||||
this.closePath();
|
this.closePath();
|
||||||
|
|
||||||
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
fillRect: function (x, y, width, height)
|
fillRect: function (x, y, width, height)
|
||||||
|
@ -94,6 +110,8 @@ var Graphics = new Class({
|
||||||
Commands.FILL_RECT,
|
Commands.FILL_RECT,
|
||||||
x, y, width, height
|
x, y, width, height
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
fillTriangle: function (x0, y0, x1, y1, x2, y2)
|
fillTriangle: function (x0, y0, x1, y1, x2, y2)
|
||||||
|
@ -102,6 +120,8 @@ var Graphics = new Class({
|
||||||
Commands.FILL_TRIANGLE,
|
Commands.FILL_TRIANGLE,
|
||||||
x0, y0, x1, y1, x2, y2
|
x0, y0, x1, y1, x2, y2
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
strokeCircle: function (x, y, radius)
|
strokeCircle: function (x, y, radius)
|
||||||
|
@ -110,6 +130,8 @@ var Graphics = new Class({
|
||||||
this.arc(x, y, radius, 0, MATH_CONST.PI2);
|
this.arc(x, y, radius, 0, MATH_CONST.PI2);
|
||||||
this.closePath();
|
this.closePath();
|
||||||
this.strokePath();
|
this.strokePath();
|
||||||
|
|
||||||
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
strokeRect: function (x, y, width, height)
|
strokeRect: function (x, y, width, height)
|
||||||
|
@ -122,6 +144,8 @@ var Graphics = new Class({
|
||||||
this.lineTo(x, y);
|
this.lineTo(x, y);
|
||||||
this.strokePath();
|
this.strokePath();
|
||||||
this.closePath();
|
this.closePath();
|
||||||
|
|
||||||
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
strokeTriangle: function (x0, y0, x1, y1, x2, y2)
|
strokeTriangle: function (x0, y0, x1, y1, x2, y2)
|
||||||
|
@ -130,6 +154,8 @@ var Graphics = new Class({
|
||||||
Commands.STROKE_TRIANGLE,
|
Commands.STROKE_TRIANGLE,
|
||||||
x0, y0, x1, y1, x2, y2
|
x0, y0, x1, y1, x2, y2
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
lineTo: function (x, y)
|
lineTo: function (x, y)
|
||||||
|
@ -138,6 +164,8 @@ var Graphics = new Class({
|
||||||
Commands.LINE_TO,
|
Commands.LINE_TO,
|
||||||
x, y
|
x, y
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
moveTo: function (x, y)
|
moveTo: function (x, y)
|
||||||
|
@ -146,6 +174,8 @@ var Graphics = new Class({
|
||||||
Commands.MOVE_TO,
|
Commands.MOVE_TO,
|
||||||
x, y
|
x, y
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
lineFxTo: function (x, y, width, rgb)
|
lineFxTo: function (x, y, width, rgb)
|
||||||
|
@ -153,7 +183,9 @@ var Graphics = new Class({
|
||||||
this.commandBuffer.push(
|
this.commandBuffer.push(
|
||||||
Commands.LINE_FX_TO,
|
Commands.LINE_FX_TO,
|
||||||
x, y, width, rgb, 1
|
x, y, width, rgb, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
moveFxTo: function (x, y, width, rgb)
|
moveFxTo: function (x, y, width, rgb)
|
||||||
|
@ -162,11 +194,15 @@ var Graphics = new Class({
|
||||||
Commands.MOVE_FX_TO,
|
Commands.MOVE_FX_TO,
|
||||||
x, y, width, rgb, 1
|
x, y, width, rgb, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
clear: function ()
|
clear: function ()
|
||||||
{
|
{
|
||||||
this.commandBuffer.length = 0;
|
this.commandBuffer.length = 0;
|
||||||
|
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue