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_RECTANGLESHAPE_HPP
26 #define SFML_RECTANGLESHAPE_HPP
28 ////////////////////////////////////////////////////////////
30 ////////////////////////////////////////////////////////////
31 #include <SFML/Graphics/Export.hpp>
32 #include <SFML/Graphics/Shape.hpp>
37 ////////////////////////////////////////////////////////////
38 /// \brief Specialized shape representing a rectangle
40 ////////////////////////////////////////////////////////////
41 class SFML_GRAPHICS_API RectangleShape : public Shape
45 ////////////////////////////////////////////////////////////
46 /// \brief Default constructor
48 /// \param size Size of the rectangle
50 ////////////////////////////////////////////////////////////
51 explicit RectangleShape(const Vector2f& size = Vector2f(0, 0));
53 ////////////////////////////////////////////////////////////
54 /// \brief Set the size of the rectangle
56 /// \param size New size of the rectangle
60 ////////////////////////////////////////////////////////////
61 void setSize(const Vector2f& size);
63 ////////////////////////////////////////////////////////////
64 /// \brief Get the size of the rectangle
66 /// \return Size of the rectangle
70 ////////////////////////////////////////////////////////////
71 const Vector2f& getSize() const;
73 ////////////////////////////////////////////////////////////
74 /// \brief Get the number of points defining the shape
76 /// \return Number of points of the shape
78 ////////////////////////////////////////////////////////////
79 virtual unsigned int getPointCount() const;
81 ////////////////////////////////////////////////////////////
82 /// \brief Get a point of the shape
84 /// The result is undefined if \a index is out of the valid range.
86 /// \param index Index of the point to get, in range [0 .. getPointCount() - 1]
88 /// \return Index-th point of the shape
90 ////////////////////////////////////////////////////////////
91 virtual Vector2f getPoint(unsigned int index) const;
95 ////////////////////////////////////////////////////////////
97 ////////////////////////////////////////////////////////////
98 Vector2f m_size; ///< Size of the rectangle
104 #endif // SFML_RECTANGLESHAPE_HPP
107 ////////////////////////////////////////////////////////////
108 /// \class sf::RectangleShape
109 /// \ingroup graphics
111 /// This class inherits all the functions of sf::Transformable
112 /// (position, rotation, scale, bounds, ...) as well as the
113 /// functions of sf::Shape (outline, color, texture, ...).
117 /// sf::RectangleShape rectangle;
118 /// rectangle.setSize(sf::Vector2f(100, 50));
119 /// rectangle.setOutlineColor(sf::Color::Red);
120 /// rectangle.setOutlineThickness(5);
121 /// rectangle.setPosition(10, 20);
123 /// window.draw(rectangle);
126 /// \see sf::Shape, sf::CircleShape, sf::ConvexShape
128 ////////////////////////////////////////////////////////////