tsp_cpp/snippets/Circle.cpp
trotFunky 71ce85cec4 Continuing vector graphics exercise
New classes :
 - DrawingElement (Base class for every other element)
 - Group : Groups DrawingElements together

Modified Circle to work with DrawingElement
Corrected a *maybe* failed vector copy in Polynomial.tpp
2019-05-16 01:16:19 +02:00

44 lines
No EOL
919 B
C++

//
// 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);
}
}