From 1eca4fbdf5f52f15f610c9b95c28d650c4b9b9dd Mon Sep 17 00:00:00 2001 From: Nomango <569629550@qq.com> Date: Thu, 24 May 2018 20:10:11 +0800 Subject: [PATCH] =?UTF-8?q?Shape=E5=A2=9E=E5=8A=A0=E7=BA=BF=E6=9D=A1?= =?UTF-8?q?=E7=9B=B8=E4=BA=A4=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/Node/Shape/CircleShape.cpp | 3 ++- core/Node/Shape/EllipseShape.cpp | 3 ++- core/Node/Shape/RectShape.cpp | 3 ++- core/Node/Shape/RoundRectShape.cpp | 3 ++- core/Node/Shape/Shape.cpp | 28 ++++++++++++++++++++++++---- core/e2dshape.h | 6 ++++++ 6 files changed, 38 insertions(+), 8 deletions(-) diff --git a/core/Node/Shape/CircleShape.cpp b/core/Node/Shape/CircleShape.cpp index 9438c0eb..b7b88581 100644 --- a/core/Node/Shape/CircleShape.cpp +++ b/core/Node/Shape/CircleShape.cpp @@ -39,7 +39,8 @@ void e2d::CircleShape::_renderLine() Renderer::getRenderTarget()->DrawEllipse( D2D1::Ellipse(D2D1::Point2F(_radius, _radius), _radius, _radius), Renderer::getSolidColorBrush(), - _strokeWidth + _strokeWidth, + _strokeStyle ); } diff --git a/core/Node/Shape/EllipseShape.cpp b/core/Node/Shape/EllipseShape.cpp index 5234f02a..a75011a6 100644 --- a/core/Node/Shape/EllipseShape.cpp +++ b/core/Node/Shape/EllipseShape.cpp @@ -53,7 +53,8 @@ void e2d::EllipseShape::_renderLine() Renderer::getRenderTarget()->DrawEllipse( D2D1::Ellipse(D2D1::Point2F(_radiusX, _radiusY), _radiusX, _radiusY), Renderer::getSolidColorBrush(), - _strokeWidth + _strokeWidth, + _strokeStyle ); } diff --git a/core/Node/Shape/RectShape.cpp b/core/Node/Shape/RectShape.cpp index 3adfa584..2346e0a8 100644 --- a/core/Node/Shape/RectShape.cpp +++ b/core/Node/Shape/RectShape.cpp @@ -25,7 +25,8 @@ void e2d::RectShape::_renderLine() Renderer::getRenderTarget()->DrawRectangle( D2D1::RectF(0, 0, _width, _height), Renderer::getSolidColorBrush(), - _strokeWidth + _strokeWidth, + _strokeStyle ); } diff --git a/core/Node/Shape/RoundRectShape.cpp b/core/Node/Shape/RoundRectShape.cpp index e38cbf61..78cc35ff 100644 --- a/core/Node/Shape/RoundRectShape.cpp +++ b/core/Node/Shape/RoundRectShape.cpp @@ -51,7 +51,8 @@ void e2d::RoundRectShape::_renderLine() Renderer::getRenderTarget()->DrawRoundedRectangle( D2D1::RoundedRect(D2D1::RectF(0, 0, _width, _height), _radiusX, _radiusY), Renderer::getSolidColorBrush(), - _strokeWidth + _strokeWidth, + _strokeStyle ); } diff --git a/core/Node/Shape/Shape.cpp b/core/Node/Shape/Shape.cpp index 9049355c..1b4c7bae 100644 --- a/core/Node/Shape/Shape.cpp +++ b/core/Node/Shape/Shape.cpp @@ -2,9 +2,10 @@ e2d::Shape::Shape() : _style(Style::SOLID) - , _fillColor(Color::BLUE, 0.3) - , _lineColor(Color::BLUE, 0.5) - , _strokeWidth(1) + , _fillColor(0x6090A0U) + , _lineColor(0x78B7D0U) + , _strokeWidth(2) + , _strokeStyle(nullptr) { } @@ -80,10 +81,29 @@ void e2d::Shape::setLineColor(Color lineColor) void e2d::Shape::setStrokeWidth(double strokeWidth) { - _strokeWidth = float(strokeWidth); + _strokeWidth = float(strokeWidth) * 2; } void e2d::Shape::setStyle(Style style) { _style = style; } + +void e2d::Shape::setLineJoin(LineJoin lineJoin) +{ + switch (lineJoin) + { + case LineJoin::MITER: + _strokeStyle = Renderer::getMiterID2D1StrokeStyle(); + break; + case LineJoin::BEVEL: + _strokeStyle = Renderer::getBevelID2D1StrokeStyle(); + break; + case LineJoin::ROUND: + _strokeStyle = Renderer::getRoundID2D1StrokeStyle(); + break; + default: + _strokeStyle = nullptr; + break; + } +} diff --git a/core/e2dshape.h b/core/e2dshape.h index 262834a2..d9a01e96 100644 --- a/core/e2dshape.h +++ b/core/e2dshape.h @@ -53,6 +53,11 @@ public: // 设置样式 void setStyle(Style style); + // 设置线条相交样式 + void setLineJoin( + LineJoin lineJoin + ); + // 渲染形状 virtual void onRender() override; @@ -68,6 +73,7 @@ protected: float _strokeWidth; Color _lineColor; Color _fillColor; + ID2D1StrokeStyle * _strokeStyle; };