Shape.hpp
1// Copyright 2019 Arthur Sonzogni. All rights reserved.
2// Use of this source code is governed by the MIT license that can be found in
3// the LICENSE file.
4
5#ifndef SMK_SHAPE_HPP
6#define SMK_SHAPE_HPP
7
8#include <glm/glm.hpp>
9#include <smk/Transformable.hpp>
10#include <smk/VertexArray.hpp>
11
12/// @example shape_2d.cpp
13/// @example shape_3d.cpp
14/// @example bezier.cpp
15/// @example rounded_rectangle.cpp
16
17namespace smk {
18
19/// A collection of static function to build simple shape.
20class Shape {
21 public:
22 static Transformable FromVertexArray(VertexArray vertex_array);
23 static Transformable Line(const glm::vec2& a,
24 const glm::vec2& b,
25 float thickness);
26 static Transformable Square();
27 static Transformable Circle(float radius);
28 static Transformable Circle(float radius, int subdivisions);
29 static Transformable Path(const std::vector<glm::vec2>& points,
30 float thickness);
31 static Transformable RoundedRectangle(float width,
32 float height,
33 float radius);
34 static Transformable3D Cube();
35 static Transformable3D IcoSphere(int iteration);
36 static Transformable3D Plane();
37 static std::vector<glm::vec2> Bezier(const std::vector<glm::vec2>& point,
38 size_t subdivision);
39};
40
41} // namespace smk
42
43#endif /* end of include guard: SMK_SHAPE_HPP */
A collection of static function to build simple shape.
Definition: Shape.hpp:20
static Transformable RoundedRectangle(float width, float height, float radius)
Return a rounded centered rectangle. @params width The width of the rectangle. @params height The hei...
Definition: Shape.cpp:309
static Transformable Line(const glm::vec2 &a, const glm::vec2 &b, float thickness)
Return a line with a given thickness.
Definition: Shape.cpp:25
static Transformable3D Cube()
Return a centered 1x1x1 3D cube.
Definition: Shape.cpp:89
static Transformable Path(const std::vector< glm::vec2 > &points, float thickness)
Build a path of a given |thickness| along a sequence of connected lines. @params points The sequence ...
Definition: Shape.cpp:215
static Transformable Circle(float radius)
Return a circle.
Definition: Shape.cpp:61
static Transformable3D IcoSphere(int iteration)
A centered sphere.
Definition: Shape.cpp:130
static Transformable Square()
Return the square [0,1]x[0,1].
Definition: Shape.cpp:42
static std::vector< glm::vec2 > Bezier(const std::vector< glm::vec2 > &point, size_t subdivision)
Return a bezier curve.
Definition: Shape.cpp:193
static Transformable3D Plane()
Return a centered 1x1 square in a 3D space.
Definition: Shape.cpp:167
An array of smk::Vertex moved to the GPU memory. This represent a set of triangles to be drawn by the...
Definition: VertexArray.hpp:20