Onsens  1.0
This is C++ game about bitwise logic.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
sf::CircleShape Class Reference

Specialized shape representing a circle. More...

#include <CircleShape.hpp>

+ Inheritance diagram for sf::CircleShape:
+ Collaboration diagram for sf::CircleShape:

Public Member Functions

 CircleShape (float radius=0, std::size_t 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 (std::size_t count)
 Set the number of points of the circle. More...
 
virtual std::size_t getPointCount () const
 Get the number of points of the circle. More...
 
virtual Vector2f getPoint (std::size_t index) const
 Get a point of the circle. More...
 
- Public Member Functions inherited from sf::Shape
virtual ~Shape ()
 Virtual destructor. 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 TexturegetTexture () const
 Get the source texture of the shape. More...
 
const IntRectgetTextureRect () const
 Get the sub-rectangle of the texture displayed by the shape. More...
 
const ColorgetFillColor () const
 Get the fill color of the shape. More...
 
const ColorgetOutlineColor () const
 Get the outline color of the shape. More...
 
float getOutlineThickness () const
 Get the outline thickness of the shape. More...
 
virtual std::size_t getPointCount () const =0
 Get the total number of points of the shape. More...
 
virtual Vector2f getPoint (std::size_t index) const =0
 Get a point of the shape. More...
 
FloatRect getLocalBounds () const
 Get the local bounding rectangle of the entity. More...
 
FloatRect getGlobalBounds () const
 Get the global (non-minimal) bounding rectangle of the entity. More...
 
- Public Member Functions inherited from sf::Drawable
virtual ~Drawable ()
 Virtual destructor. More...
 
- Public Member Functions inherited from sf::Transformable
 Transformable ()
 Default constructor. More...
 
virtual ~Transformable ()
 Virtual destructor. 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 Vector2fgetPosition () const
 get the position of the object More...
 
float getRotation () const
 get the orientation of the object More...
 
const Vector2fgetScale () const
 get the current scale of the object More...
 
const Vector2fgetOrigin () 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 TransformgetTransform () const
 get the combined transform of the object More...
 
const TransformgetInverseTransform () const
 get the inverse of the combined transform of the object More...
 

Additional Inherited Members

- Protected Member Functions inherited from sf::Shape
 Shape ()
 Default constructor. More...
 
void update ()
 Recompute the internal geometry of the shape. More...
 
virtual void draw (RenderTarget &target, RenderStates states) const =0
 Draw the object to a render target. More...
 

Detailed Description

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:

circle.setRadius(150);
circle.setPosition(10, 20);
...
window.draw(circle);
Specialized shape representing a circle.
Definition: CircleShape.hpp:42
void setRadius(float radius)
Set the radius of the circle.
static const Color Red
Red predefined color.
Definition: Color.hpp:85
void setOutlineColor(const Color &color)
Set the outline color of the shape.
void setOutlineThickness(float thickness)
Set the thickness of the shape's outline.
void setPosition(float x, float y)
set the position of the object

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, ...

See also
sf::Shape, sf::RectangleShape, sf::ConvexShape

Definition at line 41 of file CircleShape.hpp.

Constructor & Destructor Documentation

◆ CircleShape()

sf::CircleShape::CircleShape ( float  radius = 0,
std::size_t  pointCount = 30 
)
explicit

Default constructor.

Parameters
radiusRadius of the circle
pointCountNumber of points composing the circle

Member Function Documentation

◆ getPoint()

virtual Vector2f sf::CircleShape::getPoint ( std::size_t  index) const
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.

Parameters
indexIndex of the point to get, in range [0 .. getPointCount() - 1]
Returns
index-th point of the shape

Implements sf::Shape.

◆ getPointCount()

virtual std::size_t sf::CircleShape::getPointCount ( ) const
virtual

Get the number of points of the circle.

Returns
Number of points of the circle
See also
setPointCount

Implements sf::Shape.

◆ getRadius()

float sf::CircleShape::getRadius ( ) const

Get the radius of the circle.

Returns
Radius of the circle
See also
setRadius

◆ setPointCount()

void sf::CircleShape::setPointCount ( std::size_t  count)

Set the number of points of the circle.

Parameters
countNew number of points of the circle
See also
getPointCount

◆ setRadius()

void sf::CircleShape::setRadius ( float  radius)

Set the radius of the circle.

Parameters
radiusNew radius of the circle
See also
getRadius

The documentation for this class was generated from the following file: