b82539ece8bee6d53020769142a55631b25c4e31
[TDDC76_proj.git] /
1 ////////////////////////////////////////////////////////////
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages 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 freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
23 ////////////////////////////////////////////////////////////
24
25 #ifndef SFML_CIRCLESHAPE_HPP
26 #define SFML_CIRCLESHAPE_HPP
27
28 ////////////////////////////////////////////////////////////
29 // Headers
30 ////////////////////////////////////////////////////////////
31 #include <SFML/Graphics/Export.hpp>
32 #include <SFML/Graphics/Shape.hpp>
33
34
35 namespace sf
36 {
37 ////////////////////////////////////////////////////////////
38 /// \brief Specialized shape representing a circle
39 ///
40 ////////////////////////////////////////////////////////////
41 class SFML_GRAPHICS_API CircleShape : public Shape
42 {
43 public :
44
45 ////////////////////////////////////////////////////////////
46 /// \brief Default constructor
47 ///
48 /// \param radius Radius of the circle
49 /// \param pointCount Number of points composing the circle
50 ///
51 ////////////////////////////////////////////////////////////
52 explicit CircleShape(float radius = 0, unsigned int pointCount = 30);
53
54 ////////////////////////////////////////////////////////////
55 /// \brief Set the radius of the circle
56 ///
57 /// \param radius New radius of the circle
58 ///
59 /// \see getRadius
60 ///
61 ////////////////////////////////////////////////////////////
62 void setRadius(float radius);
63
64 ////////////////////////////////////////////////////////////
65 /// \brief Get the radius of the circle
66 ///
67 /// \return Radius of the circle
68 ///
69 /// \see setRadius
70 ///
71 ////////////////////////////////////////////////////////////
72 float getRadius() const;
73
74 ////////////////////////////////////////////////////////////
75 /// \brief Set the number of points of the circle
76 ///
77 /// \param count New number of points of the circle
78 ///
79 /// \see getPointCount
80 ///
81 ////////////////////////////////////////////////////////////
82 void setPointCount(unsigned int count);
83
84 ////////////////////////////////////////////////////////////
85 /// \brief Get the number of points of the shape
86 ///
87 /// \return Number of points of the shape
88 ///
89 /// \see setPointCount
90 ///
91 ////////////////////////////////////////////////////////////
92 virtual unsigned int getPointCount() const;
93
94 ////////////////////////////////////////////////////////////
95 /// \brief Get a point of the shape
96 ///
97 /// The result is undefined if \a index is out of the valid range.
98 ///
99 /// \param index Index of the point to get, in range [0 .. getPointCount() - 1]
100 ///
101 /// \return Index-th point of the shape
102 ///
103 ////////////////////////////////////////////////////////////
104 virtual Vector2f getPoint(unsigned int index) const;
105
106 private :
107
108 ////////////////////////////////////////////////////////////
109 // Member data
110 ////////////////////////////////////////////////////////////
111 float m_radius; ///< Radius of the circle
112 unsigned int m_pointCount; ///< Number of points composing the circle
113 };
114
115 } // namespace sf
116
117
118 #endif // SFML_CIRCLESHAPE_HPP
119
120
121 ////////////////////////////////////////////////////////////
122 /// \class sf::CircleShape
123 /// \ingroup graphics
124 ///
125 /// This class inherits all the functions of sf::Transformable
126 /// (position, rotation, scale, bounds, ...) as well as the
127 /// functions of sf::Shape (outline, color, texture, ...).
128 ///
129 /// Usage example:
130 /// \code
131 /// sf::CircleShape circle;
132 /// circle.setRadius(150);
133 /// circle.setOutlineColor(sf::Color::Red);
134 /// circle.setOutlineThickness(5);
135 /// circle.setPosition(10, 20);
136 /// ...
137 /// window.draw(circle);
138 /// \endcode
139 ///
140 /// Since the graphics card can't draw perfect circles, we have to
141 /// fake them with multiple triangles connected to each other. The
142 /// "points count" property of sf::CircleShape defines how many of these
143 /// triangles to use, and therefore defines the quality of the circle.
144 ///
145 /// The number of points can also be used for another purpose; with
146 /// small numbers you can create any regular polygon shape:
147 /// equilateral triangle, square, pentagon, hexagon, ...
148 ///
149 /// \see sf::Shape, sf::RectangleShape, sf::ConvexShape
150 ///
151 ////////////////////////////////////////////////////////////