line.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include <u.h>
  10. #include <libc.h>
  11. #include <draw.h>
  12. void
  13. line(Image *dst, Point p0, Point p1, int end0, int end1, int radius, Image *src, Point sp)
  14. {
  15. lineop(dst, p0, p1, end0, end1, radius, src, sp, SoverD);
  16. }
  17. void
  18. lineop(Image *dst, Point p0, Point p1, int end0, int end1, int radius, Image *src, Point sp, Drawop op)
  19. {
  20. uint8_t *a;
  21. _setdrawop(dst->display, op);
  22. a = bufimage(dst->display, 1+4+2*4+2*4+4+4+4+4+2*4);
  23. if(a == 0){
  24. fprint(2, "image line: %r\n");
  25. return;
  26. }
  27. a[0] = 'L';
  28. BPLONG(a+1, dst->id);
  29. BPLONG(a+5, p0.x);
  30. BPLONG(a+9, p0.y);
  31. BPLONG(a+13, p1.x);
  32. BPLONG(a+17, p1.y);
  33. BPLONG(a+21, end0);
  34. BPLONG(a+25, end1);
  35. BPLONG(a+29, radius);
  36. BPLONG(a+33, src->id);
  37. BPLONG(a+37, sp.x);
  38. BPLONG(a+41, sp.y);
  39. }