see #15, 移除Shape类

This commit is contained in:
Haibo 2018-08-10 17:10:57 +08:00
parent c7115a1162
commit c580b70931
12 changed files with 0 additions and 670 deletions

View File

@ -1,55 +0,0 @@
#include "..\..\e2dshape.h"
e2d::CircleShape::CircleShape()
: _radius(0)
{
this->setPivot(0.5, 0.5);
}
e2d::CircleShape::CircleShape(float radius)
{
this->setRadius(radius);
this->setPivot(0.5, 0.5);
}
e2d::CircleShape::CircleShape(Point center, float radius)
{
this->setRadius(radius);
this->setPos(center);
this->setPivot(0.5, 0.5);
}
e2d::CircleShape::~CircleShape()
{
}
float e2d::CircleShape::getRadius() const
{
return _radius;
}
void e2d::CircleShape::setRadius(float radius)
{
_radius = radius;
Node::setSize(radius * 2, radius * 2);
}
void e2d::CircleShape::_renderLine() const
{
auto renderer = Renderer::getInstance();
renderer->getRenderTarget()->DrawEllipse(
D2D1::Ellipse(D2D1::Point2F(_radius, _radius), _radius, _radius),
renderer->getSolidColorBrush(),
_strokeWidth,
_strokeStyle
);
}
void e2d::CircleShape::_renderFill() const
{
auto renderer = Renderer::getInstance();
renderer->getRenderTarget()->FillEllipse(
D2D1::Ellipse(D2D1::Point2F(_radius, _radius), _radius, _radius),
renderer->getSolidColorBrush()
);
}

View File

@ -1,69 +0,0 @@
#include "..\..\e2dshape.h"
e2d::EllipseShape::EllipseShape()
: _radiusX(0)
, _radiusY(0)
{
this->setPivot(0.5, 0.5);
}
e2d::EllipseShape::EllipseShape(float radiusX, float radiusY)
{
this->setRadiusX(radiusX);
this->setRadiusY(radiusY);
this->setPivot(0.5, 0.5);
}
e2d::EllipseShape::EllipseShape(Point center, float radiusX, float radiusY)
{
this->setRadiusX(radiusX);
this->setRadiusY(radiusY);
this->setPos(center);
this->setPivot(0.5, 0.5);
}
e2d::EllipseShape::~EllipseShape()
{
}
float e2d::EllipseShape::getRadiusX() const
{
return _radiusX;
}
float e2d::EllipseShape::getRadiusY() const
{
return _radiusY;
}
void e2d::EllipseShape::setRadiusX(float radiusX)
{
_radiusX = radiusX;
Node::setWidth(radiusX * 2);
}
void e2d::EllipseShape::setRadiusY(float radiusY)
{
_radiusY = radiusY;
Node::setHeight(radiusY * 2);
}
void e2d::EllipseShape::_renderLine() const
{
auto renderer = Renderer::getInstance();
renderer->getRenderTarget()->DrawEllipse(
D2D1::Ellipse(D2D1::Point2F(_radiusX, _radiusY), _radiusX, _radiusY),
renderer->getSolidColorBrush(),
_strokeWidth,
_strokeStyle
);
}
void e2d::EllipseShape::_renderFill() const
{
auto renderer = Renderer::getInstance();
renderer->getRenderTarget()->FillEllipse(
D2D1::Ellipse(D2D1::Point2F(_radiusX, _radiusY), _radiusX, _radiusY),
renderer->getSolidColorBrush()
);
}

View File

@ -1,41 +0,0 @@
#include "..\..\e2dshape.h"
e2d::RectShape::RectShape()
{
}
e2d::RectShape::RectShape(Size size)
{
this->setSize(size);
}
e2d::RectShape::RectShape(Point topLeft, Size size)
{
this->setPivot(0, 0);
this->setPos(topLeft);
this->setSize(size);
}
e2d::RectShape::~RectShape()
{
}
void e2d::RectShape::_renderLine() const
{
auto renderer = Renderer::getInstance();
renderer->getRenderTarget()->DrawRectangle(
D2D1::RectF(0, 0, _width, _height),
renderer->getSolidColorBrush(),
_strokeWidth,
_strokeStyle
);
}
void e2d::RectShape::_renderFill() const
{
auto renderer = Renderer::getInstance();
renderer->getRenderTarget()->FillRectangle(
D2D1::RectF(0, 0, _width, _height),
renderer->getSolidColorBrush()
);
}

View File

@ -1,67 +0,0 @@
#include "..\..\e2dshape.h"
e2d::RoundRectShape::RoundRectShape()
: _radiusX(0)
, _radiusY(0)
{
}
e2d::RoundRectShape::RoundRectShape(Size size, float radiusX, float radiusY)
: _radiusX(radiusX)
, _radiusY(radiusY)
{
this->setSize(size);
}
e2d::RoundRectShape::RoundRectShape(Point topLeft, Size size, float radiusX, float radiusY)
: _radiusX(radiusX)
, _radiusY(radiusY)
{
this->setPivot(0, 0);
this->setPos(topLeft);
this->setSize(size);
}
e2d::RoundRectShape::~RoundRectShape()
{
}
float e2d::RoundRectShape::getRadiusX() const
{
return _radiusX;
}
float e2d::RoundRectShape::getRadiusY() const
{
return _radiusY;
}
void e2d::RoundRectShape::setRadiusX(float radiusX)
{
_radiusX = radiusX;
}
void e2d::RoundRectShape::setRadiusY(float radiusY)
{
_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(),
_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()
);
}

View File

@ -1,109 +0,0 @@
#include "..\..\e2dshape.h"
e2d::Shape::Shape()
: _style(Style::Solid)
, _fillColor(0x6090A0U)
, _lineColor(0x78B7D0U)
, _strokeWidth(2)
, _strokeStyle(nullptr)
{
}
e2d::Shape::~Shape()
{
}
void e2d::Shape::onRender() const
{
auto pBrush = Renderer::getInstance()->getSolidColorBrush();
pBrush->SetOpacity(_displayOpacity);
switch (_style)
{
case Style::Fill:
{
pBrush->SetColor((D2D1_COLOR_F)_fillColor);
this->_renderFill();
pBrush->SetColor((D2D1_COLOR_F)_lineColor);
this->_renderLine();
break;
}
case Style::Round:
{
pBrush->SetColor((D2D1_COLOR_F)_lineColor);
this->_renderLine();
break;
}
case Style::Solid:
{
pBrush->SetColor((D2D1_COLOR_F)_fillColor);
this->_renderFill();
break;
}
default:
break;
}
}
e2d::Color e2d::Shape::getFillColor() const
{
return _fillColor;
}
e2d::Color e2d::Shape::getLineColor() const
{
return _lineColor;
}
float e2d::Shape::getStrokeWidth() const
{
return _strokeWidth;
}
e2d::Shape::Style 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(float strokeWidth)
{
_strokeWidth = strokeWidth * 2;
}
void e2d::Shape::setStyle(Style style)
{
_style = style;
}
void e2d::Shape::setLineJoin(LineJoin lineJoin)
{
switch (lineJoin)
{
case LineJoin::Miter:
_strokeStyle = Renderer::getMiterStrokeStyle();
break;
case LineJoin::Bevel:
_strokeStyle = Renderer::getBevelStrokeStyle();
break;
case LineJoin::Round:
_strokeStyle = Renderer::getRoundStrokeStyle();
break;
default:
_strokeStyle = nullptr;
break;
}
}

View File

@ -1,254 +0,0 @@
#pragma once
#include "e2dnode.h"
namespace e2d
{
// 形状
class Shape :
public Node
{
public:
// 形状样式
enum class Style
{
Solid, /* 填充 */
Round, /* 轮廓 */
Fill, /* 轮廓 + 填充 */
};
public:
Shape();
virtual ~Shape();
// 获取样式
Style getStyle() const;
// 获取填充颜色
Color getFillColor() const;
// 获取线条颜色
Color getLineColor() const;
// 获取线条宽度
float getStrokeWidth() const;
// 设置填充颜色
void setFillColor(
Color fillColor
);
// 设置线条颜色
void setLineColor(
Color lineColor
);
// 设置线条宽度
void setStrokeWidth(
float strokeWidth
);
// 设置样式
void setStyle(Style style);
// 设置线条相交样式
void setLineJoin(
LineJoin lineJoin
);
// 渲染形状
virtual void onRender() const override;
protected:
E2D_DISABLE_COPY(Shape);
// 渲染轮廓
virtual void _renderLine() const = 0;
// 渲染填充色
virtual void _renderFill() const = 0;
protected:
Style _style;
float _strokeWidth;
Color _lineColor;
Color _fillColor;
ID2D1StrokeStyle * _strokeStyle;
};
// 矩形
class RectShape :
public Shape
{
public:
RectShape();
explicit RectShape(
Size size /* 宽度和高度 */
);
explicit RectShape(
Point topLeft, /* 左上角坐标 */
Size size /* 宽度和高度 */
);
virtual ~RectShape();
protected:
E2D_DISABLE_COPY(RectShape);
// 渲染轮廓
virtual void _renderLine() const override;
// 渲染填充色
virtual void _renderFill() const override;
};
// 圆角矩形
class RoundRectShape :
public Shape
{
public:
RoundRectShape();
explicit RoundRectShape(
Size size, /* 宽度和高度 */
float radiusX, /* 圆角半径 */
float radiusY /* 圆角半径 */
);
explicit RoundRectShape(
Point topLeft, /* 左上角坐标 */
Size size, /* 宽度和高度 */
float radiusX, /* 圆角半径 */
float radiusY /* 圆角半径 */
);
virtual ~RoundRectShape();
// 获取圆角半径
float getRadiusX() const;
// 获取圆角半径
float getRadiusY() const;
// 设置圆角半径
virtual void setRadiusX(
float radiusX
);
// 设置圆角半径
virtual void setRadiusY(
float radiusY
);
protected:
E2D_DISABLE_COPY(RoundRectShape);
// 渲染轮廓
virtual void _renderLine() const override;
// 渲染填充色
virtual void _renderFill() const override;
protected:
float _radiusX;
float _radiusY;
};
// 圆形
class CircleShape :
public Shape
{
public:
CircleShape();
explicit CircleShape(
float radius /* 半径 */
);
explicit CircleShape(
Point center, /* 圆心坐标 */
float radius /* 半径 */
);
virtual ~CircleShape();
// 获取半径
float getRadius() const;
// 设置半径
virtual void setRadius(
float radius
);
protected:
E2D_DISABLE_COPY(CircleShape);
// 渲染轮廓
virtual void _renderLine() const override;
// 渲染填充色
virtual void _renderFill() const override;
protected:
float _radius;
};
// 椭圆形
class EllipseShape :
public Shape
{
public:
EllipseShape();
explicit EllipseShape(
float radiusX, /* 横轴半径 */
float radiusY /* 纵轴半径 */
);
explicit EllipseShape(
Point center, /* 圆心坐标 */
float radiusX, /* 横轴半径 */
float radiusY /* 纵轴半径 */
);
virtual ~EllipseShape();
// 获取横轴半径
float getRadiusX() const;
// 获取纵轴半径
float getRadiusY() const;
// 设置横轴半径
virtual void setRadiusX(
float radiusX
);
// 设置纵轴半径
virtual void setRadiusY(
float radiusY
);
protected:
E2D_DISABLE_COPY(EllipseShape);
// 渲染轮廓
virtual void _renderLine() const override;
// 渲染填充色
virtual void _renderFill() const override;
protected:
float _radiusX;
float _radiusY;
};
}

View File

@ -26,7 +26,6 @@
<ClInclude Include="..\..\core\e2dmacros.h" />
<ClInclude Include="..\..\core\e2dmanager.h" />
<ClInclude Include="..\..\core\e2dnode.h" />
<ClInclude Include="..\..\core\e2dshape.h" />
<ClInclude Include="..\..\core\e2dtool.h" />
<ClInclude Include="..\..\core\e2dtransition.h" />
<ClInclude Include="..\..\core\easy2d.h" />
@ -84,11 +83,6 @@
<ClCompile Include="..\..\core\Node\Button.cpp" />
<ClCompile Include="..\..\core\Node\Menu.cpp" />
<ClCompile Include="..\..\core\Node\Node.cpp" />
<ClCompile Include="..\..\core\Node\Shape\CircleShape.cpp" />
<ClCompile Include="..\..\core\Node\Shape\EllipseShape.cpp" />
<ClCompile Include="..\..\core\Node\Shape\RectShape.cpp" />
<ClCompile Include="..\..\core\Node\Shape\RoundRectShape.cpp" />
<ClCompile Include="..\..\core\Node\Shape\Shape.cpp" />
<ClCompile Include="..\..\core\Node\Sprite.cpp" />
<ClCompile Include="..\..\core\Node\Text.cpp" />
<ClCompile Include="..\..\core\Node\ToggleButton.cpp" />

View File

@ -22,9 +22,6 @@
<Filter Include="Transition">
<UniqueIdentifier>{337d5a0f-60fd-473a-83da-b2a3515affd9}</UniqueIdentifier>
</Filter>
<Filter Include="Node\Shape">
<UniqueIdentifier>{f0ed2748-5199-48d1-930c-286afd27c235}</UniqueIdentifier>
</Filter>
<Filter Include="Custom">
<UniqueIdentifier>{8ef0d8e2-1138-40c0-a1a8-0eb681721f4e}</UniqueIdentifier>
</Filter>
@ -40,7 +37,6 @@
<ClInclude Include="..\..\core\e2dmacros.h" />
<ClInclude Include="..\..\core\e2dmanager.h" />
<ClInclude Include="..\..\core\e2dnode.h" />
<ClInclude Include="..\..\core\e2dshape.h" />
<ClInclude Include="..\..\core\e2dtool.h" />
<ClInclude Include="..\..\core\e2dtransition.h" />
<ClInclude Include="..\..\core\easy2d.h" />
@ -187,21 +183,6 @@
<ClCompile Include="..\..\core\Node\ToggleButton.cpp">
<Filter>Node</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Node\Shape\CircleShape.cpp">
<Filter>Node\Shape</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Node\Shape\EllipseShape.cpp">
<Filter>Node\Shape</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Node\Shape\RectShape.cpp">
<Filter>Node\Shape</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Node\Shape\RoundRectShape.cpp">
<Filter>Node\Shape</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Node\Shape\Shape.cpp">
<Filter>Node\Shape</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Tool\Data.cpp">
<Filter>Tool</Filter>
</ClCompile>

View File

@ -170,7 +170,6 @@
<ClInclude Include="..\..\core\e2dmacros.h" />
<ClInclude Include="..\..\core\e2dmanager.h" />
<ClInclude Include="..\..\core\e2dnode.h" />
<ClInclude Include="..\..\core\e2dshape.h" />
<ClInclude Include="..\..\core\e2dtool.h" />
<ClInclude Include="..\..\core\e2dtransition.h" />
<ClInclude Include="..\..\core\easy2d.h" />
@ -228,11 +227,6 @@
<ClCompile Include="..\..\core\Node\Button.cpp" />
<ClCompile Include="..\..\core\Node\Menu.cpp" />
<ClCompile Include="..\..\core\Node\Node.cpp" />
<ClCompile Include="..\..\core\Node\Shape\CircleShape.cpp" />
<ClCompile Include="..\..\core\Node\Shape\EllipseShape.cpp" />
<ClCompile Include="..\..\core\Node\Shape\RectShape.cpp" />
<ClCompile Include="..\..\core\Node\Shape\RoundRectShape.cpp" />
<ClCompile Include="..\..\core\Node\Shape\Shape.cpp" />
<ClCompile Include="..\..\core\Node\Sprite.cpp" />
<ClCompile Include="..\..\core\Node\Text.cpp" />
<ClCompile Include="..\..\core\Node\ToggleButton.cpp" />

View File

@ -22,9 +22,6 @@
<Filter Include="Transition">
<UniqueIdentifier>{337d5a0f-60fd-473a-83da-b2a3515affd9}</UniqueIdentifier>
</Filter>
<Filter Include="Node\Shape">
<UniqueIdentifier>{47b7c15b-ac05-4773-a9ee-7aa352830f02}</UniqueIdentifier>
</Filter>
<Filter Include="Custom">
<UniqueIdentifier>{7660a3fa-36f9-4b1b-8942-e38e02c0c95b}</UniqueIdentifier>
</Filter>
@ -40,7 +37,6 @@
<ClInclude Include="..\..\core\e2dmacros.h" />
<ClInclude Include="..\..\core\e2dmanager.h" />
<ClInclude Include="..\..\core\e2dnode.h" />
<ClInclude Include="..\..\core\e2dshape.h" />
<ClInclude Include="..\..\core\e2dtool.h" />
<ClInclude Include="..\..\core\e2dtransition.h" />
<ClInclude Include="..\..\core\easy2d.h" />
@ -187,21 +183,6 @@
<ClCompile Include="..\..\core\Node\ToggleButton.cpp">
<Filter>Node</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Node\Shape\CircleShape.cpp">
<Filter>Node\Shape</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Node\Shape\EllipseShape.cpp">
<Filter>Node\Shape</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Node\Shape\RectShape.cpp">
<Filter>Node\Shape</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Node\Shape\RoundRectShape.cpp">
<Filter>Node\Shape</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Node\Shape\Shape.cpp">
<Filter>Node\Shape</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Tool\Data.cpp">
<Filter>Tool</Filter>
</ClCompile>

View File

@ -249,11 +249,6 @@
<ClCompile Include="..\..\core\Node\ToggleButton.cpp" />
<ClCompile Include="..\..\core\Node\Menu.cpp" />
<ClCompile Include="..\..\core\Node\Node.cpp" />
<ClCompile Include="..\..\core\Node\Shape\CircleShape.cpp" />
<ClCompile Include="..\..\core\Node\Shape\EllipseShape.cpp" />
<ClCompile Include="..\..\core\Node\Shape\RectShape.cpp" />
<ClCompile Include="..\..\core\Node\Shape\RoundRectShape.cpp" />
<ClCompile Include="..\..\core\Node\Shape\Shape.cpp" />
<ClCompile Include="..\..\core\Node\Sprite.cpp" />
<ClCompile Include="..\..\core\Node\Text.cpp" />
<ClCompile Include="..\..\core\Tool\Data.cpp" />
@ -279,7 +274,6 @@
<ClInclude Include="..\..\core\e2dmacros.h" />
<ClInclude Include="..\..\core\e2dmanager.h" />
<ClInclude Include="..\..\core\e2dnode.h" />
<ClInclude Include="..\..\core\e2dshape.h" />
<ClInclude Include="..\..\core\e2dtool.h" />
<ClInclude Include="..\..\core\e2dtransition.h" />
</ItemGroup>

View File

@ -22,9 +22,6 @@
<Filter Include="Common">
<UniqueIdentifier>{be5d9314-b00a-4f11-bd2a-1f720dc32407}</UniqueIdentifier>
</Filter>
<Filter Include="Node\Shape">
<UniqueIdentifier>{eb72b49a-5b2f-4fc0-9ad2-8f5e02efac6f}</UniqueIdentifier>
</Filter>
<Filter Include="Custom">
<UniqueIdentifier>{3475b59d-d50c-43b1-8334-bcb9e1703ed2}</UniqueIdentifier>
</Filter>
@ -93,9 +90,6 @@
<ClCompile Include="..\..\core\Tool\Path.cpp">
<Filter>Tool</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Node\Shape\Shape.cpp">
<Filter>Node\Shape</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Common\Color.cpp">
<Filter>Common</Filter>
</ClCompile>
@ -177,18 +171,6 @@
<ClCompile Include="..\..\core\Common\Font.cpp">
<Filter>Common</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Node\Shape\CircleShape.cpp">
<Filter>Node\Shape</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Node\Shape\EllipseShape.cpp">
<Filter>Node\Shape</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Node\Shape\RectShape.cpp">
<Filter>Node\Shape</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Node\Shape\RoundRectShape.cpp">
<Filter>Node\Shape</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Transition\BoxTransition.cpp">
<Filter>Transition</Filter>
</ClCompile>
@ -261,7 +243,6 @@
<ClInclude Include="..\..\core\e2dmacros.h" />
<ClInclude Include="..\..\core\e2dmanager.h" />
<ClInclude Include="..\..\core\e2dnode.h" />
<ClInclude Include="..\..\core\e2dshape.h" />
<ClInclude Include="..\..\core\e2dtool.h" />
<ClInclude Include="..\..\core\e2dtransition.h" />
<ClInclude Include="..\..\core\e2dcustom.h" />