diff --git a/CMakeLists.txt b/CMakeLists.txt index 28435eb..1e7500a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,9 @@ set(SOURCES src/bar/draw.c ) -set(ASSETS) +set(ASSETS + assets/background.png +) set(FLAGS -std=c11 diff --git a/assets/background.png b/assets/background.png new file mode 100644 index 0000000..e94eee9 Binary files /dev/null and b/assets/background.png differ diff --git a/assets/fxconv-metadata.txt b/assets/fxconv-metadata.txt new file mode 100644 index 0000000..9ce2998 --- /dev/null +++ b/assets/fxconv-metadata.txt @@ -0,0 +1,4 @@ +# gint bopti_image_t +background.png: + type: bopti-image + name: bimg_background diff --git a/src/bar/draw.c b/src/bar/draw.c index b28a4e1..03d1706 100644 --- a/src/bar/draw.c +++ b/src/bar/draw.c @@ -7,9 +7,9 @@ bar_draw(struct Bar bar) const int height = bar.fill * (float)bar.height; const int y = bar.y + bar.height - height; - /* fill */ - drect(bar.x, y, bar.x + BAR_WIDTH, y + height, C_GREEN); /* borders */ - drect_border(bar.x, bar.y, bar.x + BAR_WIDTH, bar.y + bar.height, - C_NONE, 2, C_BLACK); + drect_border(bar.x - 1, bar.y - 1, bar.x + BAR_WIDTH + 1, bar.y + bar.height + 1, + C_WHITE, 2, C_BLACK); + /* fill */ + drect(bar.x, y, bar.x + BAR_WIDTH, y + height, C_RGB(0, 32, 32)); } diff --git a/src/main.c b/src/main.c index 635ad09..8d52cc4 100644 --- a/src/main.c +++ b/src/main.c @@ -2,20 +2,39 @@ #include #include +static struct Bar bars[4]; + +static void main_draw(void); + int main(void) { int i; - struct Bar bars[4]; + /* init */ for (i = 0; i < 4; i += 1) bars[i] = bar_init(i); - dclear(C_WHITE); - for (i = 0; i < 4; i += 1) - bar_draw(bars[i]); - dupdate(); + main_draw(); getkey(); return 1; } + +static void +main_draw(void) +{ + extern bopti_image_t bimg_background; + int i; + + dclear(C_WHITE); + + /* draw background */ + dimage(0, 0, &bimg_background); + + /* draw bars */ + for (i = 0; i < 4; i += 1) + bar_draw(bars[i]); + + dupdate(); +}