-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshapedemo.c
44 lines (34 loc) · 1.01 KB
/
shapedemo.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <libTimer.h>
#include "lcdutils.h"
#include "lcddraw.h"
#include "shape.h"
const AbRect rect10 = {abRectGetBounds, abRectCheck, 10,10};;
void
abDrawPos(AbShape *shape, Vec2 *shapeCenter, u_int fg_color, u_int bg_color)
{
u_char row, col;
Region bounds;
abShapeGetBounds(shape, shapeCenter, &bounds);
lcd_setArea(bounds.topLeft.axes[0], bounds.topLeft.axes[1],
bounds.botRight.axes[0]-1, bounds.botRight.axes[1]-1);
for (row = bounds.topLeft.axes[1]; row < bounds.botRight.axes[1]; row++) {
for (col = bounds.topLeft.axes[0]; col < bounds.botRight.axes[0]; col++) {
Vec2 pixelPos = {col, row};
int color = abShapeCheck(shape, shapeCenter, &pixelPos) ?
fg_color : bg_color;
lcd_writeColor(color);
}
}
}
int
main()
{
configureClocks();
lcd_init();
shapeInit();
Vec2 rectPos = screenCenter;
clearScreen(COLOR_BLUE);
drawString5x7(20,20, "hello", COLOR_GREEN, COLOR_RED);
shapeInit();
abDrawPos((AbShape*)&rect10, &rectPos, COLOR_ORANGE, COLOR_BLUE);
}