root / proj / libs / graph / include / rectangle.h @ 338
History | View | Annotate | Download (3.08 KB)
1 |
#ifndef RECTANGLE_H_INCLUDED
|
---|---|
2 |
#define RECTANGLE_H_INCLUDED
|
3 |
|
4 |
/**
|
5 |
* @defgroup rectangle_t rectangle_t
|
6 |
* @ingroup graph
|
7 |
* @brief Rectangle module.
|
8 |
*
|
9 |
* @{
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
* @brief Rectangle.
|
14 |
*/
|
15 |
typedef struct rectangle rectangle_t; |
16 |
/**
|
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 |
rectangle_t* (rectangle_ctor)(int16_t x, int16_t y, uint16_t w, uint16_t h); |
25 |
/**
|
26 |
* @brief Destruct rectangle.
|
27 |
* @param p Pointer to rectangle to be destructed
|
28 |
*/
|
29 |
void (rectangle_dtor)(rectangle_t *p);
|
30 |
/**
|
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 |
void (rectangle_set_pos) (rectangle_t *p, int16_t x, int16_t y);
|
37 |
/**
|
38 |
* @brief Set rectangle size.
|
39 |
* @param p Pointer to rectangle
|
40 |
* @param w Width
|
41 |
* @param h Height
|
42 |
*/
|
43 |
void (rectangle_set_size) (rectangle_t *p, uint16_t w, uint16_t h);
|
44 |
/**
|
45 |
* @brief Set rectangle fill color.
|
46 |
* @param p Pointer to rectangle
|
47 |
* @param color Color to fill rectangle
|
48 |
*/
|
49 |
void (rectangle_set_fill_color) (rectangle_t *p, uint32_t color);
|
50 |
/**
|
51 |
* @brief Set rectangle fill transparency.
|
52 |
* @param p Pointer to rectangle
|
53 |
* @param alpha Value of the alpha-channel
|
54 |
*/
|
55 |
void (rectangle_set_fill_trans) (rectangle_t *p, uint8_t alpha);
|
56 |
/**
|
57 |
* @brief Set rectangle outline color.
|
58 |
* @param p Pointer to rectangle
|
59 |
* @param color Color to outline rectangle
|
60 |
*/
|
61 |
void (rectangle_set_outline_color)(rectangle_t *p, uint32_t color);
|
62 |
/**
|
63 |
* @brief Set rectangle outline width.
|
64 |
* @param p Pointer to rectangle
|
65 |
* @param width Width of the rectangle border/outline
|
66 |
*/
|
67 |
void (rectangle_set_outline_width)(rectangle_t *p, int16_t width);
|
68 |
/**
|
69 |
* @brief Get rectangle x-position.
|
70 |
* @param p Pointer to rectangle
|
71 |
* @return Rectangle x-position
|
72 |
*/
|
73 |
int16_t (rectangle_get_x)(const rectangle_t *p);
|
74 |
/**
|
75 |
* @brief Get rectangle y-position.
|
76 |
* @param p Pointer to rectangle
|
77 |
* @return Rectangle y-position
|
78 |
*/
|
79 |
int16_t (rectangle_get_y)(const rectangle_t *p);
|
80 |
/**
|
81 |
* @brief Get rectangle width.
|
82 |
* @param p Pointer to rectangle
|
83 |
* @return Rectangle width
|
84 |
*/
|
85 |
uint16_t (rectangle_get_w)(const rectangle_t *p);
|
86 |
/**
|
87 |
* @brief Get rectangle height.
|
88 |
* @param p Pointer to rectangle
|
89 |
* @return Rectangle height
|
90 |
*/
|
91 |
uint16_t (rectangle_get_h)(const rectangle_t *p);
|
92 |
/**
|
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 |
int (rectangle_collide_point)(const rectangle_t *p, int x, int y); |
100 |
/**
|
101 |
* Draw rectangle in screen buffer.
|
102 |
* @param p Pointer to rectangle to be drawn
|
103 |
*/
|
104 |
void (rectangle_draw)(const rectangle_t *p); |
105 |
|
106 |
/**
|
107 |
* @}
|
108 |
*/
|
109 |
|
110 |
#endif //RECTANGLE_H_INCLUDED |