Skip to content

Commit 2576533

Browse files
committed
Handle special case when arc is really a circle.
1 parent e54c95a commit 2576533

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

plugins/context2d.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,7 +1495,7 @@
14951495
var EPSILON = 0.00001; // Roughly 1/1000th of a degree, see below
14961496
var twoPI = Math.PI * 2;
14971497
var piOverTwo = Math.PI / 2.0;
1498-
1498+
14991499
// normalize startAngle, endAngle to [0, 2PI]
15001500
var startAngleN = startAngle;
15011501
if (startAngleN < twoPI || startAngleN > twoPI) {
@@ -1512,19 +1512,22 @@
15121512
endAngleN = twoPI + endAngleN;
15131513
}
15141514

1515-
// Total arc angle is less than 2PI.
1515+
// Total arc angle is less than or equal to 2PI.
15161516
var totalAngle = Math.abs(endAngleN - startAngleN);
1517-
if (anticlockwise) {
1518-
if (startAngle < endAngle) {
1519-
totalAngle = twoPI - totalAngle;
1520-
}
1521-
}
1522-
else {
1523-
if (startAngle > endAngle) {
1524-
totalAngle = twoPI - totalAngle;
1517+
if (totalAngle < twoPI) {
1518+
if (totalAngle < twoPI) {
1519+
if (anticlockwise) {
1520+
if (startAngle < endAngle) {
1521+
totalAngle = twoPI - totalAngle;
1522+
}
1523+
}
1524+
else {
1525+
if (startAngle > endAngle) {
1526+
totalAngle = twoPI - totalAngle;
1527+
}
1528+
}
15251529
}
15261530
}
1527-
//TODO case when angles are equal. Do we draw circle? Or NOP?
15281531

15291532
// Compute the sequence of arc curves, up to PI/2 at a time.
15301533
var curves = [];

0 commit comments

Comments
 (0)