Magic_Game/core/Shape/Rect.cpp

45 lines
774 B
C++
Raw Normal View History

2018-02-03 22:04:43 +08:00
#include "..\eshape.h"
#include "..\enodes.h"
e2d::Rect::Rect()
2017-10-28 18:48:21 +08:00
: m_pD2dRectangle(nullptr)
{
}
e2d::Rect::Rect(float x, float y, float width, float height)
2017-12-15 21:51:07 +08:00
: m_pD2dRectangle(nullptr)
{
this->_setRect(x, y, x + width, y + height);
}
e2d::Rect::Rect(Node * node)
2017-12-15 21:51:07 +08:00
: m_pD2dRectangle(nullptr)
{
this->_setRect(
2017-10-29 23:48:32 +08:00
0,
0,
node->getRealWidth(),
node->getRealHeight()
);
}
e2d::Rect::~Rect()
2017-10-29 23:48:32 +08:00
{
SafeReleaseInterface(&m_pD2dRectangle);
}
void e2d::Rect::_setRect(float left, float top, float right, float bottom)
{
SafeReleaseInterface(&m_pD2dRectangle);
Renderer::getID2D1Factory()->CreateRectangleGeometry(
D2D1::RectF(left, top, right, bottom),
&m_pD2dRectangle
);
}
ID2D1RectangleGeometry * e2d::Rect::_getD2dGeometry() const
{
return m_pD2dRectangle;
}