92 const Vec2f scaledSize{m_size.x * m_scale.x, m_size.y * m_scale.y};
93 const Vec2f scaledOrigin{m_origin.x * m_scale.x, m_origin.y * m_scale.y};
94 const Vec2f topLeft = m_position - scaledOrigin;
96 if (m_rotation == 0.f) {
100 const float c = std::cos(m_rotation);
101 const float s = std::sin(m_rotation);
103 const auto rotate = [&](
const Vec2f &point) {
104 const Vec2f local = point - m_position;
106 return Vec2f{m_position.x + local.x * c - local.y * s,
107 m_position.y + local.x * s + local.y * c};
110 const Vec2f p0 = rotate(topLeft);
111 const Vec2f p1 = rotate({topLeft.x + scaledSize.x, topLeft.y});
112 const Vec2f p2 = rotate({topLeft.x + scaledSize.x, topLeft.y + scaledSize.y});
113 const Vec2f p3 = rotate({topLeft.x, topLeft.y + scaledSize.y});
115 const float minX = std::min({p0.x, p1.x, p2.x, p3.x});
116 const float minY = std::min({p0.y, p1.y, p2.y, p3.y});
117 const float maxX = std::max({p0.x, p1.x, p2.x, p3.x});
118 const float maxY = std::max({p0.y, p1.y, p2.y, p3.y});
120 return FloatRect({minX, minY}, {maxX - minX, maxY - minY});