Draw a Shape Circle in Sfml

Specialized shape representing a circle. More than...

#include <CircleShape.hpp>

sf::Shape sf::Drawable sf::Transformable

Public Member Functions

CircleShape (float radius=0, std::size_t pointCount=thirty)
Default constructor. More...
void setRadius (float radius)
Set the radius of the circle. More...
float getRadius () const
Get the radius of the circle. More than...
void setPointCount (std::size_t count)
Gear up the number of points of the circle. More...
virtual std::size_t getPointCount () const
Get the number of points of the circle. More than...
virtual Vector2f getPoint (std::size_t index) const
Get a signal 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 than...
void setFillColor (const Color &color)
Set the fill color of the shape. More...
void setOutlineColor (const Colour &colour)
Set the outline colour of the shape. More than...
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
Go the sub-rectangle of the texture displayed by the shape. More...
const Color & getFillColor () const
Go the fill up color of the shape. More...
const Colour & getOutlineColor () const
Get the outline color of the shape. More...
float getOutlineThickness () const
Get the outline thickness of the shape. More...
FloatRect getLocalBounds () const
Go the local bounding rectangle of the entity. More...
FloatRect getGlobalBounds () const
Get the global (not-minimal) bounding rectangle of the entity. More...
void setPosition (float 10, float y)
set the position of the object More than...
void setPosition (const Vector2f &position)
set up the position of the object More...
void setRotation (bladder angle)
ready 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 than...
void setOrigin (float 10, bladder 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
go the orientation of the object More...
const Vector2f & getScale () const
go the current calibration of the object More...
const Vector2f & getOrigin () const
get the local origin of the object More...
void motion (float offsetX, bladder offsetY)
Move the object by a given offset. More than...
void move (const Vector2f &first)
Move the object by a given offset. More...
void rotate (bladder angle)
Rotate the object. More...
void scale (float factorX, float factorY)
Scale the object. More...
void scale (const Vector2f &factor)
Scale the object. More than...
const Transform & getTransform () const
go the combined transform of the object More...
const Transform & getInverseTransform () const
become the inverse of the combined transform of the object More than...

Protected Member Functions

void update ()
Recompute the internal geometry of the shape. More than...

Specialized shape representing a circle.

This course 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 carte tin't draw perfect circles, we have to fake them with multiple triangles continued 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 likewise exist used for some other purpose; with small numbers y'all tin 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.

CircleShape()

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

Default constructor.

Parameters
radius Radius of the circle
pointCount Number of points composing the circle

getFillColor()

const Colour& sf::Shape::getFillColor ( ) const
inherited

Go the fill colour of the shape.

Returns
Fill color of the shape
Run across also
setFillColor

getGlobalBounds()

FloatRect sf::Shape::getGlobalBounds ( ) const
inherited

Get the global (not-minimal) bounding rectangle of the entity.

The returned rectangle is in global coordinates, which ways that information technology takes into account the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the premises 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 perhaps more). This allows for a fast approximation of the bounds as a start cheque; yous may want to utilize more precise checks on top of that.

Returns
Global bounding rectangle of the entity

getInverseTransform()

const Transform& sf::Transformable::getInverseTransform ( ) const
inherited

get the inverse of the combined transform of the object

Returns
Inverse of the combined transformations applied to the object
See also
getTransform

getLocalBounds()

FloatRect sf::Shape::getLocalBounds ( ) const
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 practical to the entity. In other words, this function returns the bounds of the entity in the entity's coordinate organization.

Returns
Local bounding rectangle of the entity

getOrigin()

const Vector2f& sf::Transformable::getOrigin ( ) const
inherited

get the local origin of the object

Returns
Electric current origin
Run into besides
setOrigin

getOutlineColor()

const Colour& sf::Shape::getOutlineColor ( ) const
inherited

Get the outline color of the shape.

Returns
Outline color of the shape
Encounter also
setOutlineColor

getOutlineThickness()

bladder sf::Shape::getOutlineThickness ( ) const
inherited

Become the outline thickness of the shape.

Returns
Outline thickness of the shape
Encounter also
setOutlineThickness

getPoint()

virtual Vector2f sf::CircleShape::getPoint ( std::size_t index ) const
virtual

Get a point of the circumvolve.

The returned point is in local coordinates, that is, the shape's transforms (position, rotation, calibration) are non taken into account. The result is undefined if alphabetize is out of the valid range.

Parameters
Returns
index-th point of the shape

Implements sf::Shape.

getPointCount()

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

Go the number of points of the circle.

Returns
Number of points of the circle
Run into also
setPointCount

Implements sf::Shape.

getPosition()

const Vector2f& sf::Transformable::getPosition ( ) const
inherited

get the position of the object

Returns
Current position
Encounter also
setPosition

getRadius()

float sf::CircleShape::getRadius ( ) const

Get the radius of the circle.

Returns
Radius of the circle
See also
setRadius

getRotation()

float sf::Transformable::getRotation ( ) const
inherited

get the orientation of the object

The rotation is always in the range [0, 360].

Returns
Current rotation, in degrees
Meet also
setRotation

getScale()

const Vector2f& sf::Transformable::getScale ( ) const
inherited

get the electric current scale of the object

Returns
Current scale factors
See also
setScale

getTexture()

const Texture* sf::Shape::getTexture ( ) const
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 ways that you can't modify the texture when you retrieve it with this function.

Returns
Pointer to the shape'south texture
See also
setTexture

getTextureRect()

const IntRect& sf::Shape::getTextureRect ( ) const
inherited

Go the sub-rectangle of the texture displayed by the shape.

Returns
Texture rectangle of the shape
Run across also
setTextureRect

getTransform()

const Transform& sf::Transformable::getTransform ( ) const
inherited

go the combined transform of the object

Returns
Transform combining the position/rotation/calibration/origin of the object
See likewise
getInverseTransform

move() [1/ii]

void sf::Transformable::move ( bladder offsetX,
float offsetY
)
inherited

Move the object past a given get-go.

This function adds to the current position of the object, dissimilar setPosition which overwrites it. Thus, it is equivalent to the post-obit code:

object.setPosition(pos.x + offsetX, pos.y + offsetY);

Parameters
offsetX Ten beginning
offsetY Y start
See also
setPosition

move() [2/2]

void sf::Transformable::move ( const Vector2f & get-go )
inherited

Move the object by a given start.

This function adds to the electric current position of the object, dissimilar setPosition which overwrites information technology. Thus, it is equivalent to the following code:

Parameters
Come across likewise
setPosition

rotate()

void sf::Transformable::rotate ( float angle )
inherited

Rotate the object.

This function adds to the electric current rotation of the object, unlike setRotation which overwrites information technology. Thus, it is equivalent to the following code:

Parameters
bending Angle of rotation, in degrees

scale() [1/2]

void sf::Transformable::calibration ( float factorX,
float mill
)
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:

object.setScale(calibration.ten * factorX, scale.y * factory);

Parameters
factorX Horizontal calibration factor
mill Vertical scale factor
Run into also
setScale

scale() [ii/2]

void sf::Transformable::scale ( const Vector2f & factor )
inherited

Scale the object.

This role multiplies the current scale of the object, unlike setScale which overwrites it. Thus, it is equivalent to the following code:

object.setScale(calibration.x * cistron.x, calibration.y * factor.y);

Parameters
See as well
setScale

setFillColor()

void sf::Shape::setFillColor ( const Color & color )
inherited

Set the fill up colour of the shape.

This color is modulated (multiplied) with the shape'south texture if whatsoever. It can be used to colorize the shape, or change its global opacity. You tin employ sf::Colour::Transparent to brand the within of the shape transparent, and have the outline solitary. By default, the shape's fill color is opaque white.

Parameters
color New colour of the shape
See also
getFillColor, setOutlineColor

setOrigin() [1/ii]

void sf::Transformable::setOrigin ( float x,
float y
)
inherited

set the local origin of the object

The origin of an object defines the heart point for all transformations (position, scale, rotation). The coordinates of this signal must be relative to the peak-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

setOrigin() [two/2]

void sf::Transformable::setOrigin ( const Vector2f & origin )
inherited

set up 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 besides
getOrigin

setOutlineColor()

void sf::Shape::setOutlineColor ( const Color & color )
inherited

Set the outline color of the shape.

Past default, the shape's outline color is opaque white.

Parameters
color New outline colour of the shape
Run across also
getOutlineColor, setFillColor

setOutlineThickness()

void sf::Shape::setOutlineThickness ( float thickness )
inherited

Set the thickness of the shape's outline.

Note that negative values are allowed (and so that the outline expands towards the eye of the shape), and using nix disables the outline. By default, the outline thickness is 0.

Parameters
thickness New outline thickness
Come across as well
getOutlineThickness

setPointCount()

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

Set the number of points of the circle.

Parameters
count New number of points of the circle
Encounter as well
getPointCount

setPosition() [one/2]

void sf::Transformable::setPosition ( float x,
bladder y
)
inherited

set the position of the object

This role completely overwrites the previous position. See the motion function to apply an starting time based on the previous position instead. The default position of a transformable object is (0, 0).

Parameters
10 Ten coordinate of the new position
y Y coordinate of the new position
See too
movement, getPosition

setPosition() [two/ii]

void sf::Transformable::setPosition ( const Vector2f & position )
inherited

set up the position of the object

This function completely overwrites the previous position. See the motion function to apply an start based on the previous position instead. The default position of a transformable object is (0, 0).

Parameters
See also
motion, getPosition

setRadius()

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

Set up the radius of the circle.

Parameters
radius New radius of the circle
Run across as well
getRadius

setRotation()

void sf::Transformable::setRotation ( float angle )
inherited

set the orientation of the object

This role completely overwrites the previous rotation. See the rotate function to add an bending based on the previous rotation instead. The default rotation of a transformable object is 0.

Parameters
angle New rotation, in degrees
Come across also
rotate, getRotation

setScale() [1/2]

void sf::Transformable::setScale ( bladder factorX,
float manufacturing plant
)
inherited

set the scale factors of the object

This function completely overwrites the previous scale. Come across the scale role to add a factor based on the previous scale instead. The default scale of a transformable object is (1, 1).

Parameters
factorX New horizontal scale factor
mill New vertical scale factor
See also
scale, getScale

setScale() [2/2]

void sf::Transformable::setScale ( const Vector2f & factors )
inherited

set up 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 (one, 1).

Parameters
See besides
scale, getScale

setTexture()

void sf::Shape::setTexture ( const Texture * texture,
bool resetRect = false
)
inherited

Change the source texture of the shape.

The texture argument refers to a texture that must exist as long equally the shape uses it. Indeed, the shape doesn't store its own copy of the texture, but rather keeps a arrow to the i that yous passed to this role. If the source texture is destroyed and the shape tries to employ it, the behavior is undefined. texture tin exist 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?
Meet also
getTexture, setTextureRect

setTextureRect()

void sf::Shape::setTextureRect ( const IntRect & rect )
inherited

Prepare the sub-rectangle of the texture that the shape will brandish.

The texture rect is useful when yous don't want to brandish the whole texture, but rather a role of it. By default, the texture rect covers the entire texture.

Parameters
rect Rectangle defining the region of the texture to display
See also
getTextureRect, setTexture

update()

void sf::Shape::update ( )
protected inherited

Recompute the internal geometry of the shape.

This function must be chosen by the derived course everytime the shape's points change (i.e. the result of either getPointCount or getPoint is dissimilar).


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

  • CircleShape.hpp

jonesandla1992.blogspot.com

Source: https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1CircleShape.php

0 Response to "Draw a Shape Circle in Sfml"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel