From 27acbab3d9b1d048dd6648c83a6267a634bd9f3a Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Wed, 15 Nov 2023 14:12:47 -0700 Subject: [PATCH] Use `sf::Rect::getCenter()` in more places --- examples/cocoa/CocoaAppDelegate.mm | 4 +--- src/SFML/Graphics/Text.cpp | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/examples/cocoa/CocoaAppDelegate.mm b/examples/cocoa/CocoaAppDelegate.mm index 12dae6166..473913d8b 100644 --- a/examples/cocoa/CocoaAppDelegate.mm +++ b/examples/cocoa/CocoaAppDelegate.mm @@ -47,9 +47,7 @@ struct SFMLmainWindow logo.setSmooth(true); - sf::FloatRect rect = sprite.getLocalBounds(); - sf::Vector2f size(rect.width, rect.height); - sprite.setOrigin(size / 2.f); + sprite.setOrigin(sprite.getLocalBounds().getCenter()); sprite.scale({0.3f, 0.3f}); unsigned int ww = renderWindow.getSize().x; diff --git a/src/SFML/Graphics/Text.cpp b/src/SFML/Graphics/Text.cpp index 2feab6429..a13586ea2 100644 --- a/src/SFML/Graphics/Text.cpp +++ b/src/SFML/Graphics/Text.cpp @@ -398,8 +398,7 @@ void Text::ensureGeometryUpdate() const // Compute the location of the strike through dynamically // We use the center point of the lowercase 'x' glyph as the reference // We reuse the underline thickness as the thickness of the strike through as well - const FloatRect xBounds = m_font->getGlyph(U'x', m_characterSize, isBold).bounds; - const float strikeThroughOffset = xBounds.top + xBounds.height / 2.f; + const float strikeThroughOffset = m_font->getGlyph(U'x', m_characterSize, isBold).bounds.getCenter().y; // Precompute the variables needed by the algorithm float whitespaceWidth = m_font->getGlyph(U' ', m_characterSize, isBold).advance;