Blob


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