mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 15:12:18 +00:00
Update WebGL Graphics.arc to work more like on Canvas
This commit is contained in:
parent
8afeafd66b
commit
0c0b272ccc
1 changed files with 35 additions and 14 deletions
|
@ -796,6 +796,7 @@ var FlatTintPipeline = new Class({
|
|||
var path = null;
|
||||
var sin = Math.sin;
|
||||
var cos = Math.cos;
|
||||
var PI2 = Math.PI * 2;
|
||||
var sr = sin(srcRotation);
|
||||
var cr = cos(srcRotation);
|
||||
var sra = cr * srcScaleX;
|
||||
|
@ -835,31 +836,51 @@ var FlatTintPipeline = new Class({
|
|||
endAngle = commands[cmdIndex + 5];
|
||||
anticlockwise = commands[cmdIndex + 6];
|
||||
|
||||
if (lastPath === null)
|
||||
{
|
||||
lastPath = new Path(x + cos(startAngle) * radius, y + sin(startAngle) * radius, lineWidth, lineColor, lineAlpha);
|
||||
pathArray.push(lastPath);
|
||||
iteration += iterStep;
|
||||
}
|
||||
|
||||
endAngle -= startAngle;
|
||||
if (anticlockwise)
|
||||
{
|
||||
ta = endAngle;
|
||||
endAngle = startAngle;
|
||||
startAngle = -ta;
|
||||
if (endAngle < -PI2)
|
||||
{
|
||||
endAngle = -PI2;
|
||||
}
|
||||
else if (endAngle > 0)
|
||||
{
|
||||
endAngle = -PI2 + endAngle % PI2;
|
||||
}
|
||||
}
|
||||
|
||||
else if (endAngle > PI2)
|
||||
{
|
||||
endAngle = PI2;
|
||||
}
|
||||
else if (endAngle < 0)
|
||||
{
|
||||
endAngle = PI2 + endAngle % PI2;
|
||||
}
|
||||
|
||||
while (iteration < 1)
|
||||
{
|
||||
ta = (endAngle - startAngle) * iteration + startAngle;
|
||||
ta = endAngle * iteration + startAngle;
|
||||
tx = x + cos(ta) * radius;
|
||||
ty = y + sin(ta) * radius;
|
||||
|
||||
if (iteration === 0)
|
||||
{
|
||||
lastPath = new Path(tx, ty, lineWidth, lineColor, lineAlpha);
|
||||
pathArray.push(lastPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
lastPath.points.push(new Point(tx, ty, lineWidth, lineColor, lineAlpha));
|
||||
}
|
||||
lastPath.points.push(new Point(tx, ty, lineWidth, lineColor, lineAlpha));
|
||||
|
||||
iteration += iterStep;
|
||||
}
|
||||
|
||||
ta = endAngle + startAngle;
|
||||
tx = x + cos(ta) * radius;
|
||||
ty = y + sin(ta) * radius;
|
||||
|
||||
lastPath.points.push(new Point(tx, ty, lineWidth, lineColor, lineAlpha));
|
||||
|
||||
cmdIndex += 6;
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in a new issue