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 ce8b5e1362ccee..21d8849adc6924 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 @@ protected boolean setupFillPaint(Paint paint, float opacity) { 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,11 +246,18 @@ private Path createPath(float[] data) { 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); + } + if (!clockwise && sweep < 360) { + start = end; + sweep = 360 - sweep; } - float sweep = start - end; + RectF oval = new RectF(x - r, y - r, x + r, y + r); path.addArc(oval, start, sweep); break;