Magic_Game/core/Shape/ShapeCircle.cpp

67 lines
1.3 KiB
C++
Raw Normal View History

2018-02-03 22:04:43 +08:00
#include "..\eshape.h"
2017-10-29 23:48:32 +08:00
#include "..\enodes.h"
e2d::ShapeCircle::ShapeCircle()
2017-10-28 18:48:21 +08:00
: m_pD2dCircle(nullptr)
{
}
e2d::ShapeCircle::ShapeCircle(Point center, double radius)
2017-12-15 21:51:07 +08:00
: m_pD2dCircle(nullptr)
{
this->setCircle(center, radius);
}
e2d::ShapeCircle::ShapeCircle(Node * node)
2017-12-15 21:51:07 +08:00
: m_pD2dCircle(nullptr)
2017-10-29 23:48:32 +08:00
{
2018-02-27 21:07:43 +08:00
double minSide = min(node->getRealWidth(), node->getRealHeight());
this->setCircle(
Point(
2017-10-29 23:48:32 +08:00
node->getRealWidth() / 2,
node->getRealHeight() / 2
),
minSide / 2
);
}
e2d::ShapeCircle::~ShapeCircle()
2017-10-29 23:48:32 +08:00
{
SafeReleaseInterface(&m_pD2dCircle);
}
void e2d::ShapeCircle::setCircle(Point center, double radius)
{
SafeReleaseInterface(&m_pD2dCircle);
Renderer::getID2D1Factory()->CreateEllipseGeometry(
D2D1::Ellipse(
D2D1::Point2F(
2018-02-27 21:07:43 +08:00
static_cast<float>(center.x),
static_cast<float>(center.y)),
static_cast<float>(radius),
static_cast<float>(radius)),
&m_pD2dCircle
);
}
void e2d::ShapeCircle::_resize()
2018-03-07 20:14:58 +08:00
{
if (m_pParentNode && m_bEnable)
{
double minSide = min(m_pParentNode->getRealWidth(), m_pParentNode->getRealHeight());
this->setCircle(
2018-03-07 20:14:58 +08:00
Point(
m_pParentNode->getRealWidth() / 2,
m_pParentNode->getRealHeight() / 2
),
minSide / 2
);
}
}
ID2D1EllipseGeometry * e2d::ShapeCircle::getD2dGeometry() const
{
return m_pD2dCircle;
}