Square function graphing mock test

This commit is contained in:
Curt Spark 2024-08-04 10:04:22 +01:00
parent 161e5c885a
commit a526951200
1 changed files with 28 additions and 4 deletions

32
main.c
View File

@ -41,7 +41,7 @@ int main() {
ss_alloc_free(reserved_memory);
printf("Memory : %d/%d", ALLOC_SIZE, (int)ss_alloc_get_used_bytes());*/
const bitmap_header test = init_bitmap_header(255, 255);
const bitmap_header test = init_bitmap_header(1024, 1024);
const bitmap_file test_file = init_bitmap_file(&test, "test.bmp");
bitmap_pixel_color target_pixel;
@ -59,12 +59,16 @@ int main() {
/* Simple skybox generator */
target_pixel.red = ((float)height / (float)test_file.bitmap_metadata->image_height) * 255;
target_pixel.green = ((float)height / (float)test_file.bitmap_metadata->image_height) * 255;
target_pixel.blue = 150;
target_pixel.blue = 255;
//target_pixel.red = 255;
//target_pixel.green = 255;
//target_pixel.blue = 255;
write_bitmap_pixel(test_file, target_pixel, width, height);
}
}
/*
target_pixel.red = 255;
target_pixel.green = 0;
target_pixel.blue = 0;
@ -77,13 +81,33 @@ int main() {
target_pixel.green = 0;
target_pixel.blue = 255;
grapher_draw_line_lerp(test_file, target_pixel, 10, 10, 245, 100, 0.01);
*/
target_pixel.red = 0;
target_pixel.green = 255;
target_pixel.blue = 0;
int32_t iteration = -22;
int32_t y = iteration * iteration;
int32_t previous_iteration = iteration;
int32_t previous_y = iteration * iteration;
int32_t x = iteration;
int32_t previous_x = x;
while (y < 500 && x < 500) {
y = iteration * iteration;
x += 10;
++iteration;
grapher_draw_line_lerp(test_file, target_pixel, previous_x + 250, previous_y + 250, x + 250, y + 250, 0.1);
previous_iteration = iteration;
previous_x = x;
previous_y = y;
};
/* Draw graph */
target_pixel.red = 0;
target_pixel.green = 0;
target_pixel.blue = 0;
grapher_draw_line_linear(test_file, target_pixel, 10, 10, 245, 10);
grapher_draw_line_linear(test_file, target_pixel, 10, 10, 10, 245);
grapher_draw_line_linear(test_file, target_pixel, 10, 10, 1014, 10);
grapher_draw_line_linear(test_file, target_pixel, 10, 10, 10, 1014);
close(test_file.fd);