mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 15:12:18 +00:00
Fixed slice method
This commit is contained in:
parent
5c554f3f69
commit
9e84c9f082
1 changed files with 34 additions and 3 deletions
|
@ -1112,7 +1112,7 @@ var Graphics = new Class({
|
||||||
{
|
{
|
||||||
endAngle = -PI2 - overshoot;
|
endAngle = -PI2 - overshoot;
|
||||||
}
|
}
|
||||||
else if (endAngle > 0)
|
else if (endAngle >= 0)
|
||||||
{
|
{
|
||||||
endAngle = -PI2 + endAngle % PI2 - overshoot;
|
endAngle = -PI2 + endAngle % PI2 - overshoot;
|
||||||
}
|
}
|
||||||
|
@ -1159,13 +1159,44 @@ var Graphics = new Class({
|
||||||
* @param {number} radius - The radius of the slice.
|
* @param {number} radius - The radius of the slice.
|
||||||
* @param {number} startAngle - The start angle of the slice, given in radians.
|
* @param {number} startAngle - The start angle of the slice, given in radians.
|
||||||
* @param {number} endAngle - The end angle of the slice, given in radians.
|
* @param {number} endAngle - The end angle of the slice, given in radians.
|
||||||
* @param {boolean} [anticlockwise=false] - Draw the slice piece anticlockwise or clockwise?
|
* @param {boolean} [anticlockwise=false] - Whether the drawing should be anticlockwise or clockwise.
|
||||||
|
* @param {number} [overshoot=0] - This value allows you to overshoot the endAngle by this amount. Useful if the arc has a thick stroke and needs to overshoot to join-up cleanly.
|
||||||
*
|
*
|
||||||
* @return {Phaser.GameObjects.Graphics} This Game Object.
|
* @return {Phaser.GameObjects.Graphics} This Game Object.
|
||||||
*/
|
*/
|
||||||
slice: function (x, y, radius, startAngle, endAngle, anticlockwise)
|
slice: function (x, y, radius, startAngle, endAngle, anticlockwise, overshoot)
|
||||||
{
|
{
|
||||||
if (anticlockwise === undefined) { anticlockwise = false; }
|
if (anticlockwise === undefined) { anticlockwise = false; }
|
||||||
|
if (overshoot === undefined) { overshoot = 0; }
|
||||||
|
|
||||||
|
var PI2 = Math.PI * 2;
|
||||||
|
|
||||||
|
if (anticlockwise)
|
||||||
|
{
|
||||||
|
if (endAngle < -PI2)
|
||||||
|
{
|
||||||
|
endAngle = -PI2 - overshoot;
|
||||||
|
}
|
||||||
|
else if (endAngle >= 0)
|
||||||
|
{
|
||||||
|
endAngle = -PI2 + endAngle % PI2 - overshoot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
endAngle -= startAngle;
|
||||||
|
endAngle += overshoot;
|
||||||
|
|
||||||
|
if (endAngle > PI2 + overshoot)
|
||||||
|
{
|
||||||
|
endAngle = PI2 + overshoot;
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (endAngle <= -overshoot)
|
||||||
|
{
|
||||||
|
endAngle = PI2 + endAngle % PI2 - overshoot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.commandBuffer.push(Commands.BEGIN_PATH);
|
this.commandBuffer.push(Commands.BEGIN_PATH);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue