91 const Vec2f scaledSize{m_size.x * m_scale.x, m_size.y * m_scale.y};
92 const Vec2f scaledOrigin{m_origin.x * m_scale.x, m_origin.y * m_scale.y};
93 const Vec2f topLeft = m_position - scaledOrigin;
95 if (m_rotation == 0.f) {
99 const float c = std::cos(m_rotation);
100 const float s = std::sin(m_rotation);
102 const auto rotate = [&](
const Vec2f &point) {
103 const Vec2f local = point - m_position;
105 return Vec2f{m_position.x + local.x * c - local.y * s,
106 m_position.y + local.x * s + local.y * c};
109 const Vec2f p0 = rotate(topLeft);
110 const Vec2f p1 = rotate({topLeft.x + scaledSize.x, topLeft.y});
111 const Vec2f p2 = rotate({topLeft.x + scaledSize.x, topLeft.y + scaledSize.y});
112 const Vec2f p3 = rotate({topLeft.x, topLeft.y + scaledSize.y});
114 const float minX = std::min({p0.x, p1.x, p2.x, p3.x});
115 const float minY = std::min({p0.y, p1.y, p2.y, p3.y});
116 const float maxX = std::max({p0.x, p1.x, p2.x, p3.x});
117 const float maxY = std::max({p0.y, p1.y, p2.y, p3.y});
119 return FloatRect({minX, minY}, {maxX - minX, maxY - minY});