From b64e6c722c502c10c43b45ea7a38332fca805ae3 Mon Sep 17 00:00:00 2001 From: Neo Date: Thu, 28 Sep 2017 19:29:28 -0700 Subject: [PATCH] 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 --- .../react/views/art/ARTShapeShadowNode.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/art/ARTShapeShadowNode.java b/ReactAndroid/src/main/java/com/facebook/react/views/art/ARTShapeShadowNode.java index 398ef70d518..ca5e4f136d5 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/art/ARTShapeShadowNode.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/art/ARTShapeShadowNode.java @@ -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: