28 lines
729 B
C
28 lines
729 B
C
#include <stdint.h>
|
|
#include "bmp.h"
|
|
#include "math.h"
|
|
|
|
void grapher_draw_line(bitmap_file *bitmap_file_in, int32_t x_origin_in, int32_t y_origin_in, int32_t x_end_in, int32_t y_end_in) {
|
|
float x_step = 0;
|
|
float y_step = 0;
|
|
int32_t x_origin_lerped;
|
|
int32_t y_origin_lerped;
|
|
bitmap_pixel_color target_pixel;
|
|
target_pixel.red = 0;
|
|
target_pixel.green = 0;
|
|
target_pixel.blue = 0;
|
|
|
|
while (x_origin_in < x_end_in || y_origin_in < y_end_in) {
|
|
x_origin_lerped = lerp(x_origin_in, x_end_in, x_step);
|
|
y_origin_lerped = lerp(y_origin_in, y_end_in, y_step);
|
|
|
|
x_step += 0.1;
|
|
y_step += 0.1;
|
|
|
|
if (x_step >= 1 || y_step >= 1)
|
|
return;
|
|
|
|
write_bitmap_pixel(bitmap_file_in, &target_pixel, x_origin_in, y_origin_in);
|
|
};
|
|
};
|