X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fgfxpoly%2Ftest.c;h=a6a5ab51d95cc7322eeb16e0306fd1c17278411c;hp=4e3c875cabc7b4ceb96e1c672298378f4dfcf5c0;hb=fec1ab31707e68c2396b186e0e4928632402d649;hpb=336f6de943b8c0bbeb0f64b7e35dd9511147a20a diff --git a/lib/gfxpoly/test.c b/lib/gfxpoly/test.c index 4e3c875..a6a5ab5 100644 --- a/lib/gfxpoly/test.c +++ b/lib/gfxpoly/test.c @@ -114,19 +114,20 @@ gfxline_t* mkchessboard() return b; } -gfxline_t* make_circles() +gfxline_t* make_circles(int n) { gfxline_t*b = 0; unsigned int c = 0; int t; - for(t=0;t<30;t++) { + for(t=0;tedges; - while(e) { + swf_ShapeSetAll(tag,s,UNDEFINED_COORD,UNDEFINED_COORD,0,fs,0); + + int i,j; + gfxpolystroke_t*stroke = poly2->strokes; + for(;stroke;stroke=stroke->next) { + for(j=0;jnum_points-1;j++) { + point_t a = stroke->points[j]; + point_t b = stroke->points[j+1]; #define ROTATE #ifdef ROTATE - swf_ShapeSetMove(tag, s, e->a.y, e->a.x); - swf_ShapeSetLine(tag, s, e->b.y - e->a.y, e->b.x - e->a.x); + swf_ShapeSetMove(tag, s, a.y, a.x); + swf_ShapeSetLine(tag, s, b.y - a.y, b.x - a.x); #else - swf_ShapeSetMove(tag, s, e->a.x, e->a.y); - swf_ShapeSetLine(tag, s, e->b.x - e->a.x, e->b.y - e->a.y); + swf_ShapeSetMove(tag, s, a.x, a.y); + swf_ShapeSetLine(tag, s, b.x - a.x, b.y - a.y); #endif - e = e->next; - } + } + } #else swf_ShapeSetAll(tag,s,0,0,ls,0,0); edge_t*e = poly2->edges; @@ -355,7 +339,7 @@ void test3(int argn, char*argv[]) swf_ShapeSetEnd(tag); swf_ShapeFree(s); - gfxcompactpoly_destroy(poly); + gfxpoly_destroy(poly1); gfxpoly_destroy(poly2); gfxline_free(l); @@ -376,15 +360,14 @@ void test3(int argn, char*argv[]) void rotate90(gfxpoly_t*poly) { - edge_t*e = poly->edges; - while(e) { - point_t a = e->a; - point_t b = e->b; - e->a.x = a.y; - e->a.y = a.x; - e->b.x = b.y; - e->b.y = b.x; - e = e->next; + int i,j; + gfxpolystroke_t*stroke = poly->strokes; + for(;stroke;stroke=stroke->next) { + for(j=0;jnum_points;j++) { + point_t a = stroke->points[j]; + stroke->points[j].x = a.y; + stroke->points[j].y = a.x; + } } } @@ -410,20 +393,19 @@ void test4(int argn, char*argv[]) filename = argv[1]; windrule_t*rule = &windrule_evenodd; - gfxcompactpoly_t*poly = gfxcompactpoly_from_file(filename, 1.0);//0.01); + gfxpoly_t*poly1 = gfxpoly_from_file(filename, 1.0);//0.01); if(argn!=2) free(filename); double zoom = 1.0; - if(!gfxcompactpoly_check(poly)) { + if(!gfxpoly_check(poly1)) { printf("bad polygon\n"); continue; } - gfxpoly_t*poly1 = gfxpoly_from_gfxcompactpoly(poly); - gfxpoly_t*poly2 = gfxpoly_process(poly, rule, &onepolygon); + gfxpoly_t*poly2 = gfxpoly_process(poly1, rule, &onepolygon); int pass; for(pass=0;pass<2;pass++) { @@ -448,7 +430,6 @@ void test4(int argn, char*argv[]) gfxpoly_destroy(poly1); gfxpoly_destroy(poly2); - gfxcompactpoly_destroy(poly); if(argn==2) break; } @@ -460,31 +441,29 @@ void test4(int argn, char*argv[]) void extract_polygons_fill(gfxdevice_t*dev, gfxline_t*line, gfxcolor_t*color) { - //gfxcompactpoly_t*c = gfxcompactpoly_from_gfxline(line, 0.05); - //gfxcompactpoly_free(c); + //gfxpoly_t*c = gfxpoly_from_gfxline(line, 0.05); + //gfxpoly_free(c); - gfxcompactpoly_t*poly = gfxcompactpoly_from_gfxline(line, 0.05); + gfxpoly_t*poly1 = gfxpoly_from_gfxline(line, 0.05); //gfxline_dump(line, stderr, ""); - //gfxcompactpoly_dump(poly); + //gfxpoly_dump(poly); - if(gfxcompactpoly_size(poly)>100000) { - fprintf(stderr, "%d segments (skipping)\n", gfxcompactpoly_size(poly)); + if(gfxpoly_size(poly1)>100000) { + fprintf(stderr, "%d segments (skipping)\n", gfxpoly_size(poly1)); return; } else { //fprintf(stderr, "%d segments\n", gfxpoly_size(poly)); } - if(!gfxcompactpoly_check(poly)) { - gfxcompactpoly_destroy(poly); + if(!gfxpoly_check(poly1)) { + gfxpoly_destroy(poly1); fprintf(stderr, "bad polygon\n"); return; } windrule_t*rule = &windrule_evenodd; - gfxpoly_t*poly1 = gfxpoly_from_gfxcompactpoly(poly); - double zoom = 1.0; intbbox_t bbox = intbbox_from_polygon(poly1, zoom); unsigned char*bitmap1 = render_polygon(poly1, &bbox, zoom, rule, &onepolygon); @@ -492,7 +471,7 @@ void extract_polygons_fill(gfxdevice_t*dev, gfxline_t*line, gfxcolor_t*color) fprintf(stderr, "bad polygon or error in renderer\n"); return; } - gfxpoly_t*poly2 = gfxpoly_process(poly, rule, &onepolygon); + gfxpoly_t*poly2 = gfxpoly_process(poly1, rule, &onepolygon); unsigned char*bitmap2 = render_polygon(poly2, &bbox, zoom, &windrule_evenodd, &onepolygon); if(!bitmap_ok(&bbox, bitmap2)) { save_two_bitmaps(&bbox, bitmap1, bitmap2, "error.png"); @@ -507,7 +486,6 @@ void extract_polygons_fill(gfxdevice_t*dev, gfxline_t*line, gfxcolor_t*color) gfxpoly_destroy(poly1); gfxpoly_destroy(poly2); - gfxcompactpoly_destroy(poly); } int extract_polygons_setparameter(gfxdevice_t*dev, const char*key, const char*value) { return 0;