Permalink
Browse files

fix arc drawing when sweep >= 360

Summary:
I hit this issue in my own component https://github.com/nihgwu/react-native-pie, and find this https://stackoverflow.com/questions/19383842/weird-behaviour-in-drawing-a-ring-using-path-arcto-in-android, after this change, it looks exactly the same on both Android and iOS
Closes #15042

Differential Revision: D5937957

Pulled By: shergin

fbshipit-source-id: 3c88565a1cc90d82edd819d048f40d4961f78b3c
  • Loading branch information...
nihgwu authored and facebook-github-bot committed Sep 29, 2017
1 parent 089add4 commit b64e6c722c502c10c43b45ea7a38332fca805ae3
Showing with 9 additions and 9 deletions.
  1. +9 −9 ReactAndroid/src/main/java/com/facebook/react/views/art/ARTShapeShadowNode.java
@@ -298,18 +298,18 @@ private Path createPath(float[] data) {
boolean counterClockwise = !(data[i++] == 1f);
float sweep = end - start;
if (Math.abs(sweep) > 360) {
sweep = 360;
if (Math.abs(sweep) >= 360) {
path.addCircle(x, y, r, counterClockwise ? Path.Direction.CCW : Path.Direction.CW);
} else {
sweep = modulus(sweep, 360);
}
if (counterClockwise && sweep < 360) {
// Counter-clockwise sweeps are negative
sweep = -1 * (360 - sweep);
}
if (counterClockwise && sweep < 360) {
// Counter-clockwise sweeps are negative
sweep = -1 * (360 - sweep);
}
RectF oval = new RectF(x - r, y - r, x + r, y + r);
path.arcTo(oval, start, sweep);
RectF oval = new RectF(x - r, y - r, x + r, y + r);
path.arcTo(oval, start, sweep);
}
break;
}
default:

0 comments on commit b64e6c7

Please sign in to comment.