shape2d.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 "path2d.h"
35 #include <vector>
36 #include "../Render/primitives_array.h"
37 #include "color.h"
38 
39 namespace clan
40 {
43 
44 class GraphicContext;
45 class Canvas;
46 class Shape2D_Impl;
47 class Rectf;
48 
49 class CL_API_DISPLAY Shape2D
50 {
53 
54 public:
55  Shape2D();
56  virtual ~Shape2D();
57 
58 
62 
63 public:
65  void get_triangles(std::vector<Vec2f> &out_primitives_array, PolygonOrientation orientation = cl_clockwise) const;
66 
67  void get_outline(std::vector< std::vector<Vec2f> > &out_primitives_array_outline) const;
68 
72 
73 public:
74 
75  void add_path(Path2D &path);
76 
78  void add_circle(float center_x, float center_y, float radius, bool reverse = false);
79 
81  void add_ellipse(float center_x, float center_y, float radius_x, float radius_y, bool reverse = false);
82 
87  void add_circle(const Pointf &center, float radius_x, bool reverse = false);
88 
93  void add_ellipse(const Pointf &center, const Pointf &radius, bool reverse = false);
94 
95  void add_rounded_rect(const Pointf &origin, const Sizef &size, float cap_rounding, bool reverse = false);
96 
97  void add_rounded_rect(const Pointf &origin, const Sizef &size, float cap_rounding, const Angle &angle, bool reverse = false);
98 
99  void add_rect(const Rectf &rect, bool reverse = false);
100 
101  void add_rect(const Rectf &rect, const Angle &angle, bool reverse = false);
102 
103  void add_rounded_line(const Pointf &start, const Pointf &end, float line_width, float cap_rounding, bool reverse);
104 
108 
109 private:
110 
111  std::shared_ptr<Shape2D_Impl> impl;
112 
113 
115 };
116 
117 }
Angle class.
Definition: angle.h:63
PolygonOrientation
Polygon orientations.
Definition: ear_clip_triangulator.h:53
2D (left,top,right,bottom) rectangle structure - Float
Definition: rect.h:467
Definition: ear_clip_triangulator.h:55
2D (x,y) point structure - Float
Definition: point.h:73
Definition: shape2d.h:49
Definition: path2d.h:46
2D (width,height) size structure - Float
Definition: size.h:170