ellipse.c 2.3 KB

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