|
| virtual | ~Shape () |
| | Virtual destructor.
|
| 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 (const Color &color) |
| | Set the fill color of the shape.
|
| void | setOutlineColor (const 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.
|
| const Color & | getFillColor () const |
| | Get the fill color of the shape.
|
| const Color & | getOutlineColor () const |
| | Get the outline color of the shape.
|
| float | getOutlineThickness () const |
| | Get the outline thickness of the shape.
|
| virtual std::size_t | getPointCount () const =0 |
| | Get the total number of points of the shape.
|
| virtual Vector2f | getPoint (std::size_t index) const =0 |
| | Get a point 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.
|
| void | setPosition (float x, float y) |
| | set the position of the object
|
| void | setPosition (const Vector2f &position) |
| | set the position of the object
|
| void | setRotation (float angle) |
| | set the orientation of the object
|
| void | setScale (float factorX, float factorY) |
| | set the scale factors of the object
|
| void | setScale (const Vector2f &factors) |
| | set the scale factors of the object
|
| void | setOrigin (float x, float y) |
| | set the local origin of the object
|
| void | setOrigin (const Vector2f &origin) |
| | set the local origin of the object
|
| const Vector2f & | getPosition () const |
| | get the position of the object
|
| float | getRotation () const |
| | get the orientation of the object
|
| const Vector2f & | getScale () const |
| | get the current scale of the object
|
| const Vector2f & | getOrigin () const |
| | get the local origin of the object
|
| void | move (float offsetX, float offsetY) |
| | Move the object by a given offset.
|
| void | move (const Vector2f &offset) |
| | Move the object by a given offset.
|
| void | rotate (float angle) |
| | Rotate the object.
|
| void | scale (float factorX, float factorY) |
| | Scale the object.
|
| void | scale (const 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
|
Base class for textured shapes with outline.
sf::Shape is a drawable class that allows to define and display a custom convex shape on a render target.
It's only an abstract base, it needs to be specialized for concrete types of shapes (circle, rectangle, convex polygon, star, ...).
In addition to the attributes provided by the specialized shape classes, a shape always has the following attributes:
- a texture
- a texture rectangle
- a fill color
- an outline color
- an outline thickness
Each feature is optional, and can be disabled easily:
- the texture can be null
- the fill/outline colors can be sf::Color::Transparent
- the outline thickness can be zero
You can write your own derived shape class, there are only two virtual functions to override:
- getPointCount must return the number of points of the shape
- getPoint must return the points of the shape
- See also
- sf::RectangleShape, sf::CircleShape, sf::ConvexShape, sf::Transformable
Definition at line 44 of file Shape.hpp.
| FloatRect sf::Shape::getGlobalBounds |
( |
| ) |
const |
Get the global (non-minimal) bounding rectangle of the entity.
The returned rectangle is in global coordinates, which means that it takes into account the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the bounds of the shape in the global 2D world's coordinate system.
This function does not necessarily return the minimal bounding rectangle. It merely ensures that the returned rectangle covers all the vertices (but possibly more). This allows for a fast approximation of the bounds as a first check; you may want to use more precise checks on top of that.
- Returns
- Global bounding rectangle of the entity
| FloatRect sf::Shape::getLocalBounds |
( |
| ) |
const |
Get the local bounding rectangle of the entity.
The returned rectangle is in local coordinates, which means that it ignores the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the bounds of the entity in the entity's coordinate system.
- Returns
- Local bounding rectangle of the entity
| virtual Vector2f sf::Shape::getPoint |
( |
std::size_t | index | ) |
const |
|
pure virtual |
Get a point of the shape.
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.
- Parameters
-
- Returns
- index-th point of the shape
- See also
- getPointCount
Implemented in sf::CircleShape, sf::ConvexShape, and sf::RectangleShape.
| void sf::Transformable::setOrigin |
( |
const Vector2f & | origin | ) |
|
|
inherited |
set the local origin of the object
The origin of an object defines the center point for all transformations (position, scale, rotation). The coordinates of this point must be relative to the top-left corner of the object, and ignore all transformations (position, scale, rotation). The default origin of a transformable object is (0, 0).
- Parameters
-
- See also
- getOrigin
| void sf::Transformable::setOrigin |
( |
float | x, |
|
|
float | y ) |
|
inherited |
set the local origin of the object
The origin of an object defines the center point for all transformations (position, scale, rotation). The coordinates of this point must be relative to the top-left corner of the object, and ignore all transformations (position, scale, rotation). The default origin of a transformable object is (0, 0).
- Parameters
-
| x | X coordinate of the new origin |
| y | Y coordinate of the new origin |
- See also
- getOrigin
| void sf::Shape::setTexture |
( |
const Texture * | texture, |
|
|
bool | resetRect = false ) |
Change the source texture of the shape.
The texture argument refers to a texture that must exist as long as the shape uses it. Indeed, the shape doesn't store its own copy of the texture, but rather keeps a pointer to the one that you passed to this function. If the source texture is destroyed and the shape tries to use it, the behavior is undefined. texture can be NULL to disable texturing. If resetRect is true, the TextureRect property of the shape is automatically adjusted to the size of the new texture. If it is false, the texture rect is left unchanged.
- Parameters
-
| texture | New texture |
| resetRect | Should the texture rect be reset to the size of the new texture? |
- See also
- getTexture, setTextureRect