Smolgui
Immediate gui library based on SFML
Loading...
Searching...
No Matches
Shapes.h
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4#include <vector>
5#include <SFML/System/Vector2.hpp>
6
7namespace sgui
8{
9constexpr float Pi = 3.14159265359f;
10constexpr float PiRad = 3.14159265359f / 180.f;
11
13
16template <typename Type>
17struct Line {
18 Line () = default;
19 Line (const sf::Vector2<Type>& begin, const sf::Vector2<Type>& end);
26};
27
28// typedef for common line type
30
31
33
36template <typename Type>
37struct Circle
38{
39 Circle () = default;
41 Type radius = Type (0);
43};
44
45// typedef for common circle type
47
48
50
53template<typename Type>
54constexpr sf::Vector2f centroid (const std::vector<sf::Vector2 <Type>>& vertices);
55
56} // namespace sgui
57
58// impl
59#include "sgui/Core/Shapes.tpp"
Definition Interpolation.h:11
Definition Interpolation.h:16
constexpr float PiRad
Definition Shapes.h:10
Circle< float > CircleFloat
Definition Shapes.h:46
Line< float > LineFloat
Definition Shapes.h:29
constexpr float Pi
Definition Shapes.h:9
constexpr sf::Vector2f centroid(const Polygon< N > &polygon)
Return center of polygon.
Define a Circle with a center and a radius.
Definition Shapes.h:38
Circle()=default
Circle(const sf::Vector2< Type > &center, Type r)
sf::Vector2< float > center
Definition Shapes.h:42
float radius
Definition Shapes.h:41
Define a line with two points.
Definition Shapes.h:17
Line(const sf::Vector2< Type > &begin, const sf::Vector2< Type > &end)
sf::Vector2< Type > direction() const
get direction of the line
Line()=default
sf::Vector2< float > head
Definition Shapes.h:25
sf::Vector2< float > tail
Definition Shapes.h:24