Skip to content

Commit 52e069b

Browse files
committedJan 23, 2019
Fix #119 arc glitch.
1 parent b8279d6 commit 52e069b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed
 

‎src/arc.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ function arcPadAngle(d) {
2525
function intersect(x0, y0, x1, y1, x2, y2, x3, y3) {
2626
var x10 = x1 - x0, y10 = y1 - y0,
2727
x32 = x3 - x2, y32 = y3 - y2,
28-
t = (x32 * (y0 - y2) - y32 * (x0 - x2)) / (y32 * x10 - x32 * y10);
28+
t = y32 * x10 - x32 * y10;
29+
if (t * t < epsilon) return;
30+
t = (x32 * (y0 - y2) - y32 * (x0 - x2)) / t;
2931
return [x0 + t * x10, y0 + t * y10];
3032
}
3133

@@ -146,12 +148,12 @@ export default function() {
146148
var x11 = r1 * cos(a11),
147149
y11 = r1 * sin(a11),
148150
x00 = r0 * cos(a00),
149-
y00 = r0 * sin(a00);
151+
y00 = r0 * sin(a00),
152+
oc;
150153

151154
// Restrict the corner radius according to the sector angle.
152-
if (da < pi) {
153-
var oc = da0 > epsilon ? intersect(x01, y01, x00, y00, x11, y11, x10, y10) : [x10, y10],
154-
ax = x01 - oc[0],
155+
if (da <= tau - epsilon && (oc = intersect(x01, y01, x00, y00, x11, y11, x10, y10))) {
156+
var ax = x01 - oc[0],
155157
ay = y01 - oc[1],
156158
bx = x11 - oc[0],
157159
by = y11 - oc[1],

0 commit comments

Comments
 (0)