JNGL
shapes.hpp
Go to the documentation of this file.
1 // Copyright 2012-2022 Jan Niklas Hasse <[email protected]>
2 // For conditions of distribution and use, see copyright notice in LICENSE.txt
5 #pragma once
6 
7 #include "Color.hpp"
8 #include "Vec2.hpp"
9 
10 namespace jngl {
11 
12 class Mat3;
13 
18 
19 void setColor(jngl::Color, unsigned char alpha);
20 
21 void setColor(unsigned char red, unsigned char green, unsigned char blue);
22 
23 void setColor(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha);
24 
27 void setAlpha(uint8_t alpha);
28 
29 void pushAlpha(unsigned char alpha);
30 
31 void popAlpha();
32 
33 void setLineWidth(float width);
34 
35 void drawLine(Vec2 start, Vec2 end);
36 
37 void drawLine(double xstart, double ystart, double xend, double yend);
38 
40 void drawLine(const Mat3& modelview, Vec2 end);
41 
42 void drawEllipse(float xmid, float ymid, float width, float height, float startAngle = 0);
43 
44 void drawEllipse(Vec2, float width, float height, float startAngle = 0);
45 
46 void drawEllipse(Mat3 modelview, float width, float height, float startAngle = 0);
47 
49 void drawCircle(Vec2, float radius, float startAngle = 0);
50 
51 void drawCircle(Mat3 modelview, float radius, float startAngle = 0);
52 
53 void drawPoint(double x, double y);
54 
55 void drawTriangle(Vec2 a, Vec2 b, Vec2 c);
56 
57 void drawTriangle(double A_x, double A_y, double B_x, double B_y, double C_x, double C_y);
58 
59 void drawRect(double xposition, double yposition, double width, double height);
60 
64 void drawRect(Vec2 position, Vec2 size);
65 
66 template <class Vect> void drawRect(Vect pos, Vect size) {
67  drawRect(pos.x, pos.y, size.x, size.y);
68 }
69 
70 } // namespace jngl
Contains jngl::Color class.
Contains jngl::Vec2 class.
Object representing a RGB color.
Definition: Color.hpp:25
3x3 matrix
Definition: Mat3.hpp:20
Two-dimensional vector.
Definition: Vec2.hpp:35
JNGL's main namespace.
Definition: App.hpp:10
void drawLine(const Mat3 &modelview, Vec2 end)
Draws a line from (0, 0) to end.
void setColor(jngl::Color rgb)
Sets the color which should be used to draw primitives.
jngl::Mat3 modelview()
Returns a copy of the global ModelView matrix.
void setAlpha(uint8_t alpha)
Sets the alpha value which should be used to draw primitives (0 = fully transparent,...
void drawCircle(Vec2, float radius, float startAngle=0)
Angles in radian.