Magic_Game/core/Node/Shape/Shape.cpp

90 lines
1.3 KiB
C++
Raw Normal View History

2018-04-21 21:24:46 +08:00
#include "..\..\e2dshape.h"
e2d::Shape::Shape()
2018-05-08 17:40:36 +08:00
: _nStyle(ShapeStyle::SOLID)
, _nFillColor(Color::WHITE)
, _nLineColor(Color::BLUE, 0.5)
, _fStrokeWidth(1)
{
}
e2d::Shape::~Shape()
{
}
void e2d::Shape::onRender()
{
auto pBrush = Renderer::getSolidColorBrush();
2018-05-08 17:40:36 +08:00
pBrush->SetOpacity(_fDisplayOpacity);
2018-05-08 17:40:36 +08:00
switch (_nStyle)
{
case ShapeStyle::FILL:
{
2018-05-08 17:40:36 +08:00
pBrush->SetColor(_nFillColor.toColorF());
this->_renderFill();
2018-05-08 17:40:36 +08:00
pBrush->SetColor(_nLineColor.toColorF());
this->_renderLine();
break;
}
case ShapeStyle::ROUND:
{
2018-05-08 17:40:36 +08:00
pBrush->SetColor(_nLineColor.toColorF());
this->_renderLine();
break;
}
case ShapeStyle::SOLID:
{
2018-05-08 17:40:36 +08:00
pBrush->SetColor(_nFillColor.toColorF());
this->_renderFill();
break;
}
default:
break;
}
}
e2d::Color e2d::Shape::getFillColor() const
{
2018-05-08 17:40:36 +08:00
return _nFillColor;
}
e2d::Color e2d::Shape::getLineColor() const
{
2018-05-08 17:40:36 +08:00
return _nLineColor;
}
double e2d::Shape::getStrokeWidth() const
{
2018-05-08 17:40:36 +08:00
return _fStrokeWidth;
}
e2d::ShapeStyle e2d::Shape::getStyle() const
{
2018-05-08 17:40:36 +08:00
return _nStyle;
}
void e2d::Shape::setFillColor(Color fillColor)
{
2018-05-08 17:40:36 +08:00
_nFillColor = fillColor;
}
void e2d::Shape::setLineColor(Color lineColor)
{
2018-05-08 17:40:36 +08:00
_nLineColor = lineColor;
}
void e2d::Shape::setStrokeWidth(double strokeWidth)
{
2018-05-08 17:40:36 +08:00
_fStrokeWidth = static_cast<float>(strokeWidth);
}
void e2d::Shape::setStyle(ShapeStyle style)
{
2018-05-08 17:40:36 +08:00
_nStyle = style;
}