path2d.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2013 The ClanLib Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Harry Storbacka
27 ** Mark Page
28 */
29 
30 #pragma once
31 
32 
33 #include "../api_display.h"
34 #include <vector>
35 #include "../../Core/Math/point.h"
36 #include "../../Core/Math/ear_clip_triangulator.h"
37 
38 namespace clan
39 {
42 
43 class BezierCurve;
44 class Path2D_Impl;
45 
46 class CL_API_DISPLAY Path2D
47 {
50 
51 public:
52  Path2D();
53 
54  virtual ~Path2D();
55 
56 
60 
61 public:
62 
63  bool is_hole(PolygonOrientation orientation) const;
64 
65  bool is_inside_contour(const Path2D &other) const;
66 
67  bool is_point_inside(const Pointf &point) const;
68 
69  const std::vector<Pointf> &get_contour_points() const;
70 
71 
72 
76 
77 public:
78 
79  void add_curve(BezierCurve &);
80 
81  void add_line_to(const Pointf &p);
82 
83  void add_line_to( const std::vector<Pointf> &points);
84 
85  inline void add_line_to(float x, float y) {add_line_to(Pointf(x, y));}
86 
87  // Reverse the contours
88  void reverse();
89 
93 
94 private:
95 
96  std::shared_ptr<Path2D_Impl> impl;
98 };
99 
100 }
PolygonOrientation
Polygon orientations.
Definition: ear_clip_triangulator.h:53
2D (x,y) point structure - Float
Definition: point.h:73
Definition: path2d.h:46
void add_line_to(float x, float y)
Definition: path2d.h:85
Bezier curve generator.
Definition: bezier_curve.h:47