SFML には基本的な図形を表すクラスがたくさんあります。
図形ごとに別々のクラスなのですが、同じ親クラスを継承している子たちです。
なので、共通している機能がたくさんあります。
共通している機能のほかに、それぞれの図形ごとに特有の機能がある、という感じです。
たとえば「円形クラス」には「半径」があるとか、
「矩形クラス」には「サイズ」があるとか、
「多角形クラス」には「辺の数」がある、などなど。
				
			
			sf::CircleShape shape(50); // 緑に設定 shape.setFillColor (sf::Color (100, 250, 50) );
 
			
				sf::CircleShape shape (50); shape.setFillColor (sf::Color (150, 50, 250) ); // 10ピクセルでオレンジ色の縁取りにする shape.setOutlineThickness (10); shape.setOutlineColor (sf::Color (250, 150, 100));

sf::CircleShape shape (50); // サイズ 100x100 のテクスチャを 図形に貼り付ける。 shape.setTexture (&texture); // texture の型は sf::Texture shape.setTextureRect (sf::IntRect(10, 10, 100, 100));

window.draw (shape);
// サイズ 120x50 の矩形を作成 sf::RectangleShape rectangle (sf::Vector2f(120, 50) ); // サイズを 100x100 に変更 rectangle.setSize (sf::Vector2f(100, 100) );
 
			
				
				
				
				// 半径 200 の円を作成 sf::CircleShape circle (200); // 半径を 40 に変更 circle.setRadius (40); // 辺の数を 100 に設定 circle.setPointCount (100);
 
			
				
				
				
				// 三角形 sf::CircleShape triangle (80, 3); // 正方形 sf::CircleShape square (80, 4); // 正八角形 sf::CircleShape octagon (80, 8);
 
			
				
				
				// 空の図形を用意して、 sf::ConvexShape convex; // 頂点を5つに設定 convex.setPointCount (5); // それぞれの頂点を設定 convex.setPoint (0, sf::Vector2f(0, 0) ); convex.setPoint (1, sf::Vector2f(150, 10) ); convex.setPoint (2, sf::Vector2f(120, 90) ); convex.setPoint (3, sf::Vector2f(30, 100) ); convex.setPoint (4, sf::Vector2f(0, 50) );

sf::RectangleShape line (sf::Vector2f(150, 5) ); line.rotate (45);
 幅のないライン:
			
				
				
				幅のないライン:
sf::Vertex line[] =
{
    sf::Vertex (sf::Vector2f(10, 10) ),
    sf::Vertex (sf::Vector2f(150, 150) )
};
window.draw (line, 2, sf::Lines);
			
				
class EllipseShape : public sf::Shape
{
public :
    explicit EllipseShape(const sf::Vector2f& radius = sf::Vector2f(0, 0)) :
    m_radius(radius)
    {
        update();
    }
    void setRadius(const sf::Vector2f& radius)
    {
        m_radius = radius;
        update();
    }
    const sf::Vector2f& getRadius() const
    {
        return m_radius;
    }
    virtual std::size_t getPointCount() const
    {
        // ここでは値を固定してますが、必要ならクラスの属性にしてもよいですね。
        return 30;
    }
    virtual sf::Vector2f getPoint(std::size_t index) const
    {
        static const float pi = 3.141592654f;
        float angle = index * 2 * pi / getPointCount() - pi / 2;
        float x = std::cos(angle) * m_radius.x;
        float y = std::sin(angle) * m_radius.y;
        return sf::Vector2f(m_radius.x + x, m_radius.y + y);
    }
private :
    sf::Vector2f m_radius;
};
			
			
				 
			
				
				
			
sf::ContextSettings settings;
settings.antialiasingLevel = 8;
sf::RenderWindow window (
    sf::VideoMode(800, 600), 
    "SFML shapes", 
    sf::Style::Default, 
    settings
);
				
					