40 dy = -
abs(p2[1] - y1);
42 dir[0] = (x1 < p2[0]) * 2 - 1;
43 dir[1] = (y1 < p2[1]) * 2 - 1;
44 while (!(
err * 2 >= dy && x1 == p2[0]) && !(
err * 2 <= dx && y1 == p2[1]))
46 mlx_put_pixel(img, x1, y1, 0xFF0000FF);
void draw_line(mlx_image_t *img, int x1, int y1, int *p2)
Multi-directional implementation of the Bresenham incremental error line drawing algorithm.