From 2d360165c5d319f91c466b80ea36598e995a0aee Mon Sep 17 00:00:00 2001 From: Anthony Nicholls Date: Sat, 24 Aug 2024 09:00:05 +0100 Subject: [PATCH] macOS: Prevent negative corner sizes for rounded rectangles --- .../juce_graphics/native/juce_CoreGraphicsContext_mac.mm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/juce_graphics/native/juce_CoreGraphicsContext_mac.mm b/modules/juce_graphics/native/juce_CoreGraphicsContext_mac.mm index 02cedb0f11..a1a66d3c1f 100644 --- a/modules/juce_graphics/native/juce_CoreGraphicsContext_mac.mm +++ b/modules/juce_graphics/native/juce_CoreGraphicsContext_mac.mm @@ -654,12 +654,12 @@ void CoreGraphicsContext::drawRoundedRectangle (const Rectangle& r, float detail::MutablePathPtr path { CGPathCreateMutable() }; CGPathAddRoundedRect (path.get(), nullptr, convertToCGRectFlipped (outsideRect), - jmin (outsideCornerSize, outsideRect.getWidth() / 2.0f), - jmin (outsideCornerSize, outsideRect.getHeight() / 2.0f)); + std::clamp (outsideCornerSize, 0.0f, outsideRect.getWidth() / 2.0f), + std::clamp (outsideCornerSize, 0.0f, outsideRect.getHeight() / 2.0f)); CGPathAddRoundedRect (path.get(), nullptr, convertToCGRectFlipped (insideRect), - jmin (insideCornerSize, insideRect.getWidth() / 2.0f), - jmin (insideCornerSize, insideRect.getHeight() / 2.0f)); + std::clamp (insideCornerSize, 0.0f, insideRect.getWidth() / 2.0f), + std::clamp (insideCornerSize, 0.0f, insideRect.getHeight() / 2.0f)); CGContextAddPath (context.get(), path.get()); drawCurrentPath (kCGPathEOFill);