Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include "fdf.h"
  2.  
  3. void trace_line(t_img *img, int x0, int y0, int x1, int y1)
  4. {
  5. t_line line;
  6.  
  7. line.dx = ABS(x1-x0);
  8. line.sx = x0 < x1 ? 1 : -1;
  9. line.dy = ABS(y1-y0);
  10. line.sy = y0 < y1 ? 1 : -1;
  11. line.err = (line.dx > line.dy ? line.dx : -line.dy) / 2;
  12. while(x0 != x1 && y0 != y1)
  13. {
  14. //ft_printf("lapinline");
  15. print_pixel(img, x0, y0, 0xFF0000);
  16. //if (x0 == x1 && y0 == y1)
  17. // break;
  18. line.e2 = line.err;
  19. if (line.e2 > -line.dx)
  20. {
  21. line.err -= line.dy;
  22. x0 += line.sx;
  23. }
  24. if (line.e2 < line.dy)
  25. {
  26. line.err += line.dx;
  27. y0 += line.sy;
  28. }
  29. //ft_printf("lapinlinebis");
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement