Rev 5231 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5229 | raandoom | 1 | #include "rect.h" |
2 | |||
3 | void rect_draw(rect* r, __u32 color) |
||
4 | { |
||
5 | __menuet__bar(r->x,r->y,r->width,r->height,color); |
||
6 | } |
||
7 | |||
8 | __u8 rect_transform(rect* from, rect* to, __u16 step) |
||
9 | { |
||
10 | if (from->width < to->width) |
||
11 | { |
||
5231 | raandoom | 12 | from->width += (step << 1); |
5229 | raandoom | 13 | if (from->width > to->width) from->width = to->width; |
14 | } |
||
15 | else if (from->width > to->width) |
||
16 | { |
||
5231 | raandoom | 17 | from->width -= (step << 1); |
5229 | raandoom | 18 | if (from->width < to->width) from->width = to->width; |
19 | } |
||
20 | |||
21 | if (from->height < to->height) |
||
22 | { |
||
5231 | raandoom | 23 | from->height += (step << 1); |
5229 | raandoom | 24 | if (from->height > to->height) from->height = to->height; |
25 | } |
||
26 | else if (from->height > to->height) |
||
27 | { |
||
5231 | raandoom | 28 | from->height -= (step << 1); |
5229 | raandoom | 29 | if (from->height < to->height) from->height = to->height; |
30 | } |
||
31 | |||
32 | if (from->x < to->x) |
||
33 | { |
||
5231 | raandoom | 34 | from->x += step; |
5229 | raandoom | 35 | if (from->x > to->x) from->x = to->x; |
36 | } |
||
37 | else if (from->x > to->x) |
||
38 | { |
||
5231 | raandoom | 39 | from->x -= step; |
5229 | raandoom | 40 | if (from->x < to->x) from->x = to->x; |
41 | } |
||
42 | |||
43 | if (from->y < to->y) |
||
44 | { |
||
5231 | raandoom | 45 | from->y += step; |
5229 | raandoom | 46 | if (from->y > to->y) from->y = to->y; |
47 | } |
||
48 | else if (from->y > to->y) |
||
49 | { |
||
5231 | raandoom | 50 | from->y -= step; |
5229 | raandoom | 51 | if (from->y < to->y) from->y = to->y; |
52 | } |
||
53 | |||
54 | return (from->x == to->x) && |
||
55 | (from->y == to->y) && |
||
56 | (from->width == to->width) && |
||
57 | (from->height == to->height); |
||
58 | } |
||
59 | |||
5238 | raandoom | 60 | void rect_draw_text(rect *r, char *txt, __u32 len, __u32 color, __u32 frame_color) |
5229 | raandoom | 61 | { |
5238 | raandoom | 62 | // right down shadow |
63 | __menuet__write_text(r->x + 1 + (r->width - text_length_px(len)) / 2, |
||
5229 | raandoom | 64 | r->y + 1 + (r->height - FONT_HEIGHT) / 2, |
5238 | raandoom | 65 | frame_color,txt,len); |
66 | // right shadow |
||
67 | __menuet__write_text(r->x + 1 + (r->width - text_length_px(len)) / 2, |
||
5229 | raandoom | 68 | r->y + (r->height - FONT_HEIGHT) / 2, |
5238 | raandoom | 69 | frame_color,txt,len); |
70 | // down shadow |
||
71 | __menuet__write_text(r->x + (r->width - text_length_px(len)) / 2, |
||
5229 | raandoom | 72 | r->y + 1 + (r->height - FONT_HEIGHT) / 2, |
5238 | raandoom | 73 | frame_color,txt,len); |
5229 | raandoom | 74 | |
5238 | raandoom | 75 | __menuet__write_text(r->x + (r->width - text_length_px(len)) / 2, |
5229 | raandoom | 76 | r->y + (r->height - FONT_HEIGHT) / 2, |
5238 | raandoom | 77 | color,txt,len); |
5229 | raandoom | 78 | } |
79 | |||
5238 | raandoom | 80 | void rect_draw_value(rect* r, __u32 v, __u32 color, __u32 frame_color) |
5229 | raandoom | 81 | { |
82 | char buffer[16] = {0}; |
||
83 | __u32 length = strlen(itoa(v,buffer,10)); |
||
5238 | raandoom | 84 | rect_draw_text(r,buffer,length,color,frame_color); |
5229 | raandoom | 85 | }>>>>>><>><>>>><>><>> |