1 ed7c8e8d 2003-09-30 devnull #include <u.h>
2 ed7c8e8d 2003-09-30 devnull #include <libc.h>
3 ed7c8e8d 2003-09-30 devnull #include <draw.h>
7 ed7c8e8d 2003-09-30 devnull addcoord(uchar *p, int oldx, int newx)
11 ed7c8e8d 2003-09-30 devnull dx = newx-oldx;
12 ed7c8e8d 2003-09-30 devnull /* does dx fit in 7 signed bits? */
13 ed7c8e8d 2003-09-30 devnull if((unsigned)(dx - -0x40) <= 0x7F)
14 ed7c8e8d 2003-09-30 devnull *p++ = dx&0x7F;
16 ed7c8e8d 2003-09-30 devnull *p++ = 0x80 | (newx&0x7F);
17 ed7c8e8d 2003-09-30 devnull *p++ = newx>>7;
18 ed7c8e8d 2003-09-30 devnull *p++ = newx>>15;
20 ed7c8e8d 2003-09-30 devnull return p;
25 ed7c8e8d 2003-09-30 devnull dopoly(int cmd, Image *dst, Point *pp, int np, int end0, int end1, int radius, Image *src, Point *sp, Drawop op)
27 ed7c8e8d 2003-09-30 devnull uchar *a, *t, *u;
28 ed7c8e8d 2003-09-30 devnull int i, ox, oy;
30 ed7c8e8d 2003-09-30 devnull if(np == 0)
32 ed7c8e8d 2003-09-30 devnull t = malloc(np*2*3);
33 ed7c8e8d 2003-09-30 devnull if(t == nil)
36 ed7c8e8d 2003-09-30 devnull ox = oy = 0;
37 ed7c8e8d 2003-09-30 devnull for(i=0; i<np; i++){
38 ed7c8e8d 2003-09-30 devnull u = addcoord(u, ox, pp[i].x);
39 ed7c8e8d 2003-09-30 devnull ox = pp[i].x;
40 ed7c8e8d 2003-09-30 devnull u = addcoord(u, oy, pp[i].y);
41 ed7c8e8d 2003-09-30 devnull oy = pp[i].y;
44 ed7c8e8d 2003-09-30 devnull _setdrawop(dst->display, op);
46 ed7c8e8d 2003-09-30 devnull a = bufimage(dst->display, 1+4+2+4+4+4+4+2*4+(u-t));
47 ed7c8e8d 2003-09-30 devnull if(a == 0){
49 ed7c8e8d 2003-09-30 devnull fprint(2, "image poly: %r\n");
52 ed7c8e8d 2003-09-30 devnull a[0] = cmd;
53 ed7c8e8d 2003-09-30 devnull BPLONG(a+1, dst->id);
54 ed7c8e8d 2003-09-30 devnull BPSHORT(a+5, np-1);
55 ed7c8e8d 2003-09-30 devnull BPLONG(a+7, end0);
56 ed7c8e8d 2003-09-30 devnull BPLONG(a+11, end1);
57 ed7c8e8d 2003-09-30 devnull BPLONG(a+15, radius);
58 ed7c8e8d 2003-09-30 devnull BPLONG(a+19, src->id);
59 ed7c8e8d 2003-09-30 devnull BPLONG(a+23, sp->x);
60 ed7c8e8d 2003-09-30 devnull BPLONG(a+27, sp->y);
61 ed7c8e8d 2003-09-30 devnull memmove(a+31, t, u-t);
66 ed7c8e8d 2003-09-30 devnull poly(Image *dst, Point *p, int np, int end0, int end1, int radius, Image *src, Point sp)
68 ed7c8e8d 2003-09-30 devnull dopoly('p', dst, p, np, end0, end1, radius, src, &sp, SoverD);
72 ed7c8e8d 2003-09-30 devnull polyop(Image *dst, Point *p, int np, int end0, int end1, int radius, Image *src, Point sp, Drawop op)
74 ed7c8e8d 2003-09-30 devnull dopoly('p', dst, p, np, end0, end1, radius, src, &sp, op);
78 ed7c8e8d 2003-09-30 devnull fillpoly(Image *dst, Point *p, int np, int wind, Image *src, Point sp)
80 ed7c8e8d 2003-09-30 devnull dopoly('P', dst, p, np, wind, 0, 0, src, &sp, SoverD);
84 ed7c8e8d 2003-09-30 devnull fillpolyop(Image *dst, Point *p, int np, int wind, Image *src, Point sp, Drawop op)
86 ed7c8e8d 2003-09-30 devnull dopoly('P', dst, p, np, wind, 0, 0, src, &sp, op);