ellipse.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #include <u.h>
  2. #include <libc.h>
  3. #include <draw.h>
  4. static
  5. void
  6. doellipse(int cmd, Image *dst, Point *c, int xr, int yr, int thick, Image *src, Point *sp, int alpha, int phi, Drawop op)
  7. {
  8. uchar *a;
  9. _setdrawop(dst->display, op);
  10. a = bufimage(dst->display, 1+4+4+2*4+4+4+4+2*4+2*4);
  11. if(a == 0){
  12. fprint(2, "image ellipse: %r\n");
  13. return;
  14. }
  15. a[0] = cmd;
  16. BPLONG(a+1, dst->id);
  17. BPLONG(a+5, src->id);
  18. BPLONG(a+9, c->x);
  19. BPLONG(a+13, c->y);
  20. BPLONG(a+17, xr);
  21. BPLONG(a+21, yr);
  22. BPLONG(a+25, thick);
  23. BPLONG(a+29, sp->x);
  24. BPLONG(a+33, sp->y);
  25. BPLONG(a+37, alpha);
  26. BPLONG(a+41, phi);
  27. }
  28. void
  29. ellipse(Image *dst, Point c, int a, int b, int thick, Image *src, Point sp)
  30. {
  31. doellipse('e', dst, &c, a, b, thick, src, &sp, 0, 0, SoverD);
  32. }
  33. void
  34. ellipseop(Image *dst, Point c, int a, int b, int thick, Image *src, Point sp, Drawop op)
  35. {
  36. doellipse('e', dst, &c, a, b, thick, src, &sp, 0, 0, op);
  37. }
  38. void
  39. fillellipse(Image *dst, Point c, int a, int b, Image *src, Point sp)
  40. {
  41. doellipse('E', dst, &c, a, b, 0, src, &sp, 0, 0, SoverD);
  42. }
  43. void
  44. fillellipseop(Image *dst, Point c, int a, int b, Image *src, Point sp, Drawop op)
  45. {
  46. doellipse('E', dst, &c, a, b, 0, src, &sp, 0, 0, op);
  47. }
  48. void
  49. arc(Image *dst, Point c, int a, int b, int thick, Image *src, Point sp, int alpha, int phi)
  50. {
  51. alpha |= 1<<31;
  52. doellipse('e', dst, &c, a, b, thick, src, &sp, alpha, phi, SoverD);
  53. }
  54. void
  55. arcop(Image *dst, Point c, int a, int b, int thick, Image *src, Point sp, int alpha, int phi, Drawop op)
  56. {
  57. alpha |= 1<<31;
  58. doellipse('e', dst, &c, a, b, thick, src, &sp, alpha, phi, op);
  59. }
  60. void
  61. fillarc(Image *dst, Point c, int a, int b, Image *src, Point sp, int alpha, int phi)
  62. {
  63. alpha |= 1<<31;
  64. doellipse('E', dst, &c, a, b, 0, src, &sp, alpha, phi, SoverD);
  65. }
  66. void
  67. fillarcop(Image *dst, Point c, int a, int b, Image *src, Point sp, int alpha, int phi, Drawop op)
  68. {
  69. alpha |= 1<<31;
  70. doellipse('E', dst, &c, a, b, 0, src, &sp, alpha, phi, op);
  71. }