Revision 323
more stuff
rectangle.c | ||
---|---|---|
8 | 8 |
struct rectangle{ |
9 | 9 |
int16_t x, y; |
10 | 10 |
uint16_t w, h; |
11 |
uint32_t outline_color; |
|
11 | 12 |
uint32_t fill_color; |
13 |
int16_t outline_width; |
|
12 | 14 |
uint8_t fill_alpha; |
13 |
uint32_t outline_color; |
|
14 |
int16_t outline_width; |
|
15 | 15 |
}; |
16 | 16 |
|
17 | 17 |
rectangle_t* (rectangle_ctor)(int16_t x, int16_t y, uint16_t w, uint16_t h){ |
... | ... | |
51 | 51 |
|
52 | 52 |
static void (rectangle_draw_hline)(int16_t x, int16_t y, int16_t l, uint32_t color){ |
53 | 53 |
if(l < 0){ rectangle_draw_hline(x+l, y, -l, color); return; } |
54 |
for(int16_t x_ = max(0,x); x_ < min(x+l,graph_get_XRes()); ++x_){
|
|
55 |
graph_set_pixel(x_, y, color);
|
|
54 |
for(int16_t x_ = max16(0,x); x_ < min16(x+l,(int16_t)graph_get_XRes()); ++x_){
|
|
55 |
graph_set_pixel((uint16_t)x_, (uint16_t)y, color);
|
|
56 | 56 |
} |
57 | 57 |
} |
58 | 58 |
static void (rectangle_draw_vline)(int16_t x, int16_t y, int16_t l, uint32_t color){ |
59 | 59 |
if(l < 0){ rectangle_draw_vline(x, y+l, -l, color); return; } |
60 |
for(int16_t y_ = max(0,y); y_ < min(y+l,graph_get_YRes()); ++y_){
|
|
61 |
graph_set_pixel(x, y_, color);
|
|
60 |
for(int16_t y_ = max16(0,y); y_ < min16(y+l,(int16_t)graph_get_YRes()); ++y_){
|
|
61 |
graph_set_pixel((uint16_t)x, (uint16_t)y_, color);
|
|
62 | 62 |
} |
63 | 63 |
} |
64 | 64 |
|
65 | 65 |
void (rectangle_draw)(const rectangle_t *p){ |
66 | 66 |
/// fill |
67 | 67 |
if(p->fill_alpha > ALPHA_THRESHOLD) |
68 |
for(int16_t y = max(p->y,0); y < min(p->y+p->h, graph_get_YRes()); ++y)
|
|
69 |
rectangle_draw_hline(p->x, y, p->w, p->fill_color); |
|
68 |
for(int16_t y = max16(p->y,0); y < min16(p->y+p->h, (int16_t)graph_get_YRes()); ++y)
|
|
69 |
rectangle_draw_hline(p->x, y, (int16_t)p->w, p->fill_color);
|
|
70 | 70 |
/// border |
71 | 71 |
int16_t step = (p->outline_width > 0 ? 1 : -1); |
72 | 72 |
int16_t l = p->x, r = p->x+p->w, t = p->y, b = p->y+p->h; |
Also available in: Unified diff