#include "rectanglesfml.h" RectangleSFML::RectangleSFML(sf::RenderTarget * const render_target) : _render_target(render_target) {} void RectangleSFML::setRect(const kku::Area& rect) { _rectangle.setPosition(rect.left, rect.top); _rectangle.setSize({rect.width, rect.height}); } kku::Area RectangleSFML::getRect() const { const auto position = _rectangle.getPosition(); const auto size = _rectangle.getSize(); return kku::Area{position.x, position.y, size.x, size.y}; } void RectangleSFML::move(const kku::Vector2& delta) { _rectangle.move({delta.first, delta.second}); } void RectangleSFML::setPosition(const kku::Point& position) { _rectangle.setPosition({position.x, position.y}); } kku::Point RectangleSFML::getPosition() const { const auto position = _rectangle.getPosition(); return kku::Point{position.x, position.y}; } void RectangleSFML::setColor(const kku::Color& color) { _rectangle.setFillColor(sf::Color{color.red, color.green, color.blue, color.alpha}); } bool RectangleSFML::contains(const kku::Point& position) const { return _rectangle.getGlobalBounds().contains(position.x, position.y); } void RectangleSFML::display() { _render_target->draw(_rectangle); }