Magic_Game/core/Node/Shape/RoundRectShape.cpp

68 lines
1.3 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::RoundRectShape::RoundRectShape()
: _radiusX(0)
, _radiusY(0)
{
}
2018-07-28 20:06:27 +08:00
e2d::RoundRectShape::RoundRectShape(Size size, float radiusX, float radiusY)
: _radiusX(radiusX)
, _radiusY(radiusY)
{
2018-05-17 12:22:52 +08:00
this->setSize(size);
}
2018-07-28 20:06:27 +08:00
e2d::RoundRectShape::RoundRectShape(Point topLeft, Size size, float radiusX, float radiusY)
: _radiusX(radiusX)
, _radiusY(radiusY)
{
2018-05-17 12:22:52 +08:00
this->setPivot(0, 0);
this->setPos(topLeft);
this->setSize(size);
}
2018-05-22 22:29:42 +08:00
e2d::RoundRectShape::~RoundRectShape()
{
}
2018-07-28 20:06:27 +08:00
float e2d::RoundRectShape::getRadiusX() const
{
return _radiusX;
}
2018-07-28 20:06:27 +08:00
float e2d::RoundRectShape::getRadiusY() const
{
return _radiusY;
}
2018-07-28 20:06:27 +08:00
void e2d::RoundRectShape::setRadiusX(float radiusX)
{
2018-07-28 20:06:27 +08:00
_radiusX = radiusX;
}
2018-07-28 20:06:27 +08:00
void e2d::RoundRectShape::setRadiusY(float radiusY)
{
2018-07-28 20:06:27 +08:00
_radiusY = radiusY;
}
void e2d::RoundRectShape::_renderLine() const
{
auto renderer = Renderer::getInstance();
renderer->getRenderTarget()->DrawRoundedRectangle(
D2D1::RoundedRect(D2D1::RectF(0, 0, _width, _height), _radiusX, _radiusY),
renderer->getSolidColorBrush(),
2018-05-24 20:10:11 +08:00
_strokeWidth,
_strokeStyle
);
}
void e2d::RoundRectShape::_renderFill() const
{
auto renderer = Renderer::getInstance();
renderer->getRenderTarget()->FillRoundedRectangle(
D2D1::RoundedRect(D2D1::RectF(0, 0, _width, _height), _radiusX, _radiusY),
renderer->getSolidColorBrush()
);
}