mirror of
https://github.com/SFML/SFML.git
synced 2024-11-24 20:31:05 +08:00
Remove Rect getPosition and getSize methods
This commit is contained in:
parent
7e5ed78219
commit
c371bc6816
@ -104,26 +104,6 @@ public:
|
||||
////////////////////////////////////////////////////////////
|
||||
constexpr std::optional<Rect<T>> findIntersection(const Rect<T>& rectangle) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the position of the rectangle's top-left corner
|
||||
///
|
||||
/// \return Position of rectangle
|
||||
///
|
||||
/// \see getSize, getCenter
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
constexpr Vector2<T> getPosition() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the size of the rectangle
|
||||
///
|
||||
/// \return Size of rectangle
|
||||
///
|
||||
/// \see getPosition, getCenter
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
constexpr Vector2<T> getSize() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the position of the center of the rectangle
|
||||
///
|
||||
|
@ -110,27 +110,11 @@ constexpr std::optional<Rect<T>> Rect<T>::findIntersection(const Rect<T>& rectan
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
constexpr Vector2<T> Rect<T>::getPosition() const
|
||||
{
|
||||
return Vector2<T>(position.x, position.y);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
constexpr Vector2<T> Rect<T>::getSize() const
|
||||
{
|
||||
return Vector2<T>(size.x, size.y);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
constexpr Vector2<T> Rect<T>::getCenter() const
|
||||
{
|
||||
return getPosition() + getSize() / T{2};
|
||||
return position + size / T{2};
|
||||
}
|
||||
|
||||
|
||||
|
@ -308,7 +308,7 @@ Vector2f RenderTarget::mapPixelToCoords(const Vector2i& point, const View& view)
|
||||
// First, convert from viewport coordinates to homogeneous coordinates
|
||||
const FloatRect viewport = FloatRect(getViewport(view));
|
||||
const Vector2f normalized = Vector2f(-1, 1) +
|
||||
Vector2f(2, -2).cwiseMul(Vector2f(point) - viewport.getPosition()).cwiseDiv(viewport.getSize());
|
||||
Vector2f(2, -2).cwiseMul(Vector2f(point) - viewport.position).cwiseDiv(viewport.size);
|
||||
|
||||
// Then transform by the inverse of the view matrix
|
||||
return view.getInverseTransform().transformPoint(normalized);
|
||||
@ -330,8 +330,8 @@ Vector2i RenderTarget::mapCoordsToPixel(const Vector2f& point, const View& view)
|
||||
|
||||
// Then convert to viewport coordinates
|
||||
const FloatRect viewport = FloatRect(getViewport(view));
|
||||
return Vector2i((normalized.cwiseMul({1, -1}) + sf::Vector2f(1, 1)).cwiseDiv({2, 2}).cwiseMul(viewport.getSize()) +
|
||||
viewport.getPosition());
|
||||
return Vector2i((normalized.cwiseMul({1, -1}) + sf::Vector2f(1, 1)).cwiseDiv({2, 2}).cwiseMul(viewport.size) +
|
||||
viewport.position);
|
||||
}
|
||||
|
||||
|
||||
|
@ -273,8 +273,7 @@ void Shape::updateTexCoords()
|
||||
const float yratio = m_insideBounds.size.y > 0
|
||||
? (m_vertices[i].position.y - m_insideBounds.position.y) / m_insideBounds.size.y
|
||||
: 0;
|
||||
m_vertices[i].texCoords = convertedTextureRect.getPosition() +
|
||||
convertedTextureRect.getSize().cwiseMul({xratio, yratio});
|
||||
m_vertices[i].texCoords = convertedTextureRect.position + convertedTextureRect.size.cwiseMul({xratio, yratio});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -330,7 +330,7 @@ std::optional<Texture> Texture::loadFromImage(const Image& image, bool sRgb, con
|
||||
rectangle.size.y = std::min(rectangle.size.y, height - rectangle.position.y);
|
||||
|
||||
// Create the texture and upload the pixels
|
||||
if (auto texture = sf::Texture::create(Vector2u(rectangle.getSize()), sRgb))
|
||||
if (auto texture = sf::Texture::create(Vector2u(rectangle.size), sRgb))
|
||||
{
|
||||
const TransientContextLock lock;
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
namespace sf
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
View::View(const FloatRect& rectangle) : m_center(rectangle.getCenter()), m_size(rectangle.getSize())
|
||||
View::View(const FloatRect& rectangle) : m_center(rectangle.getCenter()), m_size(rectangle.size)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -91,18 +91,6 @@ TEMPLATE_TEST_CASE("[Graphics] sf::Rect", "", int, float)
|
||||
STATIC_CHECK_FALSE(rectangle.findIntersection(nonIntersectingRectangle).has_value());
|
||||
}
|
||||
|
||||
SECTION("getPosition()")
|
||||
{
|
||||
STATIC_CHECK(sf::Rect<TestType>({}, {}).getPosition() == sf::Vector2<TestType>());
|
||||
STATIC_CHECK(sf::Rect<TestType>({1, 2}, {3, 4}).getPosition() == sf::Vector2<TestType>(1, 2));
|
||||
}
|
||||
|
||||
SECTION("getSize()")
|
||||
{
|
||||
STATIC_CHECK(sf::Rect<TestType>({}, {}).getSize() == sf::Vector2<TestType>());
|
||||
STATIC_CHECK(sf::Rect<TestType>({1, 2}, {3, 4}).getSize() == sf::Vector2<TestType>(3, 4));
|
||||
}
|
||||
|
||||
SECTION("getCenter()")
|
||||
{
|
||||
STATIC_CHECK(sf::Rect<TestType>({}, {}).getCenter() == sf::Vector2<TestType>());
|
||||
|
Loading…
Reference in New Issue
Block a user