X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fgfxpoly%2Fconvert.c;fp=lib%2Fgfxpoly%2Fconvert.c;h=bb019422e9e9fe9ad2401f4a8c7eb2c236bc266f;hp=0a2cc93bbf9c45bf020d42028eb793e3c6cb2975;hb=a9634f803811f39e67114955c3e9c30ae247a669;hpb=98370d6c69a85a6b148939956d8edfb324a0740a diff --git a/lib/gfxpoly/convert.c b/lib/gfxpoly/convert.c index 0a2cc93..bb01942 100644 --- a/lib/gfxpoly/convert.c +++ b/lib/gfxpoly/convert.c @@ -133,6 +133,7 @@ void finish_segment(compactpoly_t*data) return; point_t*p = malloc(sizeof(point_t)*data->num_points); gfxpolystroke_t*s = rfx_calloc(sizeof(gfxpolystroke_t)); + s->fs = &edgestyle_default; s->next = data->poly->strokes; data->poly->strokes = s; s->num_points = s->points_size = data->num_points; @@ -166,19 +167,29 @@ static void compactmoveto(polywriter_t*w, int32_t x, int32_t y) } data->last = p; } + +static inline int direction(point_t p1, point_t p2) +{ + int diff = p1.y - p2.y; + if(diff) return diff; + return p1.x - p2.x; +} + static void compactlineto(polywriter_t*w, int32_t x, int32_t y) { compactpoly_t*data = (compactpoly_t*)w->internal; point_t p; p.x = x; p.y = y; - if(p.x == data->last.x && p.y == data->last.y) + + int diff = direction(p, data->last); + if(!diff) return; + segment_dir_t dir = diff<0?DIR_UP:DIR_DOWN; - if((p.y < data->last.y && data->dir != DIR_UP) || - (p.y > data->last.y && data->dir != DIR_DOWN) || data->new) { + if(dir!=data->dir || data->new) { finish_segment(data); - data->dir = p.y > data->last.y ? DIR_DOWN : DIR_UP; + data->dir = dir; data->points[0] = data->last; data->num_points = 1; }