Skip to content

Commit

Permalink
CoreGraphics: Prevent an assertion when creating a rounded rectangle
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony-Nicholls committed Oct 3, 2024
1 parent fdf74a7 commit c545ca0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions modules/juce_graphics/native/juce_CoreGraphicsContext_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,10 @@ void setFill (const FillType& newFill)
CGContextSetLineCap (context.get(), kCGLineCapButt);
CGContextSetLineJoin (context.get(), kCGLineJoinMiter);

detail::PathPtr path { CGPathCreateWithRoundedRect (convertToCGRectFlipped (r), cornerSize, cornerSize, nullptr) };
detail::PathPtr path { CGPathCreateWithRoundedRect (convertToCGRectFlipped (r),
std::clamp (cornerSize, 0.0f, r.getWidth() / 2.0f),
std::clamp (cornerSize, 0.0f, r.getHeight() / 2.0f),
nullptr) };
CGContextAddPath (context.get(), path.get());
drawCurrentPath (kCGPathStroke);
}
Expand Down Expand Up @@ -669,7 +672,10 @@ void setFill (const FillType& newFill)
void CoreGraphicsContext::fillRoundedRectangle (const Rectangle<float>& r, float cornerSize)
{
CGContextBeginPath (context.get());
detail::PathPtr path { CGPathCreateWithRoundedRect (convertToCGRectFlipped (r), cornerSize, cornerSize, nullptr) };
detail::PathPtr path { CGPathCreateWithRoundedRect (convertToCGRectFlipped (r),
std::clamp (cornerSize, 0.0f, r.getWidth() / 2.0f),
std::clamp (cornerSize, 0.0f, r.getHeight() / 2.0f),
nullptr) };
CGContextAddPath (context.get(), path.get());
drawCurrentPath (kCGPathFill);
}
Expand Down

0 comments on commit c545ca0

Please sign in to comment.