diff --git a/core/Node/Shape/CircleShape.cpp b/core/Node/Shape/CircleShape.cpp deleted file mode 100644 index 7484ff61..00000000 --- a/core/Node/Shape/CircleShape.cpp +++ /dev/null @@ -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() - ); -} diff --git a/core/Node/Shape/EllipseShape.cpp b/core/Node/Shape/EllipseShape.cpp deleted file mode 100644 index 390fb994..00000000 --- a/core/Node/Shape/EllipseShape.cpp +++ /dev/null @@ -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() - ); -} diff --git a/core/Node/Shape/RectShape.cpp b/core/Node/Shape/RectShape.cpp deleted file mode 100644 index 09f10042..00000000 --- a/core/Node/Shape/RectShape.cpp +++ /dev/null @@ -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() - ); -} diff --git a/core/Node/Shape/RoundRectShape.cpp b/core/Node/Shape/RoundRectShape.cpp deleted file mode 100644 index edc1e90d..00000000 --- a/core/Node/Shape/RoundRectShape.cpp +++ /dev/null @@ -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() - ); -} diff --git a/core/Node/Shape/Shape.cpp b/core/Node/Shape/Shape.cpp deleted file mode 100644 index ce4ee333..00000000 --- a/core/Node/Shape/Shape.cpp +++ /dev/null @@ -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; - } -} diff --git a/core/e2dshape.h b/core/e2dshape.h deleted file mode 100644 index 35dc476b..00000000 --- a/core/e2dshape.h +++ /dev/null @@ -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; -}; - -} \ No newline at end of file diff --git a/project/vs2012/Easy2D.vcxproj b/project/vs2012/Easy2D.vcxproj index e1522094..a1ee16e3 100644 --- a/project/vs2012/Easy2D.vcxproj +++ b/project/vs2012/Easy2D.vcxproj @@ -26,7 +26,6 @@ - @@ -84,11 +83,6 @@ - - - - - diff --git a/project/vs2012/Easy2D.vcxproj.filters b/project/vs2012/Easy2D.vcxproj.filters index adc4b8ad..75870946 100644 --- a/project/vs2012/Easy2D.vcxproj.filters +++ b/project/vs2012/Easy2D.vcxproj.filters @@ -22,9 +22,6 @@ {337d5a0f-60fd-473a-83da-b2a3515affd9} - - {f0ed2748-5199-48d1-930c-286afd27c235} - {8ef0d8e2-1138-40c0-a1a8-0eb681721f4e} @@ -40,7 +37,6 @@ - @@ -187,21 +183,6 @@ Node - - Node\Shape - - - Node\Shape - - - Node\Shape - - - Node\Shape - - - Node\Shape - Tool diff --git a/project/vs2013/Easy2D.vcxproj b/project/vs2013/Easy2D.vcxproj index 72e3899b..bafed80c 100644 --- a/project/vs2013/Easy2D.vcxproj +++ b/project/vs2013/Easy2D.vcxproj @@ -170,7 +170,6 @@ - @@ -228,11 +227,6 @@ - - - - - diff --git a/project/vs2013/Easy2D.vcxproj.filters b/project/vs2013/Easy2D.vcxproj.filters index c4d2a342..67d75b16 100644 --- a/project/vs2013/Easy2D.vcxproj.filters +++ b/project/vs2013/Easy2D.vcxproj.filters @@ -22,9 +22,6 @@ {337d5a0f-60fd-473a-83da-b2a3515affd9} - - {47b7c15b-ac05-4773-a9ee-7aa352830f02} - {7660a3fa-36f9-4b1b-8942-e38e02c0c95b} @@ -40,7 +37,6 @@ - @@ -187,21 +183,6 @@ Node - - Node\Shape - - - Node\Shape - - - Node\Shape - - - Node\Shape - - - Node\Shape - Tool diff --git a/project/vs2017/Easy2D.vcxproj b/project/vs2017/Easy2D.vcxproj index a4af2d6e..cb54607a 100644 --- a/project/vs2017/Easy2D.vcxproj +++ b/project/vs2017/Easy2D.vcxproj @@ -249,11 +249,6 @@ - - - - - @@ -279,7 +274,6 @@ - diff --git a/project/vs2017/Easy2D.vcxproj.filters b/project/vs2017/Easy2D.vcxproj.filters index 40b24ac5..a687485f 100644 --- a/project/vs2017/Easy2D.vcxproj.filters +++ b/project/vs2017/Easy2D.vcxproj.filters @@ -22,9 +22,6 @@ {be5d9314-b00a-4f11-bd2a-1f720dc32407} - - {eb72b49a-5b2f-4fc0-9ad2-8f5e02efac6f} - {3475b59d-d50c-43b1-8334-bcb9e1703ed2} @@ -93,9 +90,6 @@ Tool - - Node\Shape - Common @@ -177,18 +171,6 @@ Common - - Node\Shape - - - Node\Shape - - - Node\Shape - - - Node\Shape - Transition @@ -261,7 +243,6 @@ -