mirror of
https://github.com/photonstorm/phaser
synced 2025-01-30 05:43:32 +00:00
Make Graphics methods chainable.
This commit is contained in:
parent
2cc498e15e
commit
7a6b643e99
2 changed files with 38 additions and 2 deletions
|
@ -1,4 +1,4 @@
|
|||
var CHECKSUM = {
|
||||
build: 'd4e14b10-09d8-11e7-baf9-7d39f1ceeee3'
|
||||
build: 'cf740780-0cf8-11e7-883f-4325c3e47acb'
|
||||
};
|
||||
module.exports = CHECKSUM;
|
|
@ -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;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue