aboutsummaryrefslogtreecommitdiff
path: root/src/lib/libkogata
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2017-05-04 16:27:27 +0200
committerAlex Auvolat <alex@adnab.me>2017-05-04 16:27:27 +0200
commitc7486a2113171d4d3fe7891ddf898f9f00865cc9 (patch)
tree8f6e6a8b96118d022d7685eddb58de1aeefdef99 /src/lib/libkogata
parent7a3ab21a27c34033fbe478d68957be8e31f983a2 (diff)
downloadkogata-c7486a2113171d4d3fe7891ddf898f9f00865cc9.tar.gz
kogata-c7486a2113171d4d3fe7891ddf898f9f00865cc9.zip
Window moving :)
Diffstat (limited to 'src/lib/libkogata')
-rw-r--r--src/lib/libkogata/draw.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/lib/libkogata/draw.c b/src/lib/libkogata/draw.c
index 4e5dcf2..9ef4031 100644
--- a/src/lib/libkogata/draw.c
+++ b/src/lib/libkogata/draw.c
@@ -599,17 +599,29 @@ int g_text_height(font_t *font, const char* text, int size) {
}
void g_write(fb_t *fb, int x, int y, const char* text, font_t *font, int size, color_t c) {
+ fb_region_t r;
+ r.x = 0;
+ r.y = 0;
+ r.w = fb->geom.width;
+ r.h = fb->geom.height;
+
+ g_region_write(fb, &r, x, y, text, font, size, c);
+}
+
+void g_region_write(fb_t *fb, fb_region_t *reg, int x, int y, const char* text, font_t *font, int size, color_t c) {
if (font->type == FONT_ASCII_BITMAP) {
while (*text != 0) {
uint8_t id = (uint8_t)*text;
if (id < font->ascii_bitmap.nchars) {
uint8_t *d = font->ascii_bitmap.data + (id * font->ascii_bitmap.ch);
for (int r = 0; r < font->ascii_bitmap.ch; r++) {
- if (y + r >= fb->geom.height) continue;
+ int yy = y + reg->y + r;
+ if (y + r >= reg->h || yy >= fb->geom.height) continue;
for (int j = 0; j < 8; j++) {
- if (x + j >= fb->geom.width) continue;
+ int xx = x + reg->x + j;
+ if (x + j >= reg->w || xx >= fb->geom.width) continue;
if (d[r] & (0x80 >> j)) {
- g_plot(fb, x + j, y + r, c);
+ g_plot(fb, xx, yy, c);
}
}
}
@@ -654,12 +666,18 @@ void g_write(fb_t *fb, int x, int y, const char* text, font_t *font, int size, c
for (int i = 0; i < h; i++) {
int yy = y + size + y0 + i;
if (yy < 0) continue;
+ if (yy >= reg->h) continue;
+ yy += reg->y;
+ if (yy < 0) continue;
if (yy >= fb->geom.height) continue;
uint8_t *line = fb->data + yy * fb->geom.pitch;
for (int j = 0; j < w; j++) {
int xx = x + x0 + (int)xpos + j;
if (xx < 0) continue;
+ if (xx >= reg->w) continue;
+ xx += reg->x;
+ if (xx < 0) continue;
if (xx >= fb->geom.width) continue;
uint8_t a = tmp[i*w+j];
@@ -686,9 +704,6 @@ void g_write(fb_t *fb, int x, int y, const char* text, font_t *font, int size, c
}
}
-void g_region_write(fb_t *fb, fb_region_t *reg, int x, int y, const char* text, font_t *font, int size, color_t c) {
- // TODO
-}
/* vim: set ts=4 sw=4 tw=0 noet :*/