Specialized shape representing a circle. More...
#include <CircleShape.hpp>
Public Member Functions | |
CircleShape (float radius=0, unsigned int pointCount=30) | |
Default constructor. More... | |
void | setRadius (float radius) |
Set the radius of the circle. More... | |
float | getRadius () const |
Get the radius of the circle. More... | |
void | setPointCount (unsigned int count) |
Set the number of points of the circle. More... | |
virtual unsigned int | getPointCount () const |
Get the number of points of the circle. More... | |
virtual Vector2f | getPoint (unsigned int index) const |
Get a point of the circle. More... | |
void | setTexture (const Texture *texture, bool resetRect=false) |
Change the source texture of the shape. More... | |
void | setTextureRect (const IntRect &rect) |
Set the sub-rectangle of the texture that the shape will display. More... | |
void | setFillColor (const Color &color) |
Set the fill color of the shape. More... | |
void | setOutlineColor (const Color &color) |
Set the outline color of the shape. More... | |
void | setOutlineThickness (float thickness) |
Set the thickness of the shape's outline. More... | |
const Texture * | getTexture () const |
Get the source texture of the shape. More... | |
const IntRect & | getTextureRect () const |
Get the sub-rectangle of the texture displayed by the shape. More... | |
const Color & | getFillColor () const |
Get the fill color of the shape. More... | |
const Color & | getOutlineColor () const |
Get the outline color of the shape. More... | |
float | getOutlineThickness () const |
Get the outline thickness of the shape. More... | |
FloatRect | getLocalBounds () const |
Get the local bounding rectangle of the entity. More... | |
FloatRect | getGlobalBounds () const |
Get the global bounding rectangle of the entity. More... | |
void | setPosition (float x, float y) |
set the position of the object More... | |
void | setPosition (const Vector2f &position) |
set the position of the object More... | |
void | setRotation (float angle) |
set the orientation of the object More... | |
void | setScale (float factorX, float factorY) |
set the scale factors of the object More... | |
void | setScale (const Vector2f &factors) |
set the scale factors of the object More... | |
void | setOrigin (float x, float y) |
set the local origin of the object More... | |
void | setOrigin (const Vector2f &origin) |
set the local origin of the object More... | |
const Vector2f & | getPosition () const |
get the position of the object More... | |
float | getRotation () const |
get the orientation of the object More... | |
const Vector2f & | getScale () const |
get the current scale of the object More... | |
const Vector2f & | getOrigin () const |
get the local origin of the object More... | |
void | move (float offsetX, float offsetY) |
Move the object by a given offset. More... | |
void | move (const Vector2f &offset) |
Move the object by a given offset. More... | |
void | rotate (float angle) |
Rotate the object. More... | |
void | scale (float factorX, float factorY) |
Scale the object. More... | |
void | scale (const Vector2f &factor) |
Scale the object. More... | |
const Transform & | getTransform () const |
get the combined transform of the object More... | |
const Transform & | getInverseTransform () const |
get the inverse of the combined transform of the object More... | |
Protected Member Functions | |
void | update () |
Recompute the internal geometry of the shape. More... | |
Specialized shape representing a circle.
This class inherits all the functions of sf::Transformable (position, rotation, scale, bounds, ...) as well as the functions of sf::Shape (outline, color, texture, ...).
Usage example:
Since the graphics card can't draw perfect circles, we have to fake them with multiple triangles connected to each other. The "points count" property of sf::CircleShape defines how many of these triangles to use, and therefore defines the quality of the circle.
The number of points can also be used for another purpose; with small numbers you can create any regular polygon shape: equilateral triangle, square, pentagon, hexagon, ...
Definition at line 41 of file CircleShape.hpp.
|
explicit |
Default constructor.
radius | Radius of the circle |
pointCount | Number of points composing the circle |
|
inherited |
|
inherited |
Get the global bounding rectangle of the entity.
The returned rectangle is in global coordinates, which means that it takes in account the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the bounds of the sprite in the global 2D world's coordinate system.
|
inherited |
get the inverse of the combined transform of the object
|
inherited |
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.
|
inherited |
|
inherited |
|
inherited |
Get the outline thickness of the shape.
|
virtual |
Get a point of the circle.
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.
|
virtual |
Get the number of points of the circle.
Implements sf::Shape.
|
inherited |
float sf::CircleShape::getRadius | ( | ) | const |
|
inherited |
get the orientation of the object
The rotation is always in the range [0, 360].
|
inherited |
|
inherited |
Get the source texture of the shape.
If the shape has no source texture, a NULL pointer is returned. The returned pointer is const, which means that you can't modify the texture when you retrieve it with this function.
|
inherited |
Get the sub-rectangle of the texture displayed by the shape.
|
inherited |
get the combined transform of the object
|
inherited |
Move the object by a given offset.
This function adds to the current position of the object, unlike setPosition which overwrites it. Thus, it is equivalent to the following code:
offsetX | X offset |
offsetY | Y offset |
|
inherited |
Move the object by a given offset.
This function adds to the current position of the object, unlike setPosition which overwrites it. Thus, it is equivalent to the following code:
offset | Offset |
|
inherited |
Rotate the object.
This function adds to the current rotation of the object, unlike setRotation which overwrites it. Thus, it is equivalent to the following code:
angle | Angle of rotation, in degrees |
|
inherited |
Scale the object.
This function multiplies the current scale of the object, unlike setScale which overwrites it. Thus, it is equivalent to the following code:
factorX | Horizontal scale factor |
factorY | Vertical scale factor |
|
inherited |
Scale the object.
This function multiplies the current scale of the object, unlike setScale which overwrites it. Thus, it is equivalent to the following code:
factor | Scale factors |
|
inherited |
Set the fill color of the shape.
This color is modulated (multiplied) with the shape's texture if any. It can be used to colorize the shape, or change its global opacity. You can use sf::Color::Transparent to make the inside of the shape transparent, and have the outline alone. By default, the shape's fill color is opaque white.
color | New color of the shape |
|
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).
x | X coordinate of the new origin |
y | Y coordinate of the new 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).
origin | New origin |
|
inherited |
Set the outline color of the shape.
By default, the shape's outline color is opaque white.
color | New outline color of the shape |
|
inherited |
Set the thickness of the shape's outline.
Note that negative values are allowed (so that the outline expands towards the center of the shape), and using zero disables the outline. By default, the outline thickness is 0.
thickness | New outline thickness |
void sf::CircleShape::setPointCount | ( | unsigned int | count | ) |
Set the number of points of the circle.
count | New number of points of the circle |
|
inherited |
set the position of the object
This function completely overwrites the previous position. See the move function to apply an offset based on the previous position instead. The default position of a transformable object is (0, 0).
x | X coordinate of the new position |
y | Y coordinate of the new position |
|
inherited |
set the position of the object
This function completely overwrites the previous position. See the move function to apply an offset based on the previous position instead. The default position of a transformable object is (0, 0).
position | New position |
void sf::CircleShape::setRadius | ( | float | radius | ) |
|
inherited |
set the orientation of the object
This function completely overwrites the previous rotation. See the rotate function to add an angle based on the previous rotation instead. The default rotation of a transformable object is 0.
angle | New rotation, in degrees |
|
inherited |
set the scale factors of the object
This function completely overwrites the previous scale. See the scale function to add a factor based on the previous scale instead. The default scale of a transformable object is (1, 1).
factorX | New horizontal scale factor |
factorY | New vertical scale factor |
|
inherited |
|
inherited |
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.
texture | New texture |
resetRect | Should the texture rect be reset to the size of the new texture? |
|
inherited |
Set the sub-rectangle of the texture that the shape will display.
The texture rect is useful when you don't want to display the whole texture, but rather a part of it. By default, the texture rect covers the entire texture.
rect | Rectangle defining the region of the texture to display |
|
protectedinherited |
Recompute the internal geometry of the shape.
This function must be called by the derived class everytime the shape's points change (i.e. the result of either getPointCount or getPoint is different).