Kiwano Engine v1.3.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
34enum class CombineMode
35{
36 Union,
37 Intersect,
38 Xor,
39 Exclude
40};
41
44class KGE_API ShapeMaker : public NativeObject
45{
46public:
47 ShapeMaker();
48
50
53 RefPtr<Shape> GetShape();
54
57 void Clear();
58
62 void BeginPath(const Point& begin_pos = Point());
63
67 void EndPath(bool closed = false);
68
72 void AddLine(const Point& point);
73
77 void AddLines(const Vector<Point>& points);
78
83 void AddLines(const Point* points, size_t count);
84
90 void AddBezier(const Point& point1, const Point& point2, const Point& point3);
91
99 void AddArc(const Point& point, const Size& radius, float rotation, bool clockwise = true, bool is_small = true);
100
108 static RefPtr<Shape> Combine(RefPtr<Shape> shape_a, RefPtr<Shape> shape_b, CombineMode mode,
109 const Matrix3x2* matrix = nullptr);
110
114 void SetShape(RefPtr<Shape> shape);
115
116private:
120 void OpenStream();
121
125 void CloseStream();
126
130 bool IsStreamOpened() const;
131
132private:
133 RefPtr<Shape> shape_;
134};
135
138} // namespace kiwano
含有本地指针的对象
Definition: NativeObject.hpp:32
引用计数智能指针
Definition: RefBasePtr.hpp:35
形状生成器
Definition: ShapeMaker.h:45
CombineMode
形状合并方式
Definition: ShapeMaker.h:35
@ Intersect
交集 (A + B)
@ Xor
对称差集 ((A - B) + (B - A))
@ Exclude
差集 (A - B)
@ Union
并集 (A + B)