An sf::Shape subclass that draws a rectangle with rounded corners.
More...
#include <RoundedRectangle.h>
Public Member Functions | |
| RoundedRectangle (const sf::Vector2f &size=sf::Vector2f(0, 0), float radius=0.f, unsigned int cornerPointCount=8) | |
| Construct a rounded rectangle. | |
| unsigned int | getCornerPointCount () const |
| Return the current per-corner vertex count. | |
| Color | getFillColor () const |
| virtual Vector2f | getGeometricCenter () const |
| FloatRect | getGlobalBounds () const |
| const Transform & | getInverseTransform () const |
| FloatRect | getLocalBounds () const |
| float | getMiterLimit () const |
| Vector2f | getOrigin () const |
| Color | getOutlineColor () const |
| float | getOutlineThickness () const |
| virtual sf::Vector2f | getPoint (std::size_t index) const override |
| Return the position of a single vertex. | |
| virtual std::size_t | getPointCount () const override |
| Return the total number of shape vertices. | |
| Vector2f | getPosition () const |
| float | getRadius () const |
| Return the current corner arc radius. | |
| Angle | getRotation () const |
| Vector2f | getScale () const |
| const sf::Vector2f & | getSize () const |
| Return the current size of the rectangle. | |
| const Texture * | getTexture () const |
| const IntRect & | getTextureRect () const |
| const Transform & | getTransform () const |
| void | move (Vector2f offset) |
| void | rotate (Angle angle) |
| void | scale (Vector2f factor) |
| void | setCornerPointCount (unsigned int count) |
| Set the number of vertices per corner arc. | |
| void | setFillColor (Color color) |
| void | setMiterLimit (float miterLimit) |
| void | setOrigin (Vector2f origin) |
| void | setOutlineColor (Color color) |
| void | setOutlineThickness (float thickness) |
| void | setPosition (Vector2f position) |
| void | setRadius (float radius) |
| Set the corner arc radius. | |
| void | setRotation (Angle angle) |
| void | setScale (Vector2f factors) |
| void | setSize (const sf::Vector2f &size) |
| Set the width and height of the rectangle. | |
| void | setTexture (const Texture *texture, bool resetRect=false) |
| void | setTextureRect (const IntRect &rect) |
Protected Member Functions | |
| virtual void | draw (RenderTarget &target, RenderStates states) const=0 |
| void | update () |
An sf::Shape subclass that draws a rectangle with rounded corners.
RoundedRectangle extends sf::Shape by generating vertex geometry for a rectangle whose corners are replaced by circular arcs. The number of vertices per arc is configurable, trading smoothness for polygon count.
It is the underlying shape type used by ml::Rectangle — most user code interacts with RoundedRectangle indirectly through that class. Direct use is appropriate when you need fine control over corner radius or point count without the additional framework layers.
Setting radius to 0 produces a standard sharp-cornered rectangle.
Definition at line 40 of file RoundedRectangle.h.
|
explicit |
Construct a rounded rectangle.
| size | Width and height of the rectangle in pixels. Defaults to {0, 0}. |
| radius | Corner arc radius in pixels. Defaults to 0 (sharp corners). Clamped to half the shorter side so corners never overlap. |
| cornerPointCount | Number of vertices used to approximate each corner arc. Higher values produce smoother corners at the cost of more geometry. Defaults to 8. |
| unsigned int ml::RoundedRectangle::getCornerPointCount | ( | ) | const |
Return the current per-corner vertex count.
|
overridevirtual |
Return the position of a single vertex.
Required by sf::Shape for geometry generation.
| index | Vertex index in [0, getPointCount()). |
Implements sf::Shape.
|
overridevirtual |
| float ml::RoundedRectangle::getRadius | ( | ) | const |
Return the current corner arc radius.
| const sf::Vector2f & ml::RoundedRectangle::getSize | ( | ) | const |
Return the current size of the rectangle.
| void ml::RoundedRectangle::setCornerPointCount | ( | unsigned int | count | ) |
Set the number of vertices per corner arc.
Triggers geometry regeneration.
| count | Vertex count per corner. Must be at least 1. |
| void ml::RoundedRectangle::setRadius | ( | float | radius | ) |
Set the corner arc radius.
Triggers geometry regeneration. Values larger than half the shorter side are clamped automatically.
| radius | Corner radius in pixels. |
| void ml::RoundedRectangle::setSize | ( | const sf::Vector2f & | size | ) |
Set the width and height of the rectangle.
Triggers geometry regeneration.
| size | New size in pixels. |