Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "fdf.h"
- void trace_line(t_img *img, int x0, int y0, int x1, int y1)
- {
- t_line line;
- line.dx = ABS(x1-x0);
- line.sx = x0 < x1 ? 1 : -1;
- line.dy = ABS(y1-y0);
- line.sy = y0 < y1 ? 1 : -1;
- line.err = (line.dx > line.dy ? line.dx : -line.dy) / 2;
- while(x0 != x1 && y0 != y1)
- {
- //ft_printf("lapinline");
- print_pixel(img, x0, y0, 0xFF0000);
- //if (x0 == x1 && y0 == y1)
- // break;
- line.e2 = line.err;
- if (line.e2 > -line.dx)
- {
- line.err -= line.dy;
- x0 += line.sx;
- }
- if (line.e2 < line.dy)
- {
- line.err += line.dx;
- y0 += line.sy;
- }
- //ft_printf("lapinlinebis");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement