diff --git a/src/kiwano/2d/ShapeActor.cpp b/src/kiwano/2d/ShapeActor.cpp index 3c03ef79..bbed66fe 100644 --- a/src/kiwano/2d/ShapeActor.cpp +++ b/src/kiwano/2d/ShapeActor.cpp @@ -24,9 +24,36 @@ namespace kiwano { -ShapeActorPtr ShapeActor::Create() + +ShapeActorPtr ShapeActor::Create(ShapePtr shape) { ShapeActorPtr ptr = new (std::nothrow) ShapeActor; + if (ptr) + { + ptr->SetShape(shape); + } + return ptr; +} + +ShapeActorPtr ShapeActor::Create(ShapePtr shape, const Color& fill_color, const Color& stroke_color) +{ + ShapeActorPtr ptr = ShapeActor::Create(shape); + if (ptr) + { + ptr->SetFillColor(fill_color); + ptr->SetStrokeColor(stroke_color); + } + return ptr; +} + +ShapeActorPtr ShapeActor::Create(ShapePtr shape, BrushPtr fill_brush, BrushPtr stroke_brush) +{ + ShapeActorPtr ptr = ShapeActor::Create(shape); + if (ptr) + { + ptr->SetFillBrush(fill_brush); + ptr->SetStrokeBrush(stroke_brush); + } return ptr; } diff --git a/src/kiwano/2d/ShapeActor.h b/src/kiwano/2d/ShapeActor.h index 1090bcbd..a5855d5d 100644 --- a/src/kiwano/2d/ShapeActor.h +++ b/src/kiwano/2d/ShapeActor.h @@ -50,7 +50,22 @@ class KGE_API ShapeActor : public Actor public: /// \~chinese /// @brief 创建形状角色 - static ShapeActorPtr Create(); + /// @param shape 形状 + static ShapeActorPtr Create(ShapePtr shape); + + /// \~chinese + /// @brief 创建形状角色 + /// @param shape 形状 + /// @param fill_color 填充颜色 + /// @param stroke_color 轮廓颜色 + static ShapeActorPtr Create(ShapePtr shape, const Color& fill_color, const Color& stroke_color); + + /// \~chinese + /// @brief 创建形状角色 + /// @param shape 形状 + /// @param fill_brush 填充画刷 + /// @param stroke_brush 轮廓画刷 + static ShapeActorPtr Create(ShapePtr shape, BrushPtr fill_brush, BrushPtr stroke_brush); /// \~chinese /// @brief 构造形状角色