Rev 5229 | Go to most recent revision | 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 | |||
60 | void rect_draw_text(rect *r, char *txt, __u32 len, __u32 color) |
||
61 | { |
||
62 | __menuet__write_text(r->x + 1 + (r->width - len * FONT_WIDTH - len) / 2, |
||
63 | r->y + 1 + (r->height - FONT_HEIGHT) / 2, |
||
64 | 0xFFFFFF,txt,len); |
||
65 | __menuet__write_text(r->x - 1 + (r->width - len * FONT_WIDTH - len) / 2, |
||
66 | r->y - 1 + (r->height - FONT_HEIGHT) / 2, |
||
67 | 0xFFFFFF,txt,len); |
||
68 | __menuet__write_text(r->x - 1 + (r->width - len * FONT_WIDTH - len) / 2, |
||
69 | r->y + 1 + (r->height - FONT_HEIGHT) / 2, |
||
70 | 0xFFFFFF,txt,len); |
||
71 | __menuet__write_text(r->x + 1 + (r->width - len * FONT_WIDTH - len) / 2, |
||
72 | r->y - 1 + (r->height - FONT_HEIGHT) / 2, |
||
73 | 0xFFFFFF,txt,len); |
||
74 | |||
75 | __menuet__write_text(r->x + 1 + (r->width - len * FONT_WIDTH - len) / 2, |
||
76 | r->y + (r->height - FONT_HEIGHT) / 2, |
||
77 | 0xFFFFFF,txt,len); |
||
78 | __menuet__write_text(r->x - 1 + (r->width - len * FONT_WIDTH - len) / 2, |
||
79 | r->y + (r->height - FONT_HEIGHT) / 2, |
||
80 | 0xFFFFFF,txt,len); |
||
81 | __menuet__write_text(r->x + (r->width - len * FONT_WIDTH - len) / 2, |
||
82 | r->y + 1 + (r->height - FONT_HEIGHT) / 2, |
||
83 | 0xFFFFFF,txt,len); |
||
84 | __menuet__write_text(r->x + (r->width - len * FONT_WIDTH - len) / 2, |
||
85 | r->y - 1 + (r->height - FONT_HEIGHT) / 2, |
||
86 | 0xFFFFFF,txt,len); |
||
87 | |||
88 | __menuet__write_text(r->x + (r->width - len * FONT_WIDTH - len) / 2, |
||
89 | r->y + (r->height - FONT_HEIGHT) / 2, |
||
90 | 0,txt,len); |
||
91 | } |
||
92 | |||
5231 | raandoom | 93 | void rect_draw_value(rect* r, __u32 v, __u32 color) |
5229 | raandoom | 94 | { |
95 | char buffer[16] = {0}; |
||
96 | __u32 length = strlen(itoa(v,buffer,10)); |
||
97 | rect_draw_text(r,buffer,length,color); |
||
98 | }>>>>>><>><>>>><>><>> |