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()
: _style(ShapeStyle::SOLID)
2018-05-17 12:22:52 +08:00
, _fillColor(Color::BLUE, 0.3)
, _lineColor(Color::BLUE, 0.5)
, _strokeWidth(1)
{
}
e2d::Shape::~Shape()
{
}
void e2d::Shape::onRender()
{
auto pBrush = Renderer::getSolidColorBrush();
pBrush->SetOpacity(_displayOpacity);
switch (_style)
{
case ShapeStyle::FILL:
{
pBrush->SetColor(_fillColor.toColorF());
this->_renderFill();
pBrush->SetColor(_lineColor.toColorF());
this->_renderLine();
break;
}
case ShapeStyle::ROUND:
{
pBrush->SetColor(_lineColor.toColorF());
this->_renderLine();
break;
}
case ShapeStyle::SOLID:
{
pBrush->SetColor(_fillColor.toColorF());
this->_renderFill();
break;
}
default:
break;
}
}
e2d::Color e2d::Shape::getFillColor() const
{
return _fillColor;
}
e2d::Color e2d::Shape::getLineColor() const
{
return _lineColor;
}
double e2d::Shape::getStrokeWidth() const
{
return _strokeWidth;
}
e2d::ShapeStyle e2d::Shape::getStyle() const
{
return _style;
}
void e2d::Shape::setFillColor(Color fillColor)
{
_fillColor = fillColor;
}
void e2d::Shape::setLineColor(Color lineColor)
{
_lineColor = lineColor;
}
void e2d::Shape::setStrokeWidth(double strokeWidth)
{
_strokeWidth = float(strokeWidth);
}
void e2d::Shape::setStyle(ShapeStyle style)
{
_style = style;
}