plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

ellipse.c (1966B)


      1 #include <u.h>
      2 #include <libc.h>
      3 #include <draw.h>
      4 
      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;
     10 
     11 	_setdrawop(dst->display, op);
     12 
     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 }
     31 
     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 }
     37 
     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 }
     43 
     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 }
     49 
     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 }
     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 |= ((ulong)1)<<31;
     60 	doellipse('e', dst, &c, a, b, thick, src, &sp, alpha, phi, SoverD);
     61 }
     62 
     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 }
     69 
     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 }
     76 
     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 }