line.c 731 B

1234567891011121314151617181920212223242526272829303132333435
  1. #include <u.h>
  2. #include <libc.h>
  3. #include <draw.h>
  4. void
  5. line(Image *dst, Point p0, Point p1, int end0, int end1, int radius, Image *src, Point sp)
  6. {
  7. lineop(dst, p0, p1, end0, end1, radius, src, sp, SoverD);
  8. }
  9. void
  10. lineop(Image *dst, Point p0, Point p1, int end0, int end1, int radius, Image *src, Point sp, Drawop op)
  11. {
  12. uchar *a;
  13. _setdrawop(dst->display, op);
  14. a = bufimage(dst->display, 1+4+2*4+2*4+4+4+4+4+2*4);
  15. if(a == 0){
  16. fprint(2, "image line: %r\n");
  17. return;
  18. }
  19. a[0] = 'L';
  20. BPLONG(a+1, dst->id);
  21. BPLONG(a+5, p0.x);
  22. BPLONG(a+9, p0.y);
  23. BPLONG(a+13, p1.x);
  24. BPLONG(a+17, p1.y);
  25. BPLONG(a+21, end0);
  26. BPLONG(a+25, end1);
  27. BPLONG(a+29, radius);
  28. BPLONG(a+33, src->id);
  29. BPLONG(a+37, sp.x);
  30. BPLONG(a+41, sp.y);
  31. }