// // Created by trotfunky on 14/05/19. // #include "Circle.h" namespace xmlParser { Circle::Circle(std::string label, float x, float y, float r, const sf::Color& color) : DrawingElement(std::move(label),x,y,color), r(2) { shape = new sf::CircleShape(r); shape->setPosition(x-r,y-r); shape->setFillColor(color); } Circle::Circle(const pugi::xml_node& node) : DrawingElement(node), r(node.attribute("r").as_int(2)) { if(label == "Test DrawingElement") { label = "Test Circle"; } shape = new sf::CircleShape(r); shape->setPosition(x-r,y-r); shape->setFillColor(color); } void Circle::draw(sf::RenderWindow& window) { window.draw(*(dynamic_cast(shape))); } float Circle::getR() const { return r; } void Circle::setR(float newR) { r = newR; dynamic_cast(shape)->setRadius(r); shape->setPosition(x-r,y-r); } const std::string Circle::toString() const { std::stringstream string; string << label << " at x:" << getX() << " y:" << getY() << " | r:" << getR(); string << " color:" << getStringColor(); return(string.str()); } void Circle::setX(float newX) { DrawingElement::setX(newX); shape->setPosition(x-r,y-r); } void Circle::setY(float newY) { DrawingElement::setY(newY); shape->setPosition(x-r,y-r); } }