JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
shapes.hpp
Go to the documentation of this file.
1// Copyright 2012-2024 Jan Niklas Hasse <jhasse@bixense.com>
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#include <cstdint>
11
12namespace jngl {
13
14class Mat3;
15class Rgba;
16
20void setColor(Rgb rgb);
21
24void setColor(Rgb, unsigned char alpha);
25
26void setColor(unsigned char red, unsigned char green, unsigned char blue);
27
28void setColor(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha);
29
32void setAlpha(uint8_t alpha);
33
34[[deprecated("Use setAlpha instead")]]
36void pushAlpha(unsigned char alpha);
37
38[[deprecated("Use setAlpha instead")]]
40void popAlpha();
41
42[[deprecated("Use drawRectangle instead")]]
44void setLineWidth(float width);
45
47void drawLine(Vec2 start, Vec2 end);
48
49[[deprecated("Use drawLine(Vec2, Vec2) instead")]]
51void drawLine(double xstart, double ystart, double xend, double yend);
52
54void drawLine(const Mat3& modelview, Vec2 end);
55
56
57[[deprecated("Use drawEllipse(Mat3, float, float, float) instead")]]
59void drawEllipse(float xmid, float ymid, float width, float height, float startAngle = 0);
60
61void drawEllipse(Vec2, float width, float height, float startAngle = 0);
62
63void drawEllipse(Mat3 modelview, float width, float height, float startAngle = 0);
64
66void drawCircle(Vec2, float radius, float startAngle = 0);
67
68void drawCircle(Mat3 modelview, float radius, float startAngle);
69
70void drawCircle(Mat3 modelview, float radius);
71
73void drawCircle(Mat3 modelview, float radius, Rgba color);
74
75
76[[deprecated("Use drawCircle instead")]]
78void drawPoint(double x, double y);
79
81void drawTriangle(Vec2 a, Vec2 b, Vec2 c);
82
83[[deprecated("Use drawTriangle(Vec2, Vec2, Vec2) instead")]]
85void drawTriangle(double A_x, double A_y, double B_x, double B_y, double C_x, double C_y);
86
87void drawRect(double xposition, double yposition, double width, double height);
88
92void drawRect(Vec2 position, Vec2 size);
93
97void drawRect(const Mat3& modelview, Vec2 size, Color);
98
102void drawRect(const Mat3& modelview, Vec2 size, Rgba color);
103
104template <class Vect> void drawRect(Vect pos, Vect size) {
105 drawRect(pos.x, pos.y, size.x, size.y);
106}
107
108} // namespace jngl
Contains jngl::Color class.
Contains jngl::Vec2 class.
Object representing a RGB color.
Definition: Color.hpp:28
3x3 matrix
Definition: Mat3.hpp:18
Object representing a RGB color, new version of jngl::Color (which will be deprecated in the future)
Definition: Rgb.hpp:12
Object representing a RGBA color.
Definition: Rgba.hpp:22
Two-dimensional vector.
Definition: Vec2.hpp:32
JNGL's main namespace.
Definition: Achievement.hpp:10
void drawTriangle(Vec2 a, Vec2 b, Vec2 c)
Draws the triangle a -> b -> c.
void setAlpha(uint8_t alpha)
Sets the alpha value which should be used to draw primitives (0 = fully transparent,...
void pushAlpha(unsigned char alpha)
void setColor(Rgb rgb)
Sets the color which should be used to draw primitives.
void drawEllipse(float xmid, float ymid, float width, float height, float startAngle=0)
void drawPoint(double x, double y)
void setLineWidth(float width)
jngl::Mat3 modelview()
Returns a copy of the global ModelView matrix.
void drawCircle(Vec2, float radius, float startAngle=0)
Angles in radian.
void drawLine(Vec2 start, Vec2 end)
Draws a line from start to end, the width can be set using setLineWidth.
void popAlpha()