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 https://github.com/facebook/react-native/pull/15042 Differential Revision: D5937957 Pulled By: shergin fbshipit-source-id: 3c88565a1cc90d82edd819d048f40d4961f78b3c
This commit is contained in:
parent
089add4de7
commit
b64e6c722c
|
@ -298,18 +298,18 @@ public class ARTShapeShadowNode extends ARTVirtualNode {
|
|||
|
||||
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:
|
||||
|
|
Loading…
Reference in New Issue