-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhy352_gui.h
130 lines (102 loc) · 2.32 KB
/
hy352_gui.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#ifndef HY352_GUI_H
#define HY352_GUI_H
#include <string>
using namespace ::std;
// Collor in rgb value
class ColorPalette
{
public:
unsigned red;
unsigned green;
unsigned blue;
};
// Point in canvas/display
class Point
{
public:
unsigned x;
unsigned y;
};
// Abstract class, represent the notion of a graphic element
class Shape
{
public:
unsigned thickness;
ColorPalette color;
bool draw;
virtual string getName() = 0;
};
// Circle with center and radius
class Circle : public Shape
{
public:
Point center;
unsigned radius;
string getName()
{
return "Circle";
};
};
// Line between points start and end
class Line : public Shape
{
public:
Point start;
Point end;
string getName()
{
return "Line";
};
};
// Label in a specific point
class Label : public Shape
{
public:
char *text;
Point point;
string getName()
{
return "Label";
};
};
// Rotate turtle by d degrees relatively to current turtle direction
void turtle_rotate(int d);
// Draw circle with center the current position of the turtle and radius r
void turtle_draw_circle(unsigned r);
// Move the turtle forward
int turtle_mv_forward(float n);
// Move the turtle backward
int turtle_mv_backward(float n);
// Set the color of the pen
int set_pen_color(unsigned r, unsigned g, unsigned b);
// Set the color of the screen
int set_screen_color(unsigned r, unsigned g, unsigned b);
// Set the thickness of the pen
void set_pen_thickness(float thickness);
// Raise up the pen
void pen_up();
// Put down the pen
void pen_down();
// Move the turtle to the target position without drawing
int turtle_go_to_position(unsigned x, unsigned y);
// Move the turtle to the center of the display without drawing
int turtle_go_to_center();
// Turtle writes a label
int turtle_draw_label(char const *text);
// Initialize the GUI (display, init allegro addons etc)
int init_GUI();
// Renders the GUI
void render_GUI();
// Release the memory of GUI elements
void destroy_GUI();
// Show debug message
int show_debug_message(char const *msg);
// Freeze the execution for s seconds
void wait(unsigned s);
// Defines number pi
#define PI 3.14159265
// Converts degrees to radians.
#define degreesToRadians(angleDegrees) (angleDegrees * PI / 180.0)
// Converts radians to degrees.
#define radiansToDegrees(angleRadians) (angleRadians * 180.0 / PI)
#endif