tsp_cpp/snippets/Circle.cpp

44 lines
919 B
C++
Raw Normal View History

//
// Created by trotfunky on 14/05/19.
//
#include "Circle.h"
namespace xmlParser
{
Circle::Circle() : DrawingElement(), r(2)
{
label = "Test Circle";
shape = new sf::CircleShape(r);
shape->setPosition(x,y);
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,y);
shape->setFillColor(color);
}
void Circle::draw(sf::RenderWindow& window)
{
window.draw(*(dynamic_cast<sf::CircleShape*>(shape)));
}
int Circle::getR() const
{
return r;
}
void Circle::setR(int newR)
{
r = newR;
dynamic_cast<sf::CircleShape*>(shape)->setRadius(r);
}
}