Kiwano Engine v1.2.x
ShapeMaker.h
1// Copyright (c) 2016-2018 Kiwano - Nomango
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to deal
5// in the Software without restriction, including without limitation the rights
6// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7// copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19// THE SOFTWARE.
20
21#pragma once
22#include <kiwano/render/Shape.h>
23
24namespace kiwano
25{
26
27KGE_DECLARE_SMART_PTR(ShapeMaker);
28
36enum class CombineMode
37{
38 Union,
39 Intersect,
40 Xor,
41 Exclude
42};
43
46class KGE_API ShapeMaker : public NativeObject
47{
48public:
49 ShapeMaker();
50
52
55 ShapePtr GetShape();
56
59 void Clear();
60
64 void BeginPath(const Point& begin_pos = Point());
65
69 void EndPath(bool closed = false);
70
74 void AddLine(const Point& point);
75
79 void AddLines(const Vector<Point>& points);
80
85 void AddLines(const Point* points, size_t count);
86
92 void AddBezier(const Point& point1, const Point& point2, const Point& point3);
93
101 void AddArc(const Point& point, const Size& radius, float rotation, bool clockwise = true, bool is_small = true);
102
110 static ShapePtr Combine(ShapePtr shape_a, ShapePtr shape_b, CombineMode mode, const Matrix3x2* matrix = nullptr);
111
115 void SetShape(ShapePtr shape);
116
117private:
121 void OpenStream();
122
126 void CloseStream();
127
131 bool IsStreamOpened() const;
132
133private:
134 ShapePtr shape_;
135};
136
139} // namespace kiwano
含有本地指针的对象
Definition: NativeObject.hpp:34
形状生成器
Definition: ShapeMaker.h:47
CombineMode
形状合并方式
Definition: ShapeMaker.h:37
@ Intersect
交集 (A + B)
@ Xor
对称差集 ((A - B) + (B - A))
@ Exclude
差集 (A - B)
@ Union
并集 (A + B)