Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-02 08:58:13

0001 ////////////////////////////////////////////////////////////
0002 //
0003 // SFML - Simple and Fast Multimedia Library
0004 // Copyright (C) 2007-2023 Laurent Gomila (laurent@sfml-dev.org)
0005 //
0006 // This software is provided 'as-is', without any express or implied warranty.
0007 // In no event will the authors be held liable for any damages arising from the use of this software.
0008 //
0009 // Permission is granted to anyone to use this software for any purpose,
0010 // including commercial applications, and to alter it and redistribute it freely,
0011 // subject to the following restrictions:
0012 //
0013 // 1. The origin of this software must not be misrepresented;
0014 //    you must not claim that you wrote the original software.
0015 //    If you use this software in a product, an acknowledgment
0016 //    in the product documentation would be appreciated but is not required.
0017 //
0018 // 2. Altered source versions must be plainly marked as such,
0019 //    and must not be misrepresented as being the original software.
0020 //
0021 // 3. This notice may not be removed or altered from any source distribution.
0022 //
0023 ////////////////////////////////////////////////////////////
0024 
0025 #ifndef SFML_RECTANGLESHAPE_HPP
0026 #define SFML_RECTANGLESHAPE_HPP
0027 
0028 ////////////////////////////////////////////////////////////
0029 // Headers
0030 ////////////////////////////////////////////////////////////
0031 #include <SFML/Graphics/Export.hpp>
0032 #include <SFML/Graphics/Shape.hpp>
0033 
0034 
0035 namespace sf
0036 {
0037 ////////////////////////////////////////////////////////////
0038 /// \brief Specialized shape representing a rectangle
0039 ///
0040 ////////////////////////////////////////////////////////////
0041 class SFML_GRAPHICS_API RectangleShape : public Shape
0042 {
0043 public:
0044 
0045     ////////////////////////////////////////////////////////////
0046     /// \brief Default constructor
0047     ///
0048     /// \param size Size of the rectangle
0049     ///
0050     ////////////////////////////////////////////////////////////
0051     explicit RectangleShape(const Vector2f& size = Vector2f(0, 0));
0052 
0053     ////////////////////////////////////////////////////////////
0054     /// \brief Set the size of the rectangle
0055     ///
0056     /// \param size New size of the rectangle
0057     ///
0058     /// \see getSize
0059     ///
0060     ////////////////////////////////////////////////////////////
0061     void setSize(const Vector2f& size);
0062 
0063     ////////////////////////////////////////////////////////////
0064     /// \brief Get the size of the rectangle
0065     ///
0066     /// \return Size of the rectangle
0067     ///
0068     /// \see setSize
0069     ///
0070     ////////////////////////////////////////////////////////////
0071     const Vector2f& getSize() const;
0072 
0073     ////////////////////////////////////////////////////////////
0074     /// \brief Get the number of points defining the shape
0075     ///
0076     /// \return Number of points of the shape. For rectangle
0077     ///         shapes, this number is always 4.
0078     ///
0079     ////////////////////////////////////////////////////////////
0080     virtual std::size_t getPointCount() const;
0081 
0082     ////////////////////////////////////////////////////////////
0083     /// \brief Get a point of the rectangle
0084     ///
0085     /// The returned point is in local coordinates, that is,
0086     /// the shape's transforms (position, rotation, scale) are
0087     /// not taken into account.
0088     /// The result is undefined if \a index is out of the valid range.
0089     ///
0090     /// \param index Index of the point to get, in range [0 .. 3]
0091     ///
0092     /// \return index-th point of the shape
0093     ///
0094     ////////////////////////////////////////////////////////////
0095     virtual Vector2f getPoint(std::size_t index) const;
0096 
0097 private:
0098 
0099     ////////////////////////////////////////////////////////////
0100     // Member data
0101     ////////////////////////////////////////////////////////////
0102     Vector2f m_size; //!< Size of the rectangle
0103 };
0104 
0105 } // namespace sf
0106 
0107 
0108 #endif // SFML_RECTANGLESHAPE_HPP
0109 
0110 
0111 ////////////////////////////////////////////////////////////
0112 /// \class sf::RectangleShape
0113 /// \ingroup graphics
0114 ///
0115 /// This class inherits all the functions of sf::Transformable
0116 /// (position, rotation, scale, bounds, ...) as well as the
0117 /// functions of sf::Shape (outline, color, texture, ...).
0118 ///
0119 /// Usage example:
0120 /// \code
0121 /// sf::RectangleShape rectangle;
0122 /// rectangle.setSize(sf::Vector2f(100, 50));
0123 /// rectangle.setOutlineColor(sf::Color::Red);
0124 /// rectangle.setOutlineThickness(5);
0125 /// rectangle.setPosition(10, 20);
0126 /// ...
0127 /// window.draw(rectangle);
0128 /// \endcode
0129 ///
0130 /// \see sf::Shape, sf::CircleShape, sf::ConvexShape
0131 ///
0132 ////////////////////////////////////////////////////////////