poly.c 896 B

123456789101112131415161718192021222324252627282930313233
  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. #include <memdraw.h>
  13. #include <memlayer.h>
  14. void
  15. mempoly(Memimage *dst, Point *vert, int nvert, int end0, int end1, int radius, Memimage *src, Point sp, int op)
  16. {
  17. int i, e0, e1;
  18. Point d;
  19. if(nvert < 2)
  20. return;
  21. d = subpt(sp, vert[0]);
  22. for(i=1; i<nvert; i++){
  23. e0 = e1 = Enddisc;
  24. if(i == 1)
  25. e0 = end0;
  26. if(i == nvert-1)
  27. e1 = end1;
  28. memline(dst, vert[i-1], vert[i], e0, e1, radius, src, addpt(d, vert[i-1]), op);
  29. }
  30. }