Skip to content

Commit

Permalink
Fix drawTorus behavior with existing geometry (pixijs#6886)
Browse files Browse the repository at this point in the history
  • Loading branch information
irongaze authored Sep 16, 2020
1 parent 3ccb050 commit b7881eb
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/graphics-extras/src/drawTorus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import type { Graphics } from '@pixi/graphics';
* @param {number} y - Y position
* @param {number} innerRadius - Inner circle radius
* @param {number} outerRadius - Outer circle radius
* @param {number} sweep - How much of the circle to fill, in radius
* @param {number} [startArc=0] - Where to begin sweep, in radians, 0.0 = to the right
* @param {number} [endArc=Math.PI*2] - Where to end sweep, in radians
* @return {PIXI.Graphics}
*/
export function drawTorus(this: Graphics,
Expand All @@ -21,7 +22,7 @@ export function drawTorus(this: Graphics,
startArc = 0,
endArc: number = Math.PI * 2): Graphics
{
if ((endArc - startArc) >= Math.PI * 2)
if (Math.abs(endArc - startArc) >= Math.PI * 2)
{
return this
.drawCircle(x, y, outerRadius)
Expand All @@ -30,8 +31,11 @@ export function drawTorus(this: Graphics,
.endHole();
}

return this
this.finishPoly();
this
.arc(x, y, innerRadius, endArc, startArc, true)
.arc(x, y, outerRadius, startArc, endArc, false)
.closePath();
.finishPoly();

return this;
}

0 comments on commit b7881eb

Please sign in to comment.