Draw rectangles with lines.

Change-Id: I257ea485e67d2cc1c2ad5f9405fe507f3f4d00f1
This commit is contained in:
Felix Raimundo
2016-04-01 15:03:40 +02:00
parent 89647c995d
commit ff83c8c4da
3 changed files with 26 additions and 9 deletions

View File

@@ -46,21 +46,13 @@ static void clear_trig_menu() {
}
static void print_trig_menu() {
{
KDRect r;
r.x = SCREEN_WIDTH / 4 - 1;
r.y = SCREEN_HEIGHT / 4 - 1;
r.width = SCREEN_WIDTH / 2 + 2;
r.height = SCREEN_HEIGHT / 2 + 2;
KDFillRect(r, 0xFF);
}
{
KDRect r;
r.x = SCREEN_WIDTH / 4;
r.y = SCREEN_HEIGHT / 4;
r.width = SCREEN_WIDTH / 2;
r.height = SCREEN_HEIGHT / 2;
KDFillRect(r, 0x00);
KDDrawRect(r, 0xff);
}
}

View File

@@ -24,5 +24,6 @@ typedef struct {
extern KDRect KDRectZero;
void KDFillRect(KDRect rect, KDColor color);
void KDDrawRect(KDRect rect, KDColor color);
#endif

View File

@@ -12,3 +12,27 @@ void KDFillRect(KDRect rect, KDColor color) {
}
}
}
void KDDrawRect(KDRect rect, KDColor color) {
KDPoint p1, p2;
p1.x = rect.x;
p1.y = rect.y;
p2.x = rect.x;
p2.y = rect.y + rect.height;
for (int i = 0; i<rect.width; i++) {
KDSetPixel(p1, color);
KDSetPixel(p2, color);
p1.x++;
p2.x++;
}
p1.x = rect.x;
p1.y = rect.y;
p2.x = rect.x + rect.width;
p2.y = rect.y;
for (int i = 0; i<rect.height; i++) {
KDSetPixel(p1, color);
KDSetPixel(p2, color);
p1.y++;
p2.y++;
}
}