diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-08-27 21:53:28 +0100 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-08-27 21:53:28 +0100 |
commit | 2d11304ab4726d3904344d908c93c84a76391707 (patch) | |
tree | aa6d1d2ddb4225fb57f10d4ab06eebc52e8bb92a /main.c | |
parent | 026aa887f99d87932fd5316152a15c1a79f5a6e2 (diff) | |
download | abelian-sandpile-2d11304ab4726d3904344d908c93c84a76391707.tar.gz abelian-sandpile-2d11304ab4726d3904344d908c93c84a76391707.tar.bz2 abelian-sandpile-2d11304ab4726d3904344d908c93c84a76391707.zip |
~file-handler->files,(main~>files)~migrated png save code to files.c
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 31 |
1 files changed, 1 insertions, 30 deletions
@@ -13,8 +13,6 @@ #include <raylib.h> #include <raymath.h> -#include <stb/stb_image_write.h> - #include "./lib.h" struct StepArg @@ -150,34 +148,7 @@ int main(void) } CloseWindow(); - - unsigned char *image_data = - calloc(3 * state.dwidth * state.dwidth, sizeof(*image_data)); - - size_t image_ptr = 0; - - for (size_t i = 0; i < state.dwidth; ++i) - for (size_t j = 0; j < state.dwidth; ++j, image_ptr += 3) - { - Color c = {0}; - uint64_t sandpile = state.data[(i * state.dwidth) + j]; - if (sandpile == 0) - c = BLACK; - else if (sandpile == 1) - c = MAGENTA; - else if (sandpile == 2) - c = RED; - else if (sandpile == 3) - c = BLUE; - - image_data[image_ptr] = c.r; - image_data[image_ptr + 1] = c.g; - image_data[image_ptr + 2] = c.b; - } - - stbi_write_png("data.png", state.dwidth, state.dwidth, 3, image_data, - 3 * state.dwidth); - free(image_data); + write_to_png(&state, "data.png"); free(state.data); return 0; } |