Functions
thor::Shapes Namespace Reference

Namespace for predefined shapes. More...

Functions

sf::ConvexShape toConvexShape (const sf::Shape &shape)
 Converts a specific shape to a general, convex SFML shape. More...
 
sf::ConvexShape line (sf::Vector2f direction, const sf::Color &color, float thickness=1.f)
 Creates a line shape. More...
 
sf::ConvexShape roundedRect (sf::Vector2f size, float cornerRadius, const sf::Color &fillColor, float outlineThickness=0.f, const sf::Color &outlineColor=sf::Color())
 Creates a rectangle with radiused corners. More...
 
sf::ConvexShape polygon (std::size_t nbPoints, float radius, const sf::Color &fillColor, float outlineThickness=0.f, const sf::Color &outlineColor=sf::Color())
 Creates a regular, convex polygon shape. More...
 
sf::ConvexShape star (std::size_t nbStarPoints, float innerRadius, float outerRadius, const sf::Color &fillColor, float outlineThickness=0.f, const sf::Color &outlineColor=sf::Color())
 Creates a regular star shape. More...
 

Detailed Description

Namespace for predefined shapes.

This namespace contains some functions to create predefined shapes like stars or rounded rectangles. The namespace Shapes can be considered an extension to the specific SFML shape classes like sf::CircleShape or sf::RectangleShape.

Function Documentation

sf::ConvexShape thor::Shapes::line ( sf::Vector2f  direction,
const sf::Color &  color,
float  thickness = 1.f 
)

Creates a line shape.

This is a simple function that returns directly a shape. If you want a more flexible line implementation that can also be changed after creation, look at the thor::Arrow class and its Line style.

Parameters
directionLine direction.
thicknessLine thickness (> 0.f).
colorColor of the line.
Returns
A sf::ConvexShape copy representing the line.
sf::ConvexShape thor::Shapes::polygon ( std::size_t  nbPoints,
float  radius,
const sf::Color &  fillColor,
float  outlineThickness = 0.f,
const sf::Color &  outlineColor = sf::Color() 
)

Creates a regular, convex polygon shape.

Parameters
nbPointsThe number of polygon points (the smallest possible value is 3 for a triangle).
radiusThe distance from the center to the points (> 0.f).
fillColorThe color which is used to fill the inside of the polygon.
outlineThicknessThe thickness of the outline.
outlineColorThe color used for the outline.
Returns
A sf::ConvexShape copy representing the regular polygon.
sf::ConvexShape thor::Shapes::roundedRect ( sf::Vector2f  size,
float  cornerRadius,
const sf::Color &  fillColor,
float  outlineThickness = 0.f,
const sf::Color &  outlineColor = sf::Color() 
)

Creates a rectangle with radiused corners.

Parameters
sizeWidth and height of the rectangle.
cornerRadiusThe radius of the circle at the corners.
fillColorThe rounded rectangle's fill color.
outlineThicknessThe thickness of the outline.
outlineColorColor used for the outline.
Returns
A sf::ConvexShape copy containing the rounded rectangle.
sf::ConvexShape thor::Shapes::star ( std::size_t  nbStarPoints,
float  innerRadius,
float  outerRadius,
const sf::Color &  fillColor,
float  outlineThickness = 0.f,
const sf::Color &  outlineColor = sf::Color() 
)

Creates a regular star shape.

Parameters
nbStarPointsThe number of points (the smallest possible is a 3-pointed star).
innerRadiusThe distance from the center to the inner points (> 0.f).
outerRadiusThe distance from the center to the outer points (> innerRadius).
fillColorThe color which is used to fill the star.
outlineThicknessThe thickness of the outline.
outlineColorThe color used for the outline.
Returns
A convex shape representing the star.
sf::ConvexShape thor::Shapes::toConvexShape ( const sf::Shape &  shape)

Converts a specific shape to a general, convex SFML shape.

Returns
General shape with the same properties (shape attributes, texture, transform) as the parameter. Note that you lose specific information (such as a circle radius) during this conversion.