mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 15:12:18 +00:00
Graphics.drawArc would fail to draw any subsequent arcs if you set beginFill
on it after drawing the first arc.
Graphics.drawArc would only move to the center position of the first arc created and ignore any subsequent arcs. Graphics.drawArc now correctly renders multiple arcs across both WebGL and Canvas. You no longer need to specifically call moveTo to move into the correct place to draw the arc. Graphics.drawArc now bails out if the startAngle = the endAngle and/or the sweep is invalid *before* adjusting any points. Graphics.drawArc now correctly handles the fill on the CanvasRenderer if the arc is a subsequent arc and no line style is set.
This commit is contained in:
parent
d45a7bae8e
commit
93dc67be71
2 changed files with 30 additions and 29 deletions
|
@ -238,6 +238,11 @@ We've rolled our own fixes into our version of Pixi, ensuring we keep it as bug-
|
||||||
* Text.lineSpacing is no longer applied to the first line of Text, which prevents text from being cut off further down the Text object.
|
* Text.lineSpacing is no longer applied to the first line of Text, which prevents text from being cut off further down the Text object.
|
||||||
* If you paused a Sound object that is using audio markers and then resumed it, it wouldn't correctly calculate the resume duration - causing the sound to sometimes play into the marker that followed it (thanks @AnderbergE #1669)
|
* If you paused a Sound object that is using audio markers and then resumed it, it wouldn't correctly calculate the resume duration - causing the sound to sometimes play into the marker that followed it (thanks @AnderbergE #1669)
|
||||||
* Animation.play wouldn't correctly set the play state on the Game Objects AnimationManager causing the animation to fail to start (calling AnimationManager.play did work however), now they're both consistently working.
|
* Animation.play wouldn't correctly set the play state on the Game Objects AnimationManager causing the animation to fail to start (calling AnimationManager.play did work however), now they're both consistently working.
|
||||||
|
* Graphics.drawArc would fail to draw any subsequent arcs if you set `beginFill` on it after drawing the first arc.
|
||||||
|
* Graphics.drawArc would only move to the center position of the first arc created and ignore any subsequent arcs.
|
||||||
|
* Graphics.drawArc now correctly renders multiple arcs across both WebGL and Canvas. You no longer need to specifically call moveTo to move into the correct place to draw the arc.
|
||||||
|
* Graphics.drawArc now bails out if the startAngle = the endAngle and/or the sweep is invalid *before* adjusting any points.
|
||||||
|
* Graphics.drawArc now correctly handles the fill on the CanvasRenderer if the arc is a subsequent arc and no line style is set.
|
||||||
|
|
||||||
### Pixi 2.2.8 Bug Fixes
|
### Pixi 2.2.8 Bug Fixes
|
||||||
|
|
||||||
|
|
|
@ -149,7 +149,7 @@ PIXI.Graphics.prototype.lineStyle = function(lineWidth, color, alpha)
|
||||||
{
|
{
|
||||||
this.lineWidth = lineWidth || 0;
|
this.lineWidth = lineWidth || 0;
|
||||||
this.lineColor = color || 0;
|
this.lineColor = color || 0;
|
||||||
this.lineAlpha = (arguments.length < 3) ? 1 : alpha;
|
this.lineAlpha = (alpha === undefined) ? 1 : alpha;
|
||||||
|
|
||||||
if (this.currentPath)
|
if (this.currentPath)
|
||||||
{
|
{
|
||||||
|
@ -402,34 +402,13 @@ PIXI.Graphics.prototype.arcTo = function(x1, y1, x2, y2, radius)
|
||||||
*/
|
*/
|
||||||
PIXI.Graphics.prototype.arc = function(cx, cy, radius, startAngle, endAngle, anticlockwise)
|
PIXI.Graphics.prototype.arc = function(cx, cy, radius, startAngle, endAngle, anticlockwise)
|
||||||
{
|
{
|
||||||
var startX = cx + Math.cos(startAngle) * radius;
|
|
||||||
var startY = cy + Math.sin(startAngle) * radius;
|
|
||||||
var points;
|
|
||||||
|
|
||||||
if (this.currentPath)
|
|
||||||
{
|
|
||||||
points = this.currentPath.shape.points;
|
|
||||||
|
|
||||||
if (points.length === 0)
|
|
||||||
{
|
|
||||||
points.push(startX, startY);
|
|
||||||
}
|
|
||||||
else if (points[points.length-2] !== startX || points[points.length-1] !== startY)
|
|
||||||
{
|
|
||||||
points.push(startX, startY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.moveTo(startX, startY);
|
|
||||||
points = this.currentPath.shape.points;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (startAngle === endAngle)
|
if (startAngle === endAngle)
|
||||||
{
|
{
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof anticlockwise === 'undefined') { anticlockwise = false; }
|
||||||
|
|
||||||
if (!anticlockwise && endAngle <= startAngle)
|
if (!anticlockwise && endAngle <= startAngle)
|
||||||
{
|
{
|
||||||
endAngle += Math.PI * 2;
|
endAngle += Math.PI * 2;
|
||||||
|
@ -442,11 +421,27 @@ PIXI.Graphics.prototype.arc = function(cx, cy, radius, startAngle, endAngle, ant
|
||||||
var sweep = anticlockwise ? (startAngle - endAngle) * -1 : (endAngle - startAngle);
|
var sweep = anticlockwise ? (startAngle - endAngle) * -1 : (endAngle - startAngle);
|
||||||
var segs = Math.ceil(Math.abs(sweep) / (Math.PI * 2)) * 40;
|
var segs = Math.ceil(Math.abs(sweep) / (Math.PI * 2)) * 40;
|
||||||
|
|
||||||
|
// Sweep check - moved here because we don't want to do the moveTo below if the arc fails
|
||||||
if (sweep === 0)
|
if (sweep === 0)
|
||||||
{
|
{
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var startX = cx + Math.cos(startAngle) * radius;
|
||||||
|
var startY = cy + Math.sin(startAngle) * radius;
|
||||||
|
|
||||||
|
if (anticlockwise && this.filling)
|
||||||
|
{
|
||||||
|
this.moveTo(cx, cy);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.moveTo(startX, startY);
|
||||||
|
}
|
||||||
|
|
||||||
|
// currentPath will always exist after calling a moveTo
|
||||||
|
var points = this.currentPath.shape.points;
|
||||||
|
|
||||||
var theta = sweep / (segs * 2);
|
var theta = sweep / (segs * 2);
|
||||||
var theta2 = theta * 2;
|
var theta2 = theta * 2;
|
||||||
|
|
||||||
|
@ -587,7 +582,7 @@ PIXI.Graphics.prototype.drawEllipse = function(x, y, width, height)
|
||||||
* Draws a polygon using the given path.
|
* Draws a polygon using the given path.
|
||||||
*
|
*
|
||||||
* @method drawPolygon
|
* @method drawPolygon
|
||||||
* @param path {Array} The path data used to construct the polygon.
|
* @param path {Array} The path data used to construct the polygon. If you've got a Phaser.Polygon object then pass `polygon.points` here.
|
||||||
* @return {Graphics}
|
* @return {Graphics}
|
||||||
*/
|
*/
|
||||||
PIXI.Graphics.prototype.drawPolygon = function(path)
|
PIXI.Graphics.prototype.drawPolygon = function(path)
|
||||||
|
@ -602,7 +597,8 @@ PIXI.Graphics.prototype.drawPolygon = function(path)
|
||||||
// see section 3.2: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments
|
// see section 3.2: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments
|
||||||
points = new Array(arguments.length);
|
points = new Array(arguments.length);
|
||||||
|
|
||||||
for (var i = 0; i < points.length; ++i) {
|
for (var i = 0; i < points.length; ++i)
|
||||||
|
{
|
||||||
points[i] = arguments[i];
|
points[i] = arguments[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue