mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 20:53:39 +00:00
Graphics.arc has a new argument segments
that allows you to control how many segments are created when the arc is drawn. The default is 40. Use a higher number for more fidelity, i.e. if you find that reversed arcs are not joining up fully (#2064)
This commit is contained in:
parent
8076f64656
commit
c3c2dd6067
2 changed files with 5 additions and 2 deletions
|
@ -335,6 +335,7 @@ Please note that Phaser uses a custom build of Pixi and always has done. The fol
|
||||||
* BaseTexture.destroy no longer checks for the `_pixiId` property on the canvas before removing it from the CanvasPool, meaning it's now destroying a lot more canvas elements than it was in the past!
|
* BaseTexture.destroy no longer checks for the `_pixiId` property on the canvas before removing it from the CanvasPool, meaning it's now destroying a lot more canvas elements than it was in the past!
|
||||||
* TilingSprite would ignore the `renderable` property, and render it regardless. Now it skips render if `renderable` is false (thanks @Green92 #2214)
|
* TilingSprite would ignore the `renderable` property, and render it regardless. Now it skips render if `renderable` is false (thanks @Green92 #2214)
|
||||||
* We have replaced the PolyK Triangulation calls within Pixi with EarCut 2.0.8. This allows for faster polygon triangulation, and also deals with more complex polygons that PolyK would crash on.
|
* We have replaced the PolyK Triangulation calls within Pixi with EarCut 2.0.8. This allows for faster polygon triangulation, and also deals with more complex polygons that PolyK would crash on.
|
||||||
|
* Graphics.arc has a new argument `segments` that allows you to control how many segments are created when the arc is drawn. The default is 40. Use a higher number for more fidelity, i.e. if you find that reversed arcs are not joining up fully (#2064)
|
||||||
|
|
||||||
For changes in previous releases please see the extensive [Version History](https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md).
|
For changes in previous releases please see the extensive [Version History](https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md).
|
||||||
|
|
||||||
|
|
|
@ -398,9 +398,10 @@ PIXI.Graphics.prototype.arcTo = function(x1, y1, x2, y2, radius)
|
||||||
* @param startAngle {Number} The starting angle, in radians (0 is at the 3 o'clock position of the arc's circle)
|
* @param startAngle {Number} The starting angle, in radians (0 is at the 3 o'clock position of the arc's circle)
|
||||||
* @param endAngle {Number} The ending angle, in radians
|
* @param endAngle {Number} The ending angle, in radians
|
||||||
* @param anticlockwise {Boolean} Optional. Specifies whether the drawing should be counterclockwise or clockwise. False is default, and indicates clockwise, while true indicates counter-clockwise.
|
* @param anticlockwise {Boolean} Optional. Specifies whether the drawing should be counterclockwise or clockwise. False is default, and indicates clockwise, while true indicates counter-clockwise.
|
||||||
|
* @param segments {Number} Optional. The number of segments to use when calculating the arc. The default is 40. If you need more fidelity use a higher number.
|
||||||
* @return {Graphics}
|
* @return {Graphics}
|
||||||
*/
|
*/
|
||||||
PIXI.Graphics.prototype.arc = function(cx, cy, radius, startAngle, endAngle, anticlockwise)
|
PIXI.Graphics.prototype.arc = function(cx, cy, radius, startAngle, endAngle, anticlockwise, segments)
|
||||||
{
|
{
|
||||||
// If we do this we can never draw a full circle
|
// If we do this we can never draw a full circle
|
||||||
if (startAngle === endAngle)
|
if (startAngle === endAngle)
|
||||||
|
@ -409,6 +410,7 @@ PIXI.Graphics.prototype.arc = function(cx, cy, radius, startAngle, endAngle, ant
|
||||||
}
|
}
|
||||||
|
|
||||||
if (anticlockwise === undefined) { anticlockwise = false; }
|
if (anticlockwise === undefined) { anticlockwise = false; }
|
||||||
|
if (segments === undefined) { segments = 40; }
|
||||||
|
|
||||||
if (!anticlockwise && endAngle <= startAngle)
|
if (!anticlockwise && endAngle <= startAngle)
|
||||||
{
|
{
|
||||||
|
@ -420,7 +422,7 @@ 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)) * segments;
|
||||||
|
|
||||||
// Sweep check - moved here because we don't want to do the moveTo below if the arc fails
|
// Sweep check - moved here because we don't want to do the moveTo below if the arc fails
|
||||||
if (sweep === 0)
|
if (sweep === 0)
|
||||||
|
|
Loading…
Reference in a new issue