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