Project

General

Profile

Statistics
| Revision:

root / proj / libs / graph / include / rectangle.h @ 368

History | View | Annotate | Download (3.08 KB)

1 178 up20180642
#ifndef RECTANGLE_H_INCLUDED
2
#define RECTANGLE_H_INCLUDED
3
4 333 up20180642
/**
5
 * @defgroup    rectangle_t rectangle_t
6
 * @ingroup graph
7
 * @brief   Rectangle module.
8
 *
9
 * @{
10
 */
11
12 334 up20180642
/**
13
 * @brief Rectangle.
14
 */
15 178 up20180642
typedef struct rectangle rectangle_t;
16 334 up20180642
/**
17
 * @brief Construct rectangle.
18
 * @param   x   X-position of upper-left corner
19
 * @param   y   Y-position of upper-left corner
20
 * @param   w   Width
21
 * @param   h   Height
22
 * @return      Pointer to constructed rectangle, or NULL if failed
23
 */
24 178 up20180642
rectangle_t* (rectangle_ctor)(int16_t x, int16_t y, uint16_t w, uint16_t h);
25 334 up20180642
/**
26
 * @brief Destruct rectangle.
27
 * @param   p   Pointer to rectangle to be destructed
28
 */
29 178 up20180642
void         (rectangle_dtor)(rectangle_t *p);
30 334 up20180642
/**
31
 * @brief Set rectangle position.
32
 * @param   p   Pointer to rectangle
33
 * @param   x   X-position of the upper-left corner
34
 * @param   y   Y-position of the upper-left corner
35
 */
36 179 up20180642
void (rectangle_set_pos)          (rectangle_t *p,  int16_t x,  int16_t y);
37 334 up20180642
/**
38
 * @brief Set rectangle size.
39
 * @param   p   Pointer to rectangle
40
 * @param   w   Width
41
 * @param   h   Height
42
 */
43 179 up20180642
void (rectangle_set_size)         (rectangle_t *p, uint16_t w, uint16_t h);
44 334 up20180642
/**
45
 * @brief Set rectangle fill color.
46
 * @param   p       Pointer to rectangle
47
 * @param   color   Color to fill rectangle
48
 */
49 179 up20180642
void (rectangle_set_fill_color)   (rectangle_t *p, uint32_t color);
50 334 up20180642
/**
51
 * @brief Set rectangle fill transparency.
52
 * @param   p       Pointer to rectangle
53
 * @param   alpha   Value of the alpha-channel
54
 */
55 286 up20180642
void (rectangle_set_fill_trans)   (rectangle_t *p, uint8_t  alpha);
56 334 up20180642
/**
57
 * @brief Set rectangle outline color.
58
 * @param   p       Pointer to rectangle
59
 * @param   color   Color to outline rectangle
60
 */
61 179 up20180642
void (rectangle_set_outline_color)(rectangle_t *p, uint32_t color);
62 334 up20180642
/**
63
 * @brief Set rectangle outline width.
64
 * @param   p       Pointer to rectangle
65
 * @param   width   Width of the rectangle border/outline
66
 */
67 179 up20180642
void (rectangle_set_outline_width)(rectangle_t *p,  int16_t width);
68 334 up20180642
/**
69
 * @brief Get rectangle x-position.
70
 * @param   p   Pointer to rectangle
71
 * @return      Rectangle x-position
72
 */
73 179 up20180642
int16_t  (rectangle_get_x)(const rectangle_t *p);
74 334 up20180642
/**
75
 * @brief Get rectangle y-position.
76
 * @param   p   Pointer to rectangle
77
 * @return      Rectangle y-position
78
 */
79 179 up20180642
int16_t  (rectangle_get_y)(const rectangle_t *p);
80 334 up20180642
/**
81
 * @brief Get rectangle width.
82
 * @param   p   Pointer to rectangle
83
 * @return      Rectangle width
84
 */
85 179 up20180642
uint16_t (rectangle_get_w)(const rectangle_t *p);
86 334 up20180642
/**
87
 * @brief Get rectangle height.
88
 * @param   p   Pointer to rectangle
89
 * @return      Rectangle height
90
 */
91 179 up20180642
uint16_t (rectangle_get_h)(const rectangle_t *p);
92 334 up20180642
/**
93
 * @brief Know if point in screen coordinates lies inside rectangle.
94
 * @param   p   Pointer to rectangle
95
 * @param   x   X-position of the point
96
 * @param   y   Y-position of the point
97
 * @return      True if the point lies inside the rectangle, false otherwise.
98
 */
99 251 up20180655
int      (rectangle_collide_point)(const rectangle_t *p, int x, int y);
100 334 up20180642
/**
101
 * Draw rectangle in screen buffer.
102
 * @param   p   Pointer to rectangle to be drawn
103
 */
104 179 up20180642
void (rectangle_draw)(const rectangle_t *p);
105
106 333 up20180642
/**
107
 * @}
108
 */
109
110 178 up20180642
#endif //RECTANGLE_H_INCLUDED