Skip to content

Commit

Permalink
Fixing drawing bug in ReactArt on Android
Browse files Browse the repository at this point in the history
Summary: This change fixes rendering issues with arcs having an inner radius.  The root cause was a bug that lost the negative sign for counter-clockwise angles.  The previous code also incorrectly set the start angle to the end angle.

Differential Revision: D5298320

fbshipit-source-id: 4d11edfed5bdab0cf68313d22f94ef0e3711a1a8
  • Loading branch information
Nick Eddy authored and facebook-github-bot committed Jun 23, 2017
1 parent 1ee602b commit a660796
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ protected boolean setupFillPaint(Paint paint, float opacity) {
case COLOR_TYPE_LINEAR_GRADIENT:
// For mBrushData format refer to LinearGradient and insertColorStopsIntoArray functions in ReactNativeART.js
if (mBrushData.length < 5) {
FLog.w(ReactConstants.TAG,
"[ARTShapeShadowNode setupFillPaint] expects 5 elements, received "
FLog.w(ReactConstants.TAG,
"[ARTShapeShadowNode setupFillPaint] expects 5 elements, received "
+ mBrushData.length);
return false;
}
Expand Down Expand Up @@ -296,16 +296,16 @@ private Path createPath(float[] data) {
float start = (float) Math.toDegrees(data[i++]);
float end = (float) Math.toDegrees(data[i++]);

boolean clockwise = data[i++] == 1f;
boolean counterClockwise = !(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;
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);
Expand Down

0 comments on commit a660796

Please sign in to comment.