|
SFML
Simple and Fast Multimedia Library
|
Specialized shape representing a convex polygon. More...
#include <ConvexShape.hpp>
Public Member Functions | |
| ConvexShape (std::size_t pointCount=0) | |
| Default constructor. | |
| void | setPointCount (std::size_t count) |
| Set the number of points of the polygon. | |
| std::size_t | getPointCount () const override |
| Get the number of points of the polygon. | |
| void | setPoint (std::size_t index, Vector2f point) |
| Set the position of a point. | |
| Vector2f | getPoint (std::size_t index) const override |
| Get the position of a point. | |
| Public Member Functions inherited from sf::Shape | |
| void | setTexture (const Texture *texture, bool resetRect=false) |
| Change the source texture of the shape. | |
| void | setTextureRect (const IntRect &rect) |
| Set the sub-rectangle of the texture that the shape will display. | |
| void | setFillColor (Color color) |
| Set the fill color of the shape. | |
| void | setOutlineColor (Color color) |
| Set the outline color of the shape. | |
| void | setOutlineThickness (float thickness) |
| Set the thickness of the shape's outline. | |
| const Texture * | getTexture () const |
| Get the source texture of the shape. | |
| const IntRect & | getTextureRect () const |
| Get the sub-rectangle of the texture displayed by the shape. | |
| Color | getFillColor () const |
| Get the fill color of the shape. | |
| Color | getOutlineColor () const |
| Get the outline color of the shape. | |
| float | getOutlineThickness () const |
| Get the outline thickness of the shape. | |
| virtual Vector2f | getGeometricCenter () const |
| Get the geometric center of the shape. | |
| FloatRect | getLocalBounds () const |
| Get the local bounding rectangle of the entity. | |
| FloatRect | getGlobalBounds () const |
| Get the global (non-minimal) bounding rectangle of the entity. | |
| Public Member Functions inherited from sf::Drawable | |
| virtual | ~Drawable ()=default |
| Virtual destructor. | |
| Public Member Functions inherited from sf::Transformable | |
| Transformable ()=default | |
| Default constructor. | |
| virtual | ~Transformable ()=default |
| Virtual destructor. | |
| void | setPosition (Vector2f position) |
| set the position of the object | |
| void | setRotation (Angle angle) |
| set the orientation of the object | |
| void | setScale (Vector2f factors) |
| set the scale factors of the object | |
| void | setOrigin (Vector2f origin) |
| set the local origin of the object | |
| Vector2f | getPosition () const |
| get the position of the object | |
| Angle | getRotation () const |
| get the orientation of the object | |
| Vector2f | getScale () const |
| get the current scale of the object | |
| Vector2f | getOrigin () const |
| get the local origin of the object | |
| void | move (Vector2f offset) |
| Move the object by a given offset. | |
| void | rotate (Angle angle) |
| Rotate the object. | |
| void | scale (Vector2f factor) |
| Scale the object. | |
| const Transform & | getTransform () const |
| get the combined transform of the object | |
| const Transform & | getInverseTransform () const |
| get the inverse of the combined transform of the object | |
Additional Inherited Members | |
| Protected Member Functions inherited from sf::Shape | |
| void | update () |
| Recompute the internal geometry of the shape. | |
Specialized shape representing a convex polygon.
This class inherits all the functions of sf::Transformable (position, rotation, scale, bounds, ...) as well as the functions of sf::Shape (outline, color, texture, ...).
It is important to keep in mind that a convex shape must always be... convex, otherwise it may not be drawn correctly. Moreover, the points must be defined in order; using a random order would result in an incorrect shape.
Usage example:
|
explicit |
Default constructor.
| pointCount | Number of points of the polygon |
|
nodiscardoverridevirtual |
Get the position of a point.
The returned point is in local coordinates, that is, the shape's transforms (position, rotation, scale) are not taken into account. The result is undefined if index is out of the valid range.
| index | Index of the point to get, in range [0 .. getPointCount() - 1] |
Implements sf::Shape.
|
nodiscardoverridevirtual |
Get the number of points of the polygon.
Implements sf::Shape.
| void sf::ConvexShape::setPoint | ( | std::size_t | index, |
| Vector2f | point ) |
Set the position of a point.
Don't forget that the shape must be convex and the order of points matters. Points should not overlap. This applies to rendering; it is explicitly allowed to temporarily have non-convex or degenerate shapes when not drawn (e.g. during shape initialization).
Point count must be specified beforehand. The behavior is undefined if index is greater than or equal to getPointCount.
| index | Index of the point to change, in range [0 .. getPointCount() - 1] |
| point | New position of the point |
| void sf::ConvexShape::setPointCount | ( | std::size_t | count | ) |
Set the number of points of the polygon.
For the shape to be rendered as expected, count must be greater or equal to 3.
| count | New number of points of the polygon |