|
|
|||
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_CIRCLESHAPE_HPP 0026 #define SFML_CIRCLESHAPE_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 circle 0039 /// 0040 //////////////////////////////////////////////////////////// 0041 class SFML_GRAPHICS_API CircleShape : public Shape 0042 { 0043 public: 0044 0045 //////////////////////////////////////////////////////////// 0046 /// \brief Default constructor 0047 /// 0048 /// \param radius Radius of the circle 0049 /// \param pointCount Number of points composing the circle 0050 /// 0051 //////////////////////////////////////////////////////////// 0052 explicit CircleShape(float radius = 0, std::size_t pointCount = 30); 0053 0054 //////////////////////////////////////////////////////////// 0055 /// \brief Set the radius of the circle 0056 /// 0057 /// \param radius New radius of the circle 0058 /// 0059 /// \see getRadius 0060 /// 0061 //////////////////////////////////////////////////////////// 0062 void setRadius(float radius); 0063 0064 //////////////////////////////////////////////////////////// 0065 /// \brief Get the radius of the circle 0066 /// 0067 /// \return Radius of the circle 0068 /// 0069 /// \see setRadius 0070 /// 0071 //////////////////////////////////////////////////////////// 0072 float getRadius() const; 0073 0074 //////////////////////////////////////////////////////////// 0075 /// \brief Set the number of points of the circle 0076 /// 0077 /// \param count New number of points of the circle 0078 /// 0079 /// \see getPointCount 0080 /// 0081 //////////////////////////////////////////////////////////// 0082 void setPointCount(std::size_t count); 0083 0084 //////////////////////////////////////////////////////////// 0085 /// \brief Get the number of points of the circle 0086 /// 0087 /// \return Number of points of the circle 0088 /// 0089 /// \see setPointCount 0090 /// 0091 //////////////////////////////////////////////////////////// 0092 virtual std::size_t getPointCount() const; 0093 0094 //////////////////////////////////////////////////////////// 0095 /// \brief Get a point of the circle 0096 /// 0097 /// The returned point is in local coordinates, that is, 0098 /// the shape's transforms (position, rotation, scale) are 0099 /// not taken into account. 0100 /// The result is undefined if \a index is out of the valid range. 0101 /// 0102 /// \param index Index of the point to get, in range [0 .. getPointCount() - 1] 0103 /// 0104 /// \return index-th point of the shape 0105 /// 0106 //////////////////////////////////////////////////////////// 0107 virtual Vector2f getPoint(std::size_t index) const; 0108 0109 private: 0110 0111 //////////////////////////////////////////////////////////// 0112 // Member data 0113 //////////////////////////////////////////////////////////// 0114 float m_radius; //!< Radius of the circle 0115 std::size_t m_pointCount; //!< Number of points composing the circle 0116 }; 0117 0118 } // namespace sf 0119 0120 0121 #endif // SFML_CIRCLESHAPE_HPP 0122 0123 0124 //////////////////////////////////////////////////////////// 0125 /// \class sf::CircleShape 0126 /// \ingroup graphics 0127 /// 0128 /// This class inherits all the functions of sf::Transformable 0129 /// (position, rotation, scale, bounds, ...) as well as the 0130 /// functions of sf::Shape (outline, color, texture, ...). 0131 /// 0132 /// Usage example: 0133 /// \code 0134 /// sf::CircleShape circle; 0135 /// circle.setRadius(150); 0136 /// circle.setOutlineColor(sf::Color::Red); 0137 /// circle.setOutlineThickness(5); 0138 /// circle.setPosition(10, 20); 0139 /// ... 0140 /// window.draw(circle); 0141 /// \endcode 0142 /// 0143 /// Since the graphics card can't draw perfect circles, we have to 0144 /// fake them with multiple triangles connected to each other. The 0145 /// "points count" property of sf::CircleShape defines how many of these 0146 /// triangles to use, and therefore defines the quality of the circle. 0147 /// 0148 /// The number of points can also be used for another purpose; with 0149 /// small numbers you can create any regular polygon shape: 0150 /// equilateral triangle, square, pentagon, hexagon, ... 0151 /// 0152 /// \see sf::Shape, sf::RectangleShape, sf::ConvexShape 0153 /// 0154 ////////////////////////////////////////////////////////////
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|