Magic_Game/core/Node/Shape/CircleShape.cpp

56 lines
1.0 KiB
C++
Raw Normal View History

2018-04-21 21:24:46 +08:00
#include "..\..\e2dshape.h"
2018-05-22 22:29:42 +08:00
e2d::CircleShape::CircleShape()
: _radius(0)
{
this->setPivot(0.5, 0.5);
}
2018-07-28 20:06:27 +08:00
e2d::CircleShape::CircleShape(float radius)
{
this->setRadius(radius);
this->setPivot(0.5, 0.5);
}
2018-07-28 20:06:27 +08:00
e2d::CircleShape::CircleShape(Point center, float radius)
{
this->setRadius(radius);
this->setPos(center);
this->setPivot(0.5, 0.5);
}
2018-05-22 22:29:42 +08:00
e2d::CircleShape::~CircleShape()
{
}
2018-07-28 20:06:27 +08:00
float e2d::CircleShape::getRadius() const
{
return _radius;
}
2018-07-28 20:06:27 +08:00
void e2d::CircleShape::setRadius(float radius)
{
2018-07-28 20:06:27 +08:00
_radius = radius;
Node::setSize(radius * 2, radius * 2);
}
void e2d::CircleShape::_renderLine() const
{
auto renderer = Renderer::getInstance();
renderer->getRenderTarget()->DrawEllipse(
D2D1::Ellipse(D2D1::Point2F(_radius, _radius), _radius, _radius),
renderer->getSolidColorBrush(),
2018-05-24 20:10:11 +08:00
_strokeWidth,
_strokeStyle
);
}
void e2d::CircleShape::_renderFill() const
{
auto renderer = Renderer::getInstance();
renderer->getRenderTarget()->FillEllipse(
D2D1::Ellipse(D2D1::Point2F(_radius, _radius), _radius, _radius),
renderer->getSolidColorBrush()
);
}