Fix arcTo circle bug

This commit is contained in:
Horcrux
2017-01-07 21:46:08 +08:00
parent 293263d6ef
commit 609226d732
@@ -494,22 +494,34 @@ import java.util.regex.Pattern;
mPenX = mPivotX = x; mPenX = mPivotX = x;
mPenY = mPivotY = y; mPenY = mPivotY = y;
//arcToBezier(cx, cy, rx, ry, sa, ea, clockwise, rad);
if (rx != ry || rad != 0f) { if (rx != ry || rad != 0f) {
arcToBezier(cx, cy, rx, ry, sa, ea, clockwise, rad); arcToBezier(cx, cy, rx, ry, sa, ea, clockwise, rad);
} else { } else {
float start = (float) Math.toDegrees(sa); float start = (float) Math.toDegrees(sa);
float end = (float) Math.toDegrees(ea); float end = (float) Math.toDegrees(ea);
float sweep = Math.abs((start - end) % 360);
if (outer) {
if (sweep < 180) {
sweep = 360 - sweep;
}
} else {
if (sweep > 180) {
sweep = 360 - sweep;
}
}
if (!clockwise) { if (!clockwise) {
end = 360 - end; sweep = -sweep;
} }
float sweep = start - end;
RectF oval = new RectF( RectF oval = new RectF(
(cx - rx) * mScale, (cx - rx) * mScale,
(cy - rx) * mScale, (cy - rx) * mScale,
(cx + rx) * mScale, (cx + rx) * mScale,
(cy + rx) * mScale); (cy + rx) * mScale);
mPath.arcTo(oval, start, sweep); mPath.arcTo(oval, start, sweep);
} }
} }