Skip to content

Commit

Permalink
Internal change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 321437366
  • Loading branch information
afweiss authored and material-automation committed Jul 15, 2020
1 parent e4805f0 commit eb324d0
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions components/BottomAppBar/src/private/MDCBottomAppBarLayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,27 @@ - (UIBezierPath *)drawWithPathToCut:(UIBezierPath *)bottomBarPath
[bottomBarPath addLineToPoint:CGPointMake(0, height * 2 + yOffset)];

[bottomBarPath addLineToPoint:CGPointMake(0, yOffset)];
[bottomBarPath addLineToPoint:CGPointMake(arcCenter1.x - arcRadius, yOffset)];

CGFloat xOffset = arcCenter1.y == yOffset
? arcRadius
: sqrt(pow(arcRadius, 2) - pow(yOffset - arcCenter1.y, 2));
[bottomBarPath addLineToPoint:CGPointMake(arcCenter1.x - xOffset, yOffset)];

CGFloat angleOffset1 = asin((yOffset - arcCenter1.y) / arcRadius);

[bottomBarPath addArcWithCenter:arcCenter1
radius:arcRadius
startAngle:-180 * (float)M_PI / 180
endAngle:-270 * (float)M_PI / 180
startAngle:(180.0 * (float)M_PI / 180.0) - angleOffset1
endAngle:90.0 * (float)M_PI / 180.0
clockwise:NO];

[bottomBarPath addLineToPoint:CGPointMake(arcCenter2.x, arcRadius + yOffset)];
[bottomBarPath addLineToPoint:CGPointMake(arcCenter2.x, arcRadius + arcCenter2.y)];

CGFloat angleOffset2 = asin((yOffset - arcCenter2.y) / arcRadius);
[bottomBarPath addArcWithCenter:arcCenter2
radius:arcRadius
startAngle:-270 * (float)M_PI / 180
endAngle:-360 * (float)M_PI / 180
startAngle:90.0 * (float)M_PI / 180.0
endAngle:angleOffset2
clockwise:NO];

[bottomBarPath addLineToPoint:CGPointMake(width, yOffset)];
Expand All @@ -153,19 +160,23 @@ - (UIBezierPath *)drawWithPlainPath:(UIBezierPath *)bottomBarPath
[bottomBarPath addLineToPoint:CGPointMake(0, yOffset)];
[bottomBarPath addLineToPoint:CGPointMake(arcCenter1.x - arcRadius, yOffset)];

CGFloat angleOffset1 = arcCenter1.y == yOffset ? 0 : asin((yOffset - arcCenter1.y) / arcRadius);

// draw circle with radius 0 to ensure we have the same number of points as the cut-out path
[bottomBarPath addArcWithCenter:arcCenter1
[bottomBarPath addArcWithCenter:CGPointMake(arcCenter1.x, yOffset)
radius:0
startAngle:-180 * (float)M_PI / 180
endAngle:-270 * (float)M_PI / 180
startAngle:(180.0 * (float)M_PI / 180.0) - angleOffset1
endAngle:90.0 * (float)M_PI / 180.0
clockwise:NO];
[bottomBarPath addLineToPoint:CGPointMake(arcCenter2.x, yOffset)];

CGFloat angleOffset2 = arcCenter2.y == yOffset ? 0 : asin((yOffset - arcCenter2.y) / arcRadius);

// draw circle with radius 0 to ensure we have the same number of points as the cut-out path
[bottomBarPath addArcWithCenter:arcCenter2
[bottomBarPath addArcWithCenter:CGPointMake(arcCenter2.x, yOffset)
radius:0
startAngle:-270 * (float)M_PI / 180
endAngle:-360 * (float)M_PI / 180
startAngle:90.0 * (float)M_PI / 180.0
endAngle:angleOffset2
clockwise:NO];

[bottomBarPath addLineToPoint:CGPointMake(width, yOffset)];
Expand Down

0 comments on commit eb324d0

Please sign in to comment.