diff --git a/main.c b/main.c index 566da08..e65b5ac 100644 --- a/main.c +++ b/main.c @@ -2,73 +2,9 @@ #include #include "images/images.h" -void test_transparency(); -void test_4k_gradient(); -int main(int argc, char* argv[]) { - test_transparency(); - test_4k_gradient(); -} - -void test_transparency() { - Image img; - Color white = color_new(255,255,255); - Color green = color_new(0,255,0); - Color blue = color_new(30,50,210); - Color black = color_new(0,0,0); - - image_new(512, 512, &img); - - // make it white - image_draw_rect(img, 0, 0, 512, 512, white); - - // draw some circs - blue.alpha = 0.5; - image_draw_circ(img, 255,255, 100, blue); - image_draw_circ(img, 255,155, 100, blue); - image_draw_circ(img, 255,355, 100, blue); - green.alpha = .6; - image_draw_circ(img, 255, 255, 12, green); - - // draw a couple of rects - black.alpha = 0.5; - white.alpha = 0.5; - image_draw_square(img, 200, 255, 111, black); - image_draw_square(img, 200, 255, 101, white); - if (!image_save_bmp(img, "test-transparency.bmp")) { - printf("error writing file!\n"); - } else { - printf("writing finished\n"); - } +int main(int argc, char* argv[]) { - image_destroy(img); } -void test_4k_gradient() { - int width = 1920 * 4, - height = 1080 * 4; - - printf("allocating image\n"); - Image img; - image_new(width, height, &img); - - printf("writing pixies\n"); - - 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); - } - } - - printf("writing file to disk\n"); - - if (!image_save_bmp(img, "test-4k.bmp")) { - printf("error writing file!\n"); - } else { - printf("writing finished\n"); - } - image_destroy(img); - printf("image destroyed\n"); -} \ No newline at end of file diff --git a/test.c b/test.c new file mode 100644 index 0000000..0c646e5 --- /dev/null +++ b/test.c @@ -0,0 +1,66 @@ + +void test_transparency(); +void test_4k_gradient(); + +void test_transparency() { + Image img; + Color white = color_new(255,255,255); + Color green = color_new(0,255,0); + Color blue = color_new(30,50,210); + Color black = color_new(0,0,0); + + image_new(512, 512, &img); + + // make it white + image_draw_rect(img, 0, 0, 512, 512, white); + + // draw some circs + blue.alpha = 0.5; + image_draw_circ(img, 255,255, 100, blue); + image_draw_circ(img, 255,155, 100, blue); + image_draw_circ(img, 255,355, 100, blue); + green.alpha = .6; + image_draw_circ(img, 255, 255, 12, green); + + // draw a couple of rects + black.alpha = 0.5; + white.alpha = 0.5; + image_draw_square(img, 200, 255, 111, black); + image_draw_square(img, 200, 255, 101, white); + + if (!image_save_bmp(img, "test-transparency.bmp")) { + printf("error writing file!\n"); + } else { + printf("writing finished\n"); + } + + image_destroy(img); +} + +void test_4k_gradient() { + int width = 1920 * 4, + height = 1080 * 4; + + printf("allocating image\n"); + Image img; + image_new(width, height, &img); + + printf("writing pixies\n"); + + 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); + } + } + + printf("writing file to disk\n"); + + if (!image_save_bmp(img, "test-4k.bmp")) { + printf("error writing file!\n"); + } else { + printf("writing finished\n"); + } + image_destroy(img); + printf("image destroyed\n"); +} \ No newline at end of file