X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fgfxtools.c;h=3e565a107ab05062d2d27faae1e6e495a43ec28a;hp=e79e6fefd672f78c7a7c71a3213fd8d6f1a2df2e;hb=71b11cc925e384ecad5b0f48b511bcadc2867f9b;hpb=a75ba56a3af5826224448fd26867eeac7c4bb395 diff --git a/lib/gfxtools.c b/lib/gfxtools.c index e79e6fe..3e565a1 100644 --- a/lib/gfxtools.c +++ b/lib/gfxtools.c @@ -834,6 +834,42 @@ gfxline_t*gfxline_makerectangle(int x1,int y1,int x2, int y2) return line; } +gfxline_t*gfxline_makecircle(double x,double y,double rx, double ry) +{ + double C1 = 0.2930; + double C2 = 0.4140; + double begin = 0.7070; + gfxline_t** line = (gfxline_t**)rfx_calloc(sizeof(gfxline_t*)*9); + int t; + for(t=0;t<9;t++) { + line[t] = rfx_calloc(sizeof(gfxline_t)); + } + line[0]->type = gfx_moveTo; + line[0]->x = x+begin*rx; + line[0]->y = y+begin*ry; + for(t=1;t<9;t++) { + line[t-1]->next = line[t]; + line[t]->type = gfx_splineTo; + } + line[8]->next = 0; +#define R(nr,cx,cy,mx,my) \ + line[nr]->sx = line[nr-1]->x + (cx); \ + line[nr]->sy = line[nr-1]->y + (cy); \ + line[nr]->x = line[nr]->sx + (mx); \ + line[nr]->y = line[nr]->sy + (my); + R(1, -C1*rx, C1*ry, -C2*rx, 0); + R(2, -C2*rx, 0, -C1*rx, -C1*ry); + R(3, -C1*rx, -C1*ry, 0, -C2*ry); + R(4, 0, -C2*ry, C1*rx, -C1*ry); + R(5, C1*rx, -C1*ry, C2*rx, 0); + R(6, C2*rx, 0, C1*rx, C1*ry); + R(7, C1*rx, C1*ry, 0, C2*ry); + R(8, 0, C2*ry, -C1*rx, C1*ry); + gfxline_t*l = line[0]; + free(line); + return l; +} + gfxbbox_t* gfxline_isrectangle(gfxline_t*_l) { if(!_l)