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 770739f39..195ef8fd4 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 @@ -191,6 +191,20 @@ public class ARTShapeShadowNode extends ARTVirtualNode { return false; } + /** + * Returns the floor modulus of the float arguments. Java modulus will return a negative remainder + * when the divisor is negative. Modulus should always be positive. This mimics the behavior of + * Math.floorMod, introduced in Java 8. + */ + private float modulus(float x, float y) { + float remainder = x % y; + float modulus = remainder; + if (remainder < 0) { + modulus += y; + } + return modulus; + } + /** * Creates a {@link Path} from an array of instructions constructed by JS * (see ARTSerializablePath.js). Each instruction starts with a type (see PATH_TYPE_*) followed @@ -232,13 +246,21 @@ public class ARTShapeShadowNode extends ARTVirtualNode { float r = data[i++] * mScale; float start = (float) Math.toDegrees(data[i++]); float end = (float) Math.toDegrees(data[i++]); - boolean clockwise = data[i++] == 0f; - if (!clockwise) { - end = 360 - end; + + boolean clockwise = data[i++] == 1f; + float sweep = end - start; + if (Math.abs(sweep) > 360) { + sweep = 360; + } else { + sweep = modulus(sweep, 360); } - float sweep = start - end; + if (!clockwise && sweep < 360) { + start = end; + sweep = 360 - sweep; + } + RectF oval = new RectF(x - r, y - r, x + r, y + r); - path.addArc(oval, start, sweep); + path.arcTo(oval, start, sweep); break; } default: