X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fgfxpoly.c;h=a08899de6c721442d27b84017f26fce00a81d241;hp=af847f859b937fd4dad6d5e5f8623232f32bb242;hb=66a03382aab040571f94b0861719753bda3ff8f1;hpb=c2e927662131cdf53562c223c23ac96b14ef18a1 diff --git a/lib/gfxpoly.c b/lib/gfxpoly.c index af847f8..a08899d 100644 --- a/lib/gfxpoly.c +++ b/lib/gfxpoly.c @@ -384,11 +384,13 @@ static ArtVpath* gfxline_to_ArtVpath(gfxline_t*line, char fill) pos = 0; l2 = line; + int lastmove=-1; while(l2) { if(l2->type == gfx_moveTo) { vec[pos].code = ART_MOVETO_OPEN; vec[pos].x = l2->x; vec[pos].y = l2->y; + lastmove=pos; pos++; assert(pos<=len); } else if(l2->type == gfx_lineTo) { @@ -413,6 +415,16 @@ static ArtVpath* gfxline_to_ArtVpath(gfxline_t*line, char fill) } x = l2->x; y = l2->y; + + /* let closed line segments start w/ MOVETO instead of MOVETO_OPEN */ + if(lastmove>=0 && l2->type!=gfx_moveTo && (!l2->next || l2->next->type == gfx_moveTo)) { + if(vec[lastmove].x == l2->x && + vec[lastmove].y == l2->y) { + assert(vec[lastmove].code == ART_MOVETO_OPEN); + vec[lastmove].code = ART_MOVETO; + } + } + l2 = l2->next; } vec[pos++].code = ART_END; @@ -437,7 +449,7 @@ static ArtVpath* gfxline_to_ArtVpath(gfxline_t*line, char fill) } /* Find adjacent identical points. If an ajdacent pair of identical - points is found, the second is removed. + points is found, the second one is removed. So moveto x,y lineto x,y becomes moveto x,y lineto x,y lineto x,y becomes lineto x,y lineto x,y moveto x,y becomes lineto x,y @@ -529,7 +541,13 @@ static double find_shear_value(ArtSVP*svp) } if(!fail) break; - v = lrand48() / 2000000000.0; +#ifdef HAVE_LRAND48 + v = lrand48() / 2000000000.0;; +#elif HAVE_RAND + v = rand() / 2000000000.0; +#else +#error "no lrand48()/rand() implementation found" +#endif tries++; } return v;