1 ////////////////////////////////////////////////////////////
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
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.
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:
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.
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
21 // 3. This notice may not be removed or altered from any source distribution.
23 ////////////////////////////////////////////////////////////
25 #ifndef SFML_CIRCLESHAPE_HPP
26 #define SFML_CIRCLESHAPE_HPP
28 ////////////////////////////////////////////////////////////
30 ////////////////////////////////////////////////////////////
31 #include <SFML/Graphics/Export.hpp>
32 #include <SFML/Graphics/Shape.hpp>
37 ////////////////////////////////////////////////////////////
38 /// \brief Specialized shape representing a circle
40 ////////////////////////////////////////////////////////////
41 class SFML_GRAPHICS_API CircleShape : public Shape
45 ////////////////////////////////////////////////////////////
46 /// \brief Default constructor
48 /// \param radius Radius of the circle
49 /// \param pointCount Number of points composing the circle
51 ////////////////////////////////////////////////////////////
52 explicit CircleShape(float radius = 0, unsigned int pointCount = 30);
54 ////////////////////////////////////////////////////////////
55 /// \brief Set the radius of the circle
57 /// \param radius New radius of the circle
61 ////////////////////////////////////////////////////////////
62 void setRadius(float radius);
64 ////////////////////////////////////////////////////////////
65 /// \brief Get the radius of the circle
67 /// \return Radius of the circle
71 ////////////////////////////////////////////////////////////
72 float getRadius() const;
74 ////////////////////////////////////////////////////////////
75 /// \brief Set the number of points of the circle
77 /// \param count New number of points of the circle
79 /// \see getPointCount
81 ////////////////////////////////////////////////////////////
82 void setPointCount(unsigned int count);
84 ////////////////////////////////////////////////////////////
85 /// \brief Get the number of points of the shape
87 /// \return Number of points of the shape
89 /// \see setPointCount
91 ////////////////////////////////////////////////////////////
92 virtual unsigned int getPointCount() const;
94 ////////////////////////////////////////////////////////////
95 /// \brief Get a point of the shape
97 /// The result is undefined if \a index is out of the valid range.
99 /// \param index Index of the point to get, in range [0 .. getPointCount() - 1]
101 /// \return Index-th point of the shape
103 ////////////////////////////////////////////////////////////
104 virtual Vector2f getPoint(unsigned int index) const;
108 ////////////////////////////////////////////////////////////
110 ////////////////////////////////////////////////////////////
111 float m_radius; ///< Radius of the circle
112 unsigned int m_pointCount; ///< Number of points composing the circle
118 #endif // SFML_CIRCLESHAPE_HPP
121 ////////////////////////////////////////////////////////////
122 /// \class sf::CircleShape
123 /// \ingroup graphics
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, ...).
131 /// sf::CircleShape circle;
132 /// circle.setRadius(150);
133 /// circle.setOutlineColor(sf::Color::Red);
134 /// circle.setOutlineThickness(5);
135 /// circle.setPosition(10, 20);
137 /// window.draw(circle);
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.
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, ...
149 /// \see sf::Shape, sf::RectangleShape, sf::ConvexShape
151 ////////////////////////////////////////////////////////////