Skip to content

Commit

Permalink
Fix border drawing when border-radius is smaller than border-width
Browse files Browse the repository at this point in the history
  • Loading branch information
IjzerenHein committed Apr 16, 2020
1 parent 25ed045 commit d8c8c30
Showing 1 changed file with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -526,18 +526,18 @@ private void updatePath() {
mTempRectForBorderRadiusOutline.set(getBounds());
mTempRectForCenterDrawPath.set(getBounds());

float fullBorderWidth = getFullBorderWidth();
if (fullBorderWidth > 0) {
mTempRectForCenterDrawPath.inset(fullBorderWidth * 0.5f, fullBorderWidth * 0.5f);
}

final RectF borderWidth = getDirectionAwareBorderInsets();

mInnerClipTempRectForBorderRadius.top += borderWidth.top;
mInnerClipTempRectForBorderRadius.bottom -= borderWidth.bottom;
mInnerClipTempRectForBorderRadius.left += borderWidth.left;
mInnerClipTempRectForBorderRadius.right -= borderWidth.right;

mTempRectForCenterDrawPath.top += borderWidth.top * 0.5f;
mTempRectForCenterDrawPath.bottom -= borderWidth.bottom * 0.5f;
mTempRectForCenterDrawPath.left += borderWidth.left * 0.5f;
mTempRectForCenterDrawPath.right -= borderWidth.right * 0.5f;

final float borderRadius = getFullBorderRadius();
float topLeftRadius = getBorderRadiusOrDefaultTo(borderRadius, BorderRadiusLocation.TOP_LEFT);
float topRightRadius = getBorderRadiusOrDefaultTo(borderRadius, BorderRadiusLocation.TOP_RIGHT);
Expand Down Expand Up @@ -663,14 +663,14 @@ private void updatePath() {
mCenterDrawPath.addRoundRect(
mTempRectForCenterDrawPath,
new float[] {
innerTopLeftRadiusX + (topLeftRadius > 0 ? extraRadiusForOutline : 0),
innerTopLeftRadiusY + (topLeftRadius > 0 ? extraRadiusForOutline : 0),
innerTopRightRadiusX + (topRightRadius > 0 ? extraRadiusForOutline : 0),
innerTopRightRadiusY + (topRightRadius > 0 ? extraRadiusForOutline : 0),
innerBottomRightRadiusX + (bottomRightRadius > 0 ? extraRadiusForOutline : 0),
innerBottomRightRadiusY + (bottomRightRadius > 0 ? extraRadiusForOutline : 0),
innerBottomLeftRadiusX + (bottomLeftRadius > 0 ? extraRadiusForOutline : 0),
innerBottomLeftRadiusY + (bottomLeftRadius > 0 ? extraRadiusForOutline : 0)
Math.max(topLeftRadius - borderWidth.left * 0.5f, 0),
Math.max(topLeftRadius - borderWidth.top * 0.5f, 0),
Math.max(topRightRadius - borderWidth.right * 0.5f, 0),
Math.max(topRightRadius - borderWidth.top * 0.5f, 0),
Math.max(bottomRightRadius - borderWidth.right * 0.5f, 0),
Math.max(bottomRightRadius - borderWidth.bottom * 0.5f, 0),
Math.max(bottomLeftRadius - borderWidth.left * 0.5f, 0),
Math.max(bottomLeftRadius - borderWidth.bottom * 0.5f, 0)
},
Path.Direction.CW);

Expand Down

0 comments on commit d8c8c30

Please sign in to comment.