Smolgui
Immediate gui library based on SFML
Loading...
Searching...
No Matches
Polygon.h
Go to the documentation of this file.
1#pragma once
2
3#include <cmath>
4#include "sgui/Core/Shapes.h"
5
6namespace sgui
7{
9
13template <size_t N>
14struct Polygon {
15 std::array <sf::Vector2f, N> points;
16};
17
18// typedef for common polygon type
19using Tetragon = Polygon <4>;
20using Hexagon = Polygon <6>;
21using Octogon = Polygon <8>;
22
26template <size_t N>
27Polygon<N> makeRegularPolygon (const sf::Vector2f& center, const float size);
28
29
31
34template <size_t N>
35constexpr sf::Vector2f centroid (const Polygon<N>& polygon);
36
40template <size_t N>
41constexpr sf::FloatRect boundingBox (const Polygon<N>& polygon);
42
43} // namespace sgui
44
45
46#include "sgui/Core/Polygon.tpp"
Definition Interpolation.h:16
Polygon< N > makeRegularPolygon(const sf::Vector2f &center, const float size)
make a regular polygon, like hexagon or octogon, around a center
Polygon< 8 > Octogon
Definition Polygon.h:21
constexpr sf::FloatRect boundingBox(const Polygon< N > &polygon)
Return a box that bounds polygon.
Polygon< 4 > Tetragon
Definition Polygon.h:19
Polygon< 6 > Hexagon
Definition Polygon.h:20
constexpr sf::Vector2f centroid(const Polygon< N > &polygon)
Return center of polygon.
Polygon is a series of N points, ranged in clock-wise order and that form a convex shape.
Definition Polygon.h:14
std::array< sf::Vector2f, N > points
Definition Polygon.h:15