From 21ef4f2e6d75fcac5278429232f9a37ae4d6e2e9 Mon Sep 17 00:00:00 2001 From: Anton Lydike Date: Fri, 13 Mar 2020 22:43:08 +0100 Subject: [PATCH] cleaned up --- images/images.h | 14 +++++++++----- main.c | 13 ++++++++----- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/images/images.h b/images/images.h index c647925..527e580 100644 --- a/images/images.h +++ b/images/images.h @@ -25,11 +25,7 @@ int image_check_coords(Image image, int x, int y); int image_destroy(Image image); -// drawing - -int image_draw_rect(Image image, int x1, int y1, int x2, int y2, Color color); -int image_draw_circ(Image image, int x, int y, int r, Color color); -int image_draw_square(Image image, int x, int y, int s, Color color); +// colors Color color_new(int r, int g, int b); Color color_new_alpha(int r, int g, int b, float alpha); @@ -38,6 +34,14 @@ void print_color(Color c); Color color_mix(Color c1, Color c2, float ratio); +// drawing + +int image_draw_rect(Image image, int x1, int y1, int x2, int y2, Color color); +int image_draw_circ(Image image, int x, int y, int r, Color color); +int image_draw_square(Image image, int x, int y, int s, Color color); + + + // bmp format specifics: int image_save_bmp(Image image, char* path); diff --git a/main.c b/main.c index 3bb327f..566da08 100644 --- a/main.c +++ b/main.c @@ -46,16 +46,19 @@ void test_transparency() { } void test_4k_gradient() { + int width = 1920 * 4, + height = 1080 * 4; + printf("allocating image\n"); Image img; - image_new(1920 * 4,1080 * 4, &img); + image_new(width, height, &img); printf("writing pixies\n"); - for (int i = 0; i < 1920 * 4; i++) { - for (int j = 0; j < 1080 * 4; j++) { - float color = (j / (1080.0f * 4)) * 255; - image_set_px(img, i, j, (int) color, 255, 255); + for (int i = 0; i < width; i++) { + for (int j = 0; j < height; j++) { + int color = ((j / ((float) height)) * 255); + image_set_px(img, i, j, color, 255, 255); } }