-
Notifications
You must be signed in to change notification settings - Fork 1
/
drawing.h
73 lines (62 loc) · 2.07 KB
/
drawing.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* stair-step-detector
* Copyright (c) 2021 Peter Nebe (mail@peter-nebe.dev)
*
* This file is part of stair-step-detector.
*
* stair-step-detector is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* stair-step-detector is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with stair-step-detector. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef DRAWING_H_
#define DRAWING_H_
#include "types.h"
#include <cstdint>
namespace stairs
{
struct Rgb
{
uint8_t r, g, b;
};
const Rgb red{ 0xff, 0, 0 };
const Rgb green{ 0, 0xff, 0 };
const Rgb blue{ 0, 0, 0xff };
const Rgb white{ 0xff, 0xff, 0xff };
void setColor(Rgb color);
void drawRectangle(int x, int y, int w, int h);
void drawQuadrilateral(const int corners[4][2]);
void drawDot(int x, int y);
void drawCross(int x, int y);
void drawText(int x, int y, const char *text);
void setDrawOffset(int x, int y);
void resetDrawOffset();
void drawSubframeRect(const Rect2i &rect, Rgb color);
void drawMarker(const Point2 ¢er, const Contour_t &contour);
void drawMarker(const Point2 ¢er, const Point3f &coordinates);
void drawPoints(const Points2i_t &points);
void drawLineStrip(const Points2i_t &points);
void drawPolygon(const Points2i_t &points);
void drawRectangle(const Rect2i &rect);
void drawOctagon(const Point2f ¢er, float radius);
void drawQuadrilateral(const Quadrilateralf_t &corners, const Quadrilateral_t &labeling, Coordinate_t zLabel);
template<typename T>
inline int toInt(T a)
{
return static_cast<int>(a);
}
template<typename PointType>
void drawCross(const PointType &pos)
{
drawCross(toInt(pos.x), toInt(pos.y));
}
} /* namespace stairs */
#endif /* DRAWING_H_ */