#include <stdint.h>
#include "bmp.h"
#include "math.h"

void grapher_draw_line_linear(const bitmap_file bitmap_file_in, const bitmap_pixel_color bitmap_pixel_in, int32_t x_origin_in, int32_t y_origin_in, const int32_t x_end_in, const int32_t y_end_in) {
	while (x_origin_in < x_end_in || y_origin_in < y_end_in) {
		write_bitmap_pixel(bitmap_file_in, bitmap_pixel_in, x_origin_in, y_origin_in);
		if (x_origin_in < x_end_in)
			x_origin_in++;
		if (y_origin_in < y_end_in)
			y_origin_in++;
	};
};

void grapher_draw_line_lerp(const bitmap_file bitmap_file_in, const bitmap_pixel_color bitmap_pixel_in, int32_t x_origin_in, int32_t y_origin_in, const int32_t x_end_in, const int32_t y_end_in, const float lerp_step_in) {
	int32_t x_origin_lerped = 1;
	int32_t y_origin_lerped = 1;
	float position = 0;

	for (position = 0; x_origin_lerped < x_end_in || y_origin_lerped < y_end_in; position += lerp_step_in) {
		x_origin_lerped = lerp(x_origin_in, x_end_in, position);
		y_origin_lerped = lerp(y_origin_in, y_end_in, position);
		write_bitmap_pixel(bitmap_file_in, bitmap_pixel_in, x_origin_lerped, y_origin_lerped);
	};
};
