+
+ gfxmatrix_t m;
+ memset(&m, 0, sizeof(m));
+
+ SWF swf;
+ memset(&swf, 0, sizeof(SWF));
+ swf.movieSize.xmax = RANGE*20*1.41;
+ swf.movieSize.ymax = RANGE*20*1.41;
+ swf.fileVersion = 9;
+ swf.frameRate = 25*0x100;
+ TAG * tag = swf.firstTag = swf_InsertTag(0, ST_SETBACKGROUNDCOLOR);
+ swf_SetU8(tag, 0);
+ swf_SetU8(tag, 0);
+ swf_SetU8(tag, 0);
+
+ int t;
+ for(t=0;t<360;t++) {
+ m.m00 = cos(t*M_PI/180.0);
+ m.m01 = sin(t*M_PI/180.0);
+ m.m10 = -sin(t*M_PI/180.0);
+ m.m11 = cos(t*M_PI/180.0);
+ m.tx = RANGE*1.41/2;
+ m.ty = RANGE*1.41/2;
+ gfxline_t*l = gfxline_clone(line);
+ gfxline_transform(l, &m);
+
+ gfxpoly_t*poly = gfxpoly_fillToPoly(l, 0.05);
+ gfxpoly_t*poly2 = gfxpoly_process(poly, &windrule_circular);
+
+ tag = swf_InsertTag(tag, ST_DEFINESHAPE);
+ SHAPE* s;
+ swf_ShapeNew(&s);
+ RGBA rgb;
+ rgb.r = rgb.g = 0x00; rgb.b = 0xff;
+ rgb.a = 255;
+ int fs = swf_ShapeAddSolidFillStyle(s,&rgb);
+ int ls = swf_ShapeAddLineStyle(s,20,&rgb);
+ swf_SetU16(tag,t+1);
+ swf_SetRect(tag,&swf.movieSize);
+ swf_SetShapeHeader(tag,s);
+
+#define FILL
+#ifdef FILL
+ swf_ShapeSetAll(tag,s,0,0,0,fs,0);
+ edge_t*e = poly2->edges;
+ while(e) {
+#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);
+#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);
+#endif
+ e = e->next;
+ }
+#else
+ swf_ShapeSetAll(tag,s,0,0,ls,0,0);
+ edge_t*e = poly2->edges;
+ while(e) {
+ 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_ShapeSetCircle(tag, s, e->a.x, e->a.y, 5*20, 5*20);
+ swf_ShapeSetCircle(tag, s, e->b.x, e->b.y, 5*20, 5*20);
+ e = e->next;
+ }
+#endif
+
+ swf_ShapeSetEnd(tag);
+ swf_ShapeFree(s);
+
+ gfxpoly_destroy(poly);
+ gfxpoly_destroy(poly2);
+
+ gfxline_free(l);
+
+ if(t) {
+ tag = swf_InsertTag(tag,ST_REMOVEOBJECT2);
+ swf_SetU16(tag, t);
+ }
+ tag = swf_InsertTag(tag,ST_PLACEOBJECT2);
+ swf_ObjectPlace(tag,t+1,t+1,NULL,NULL,NULL);
+
+ tag = swf_InsertTag(tag, ST_SHOWFRAME);
+ }
+ tag = swf_InsertTag(tag, ST_END);
+
+ swf_SaveSWF(&swf, "test.swf");
+}
+
+#include <dirent.h>
+void test4()
+{
+ char*dir = "ps";
+ DIR*_dir = opendir(dir);
+ if(!_dir) return;
+ struct dirent*file;
+ while(1) {
+ file = readdir(_dir);
+ if (!file)
+ break;
+ if(!strstr(file->d_name, ".ps"))
+ continue;
+
+ char* filename = allocprintf("%s/%s", dir, file->d_name);
+ windrule_t*rule = &windrule_evenodd;
+ gfxpoly_t*poly = gfxpoly_from_file(filename, 0.01);
+ free(filename);
+
+ double zoom = 1.0;
+ intbbox_t bbox = intbbox_from_polygon(poly, zoom);
+
+ if(!gfxpoly_check(poly)) {
+ printf("bad polygon\n");
+ continue;
+ }
+
+ gfxpoly_t*poly2 = gfxpoly_process(poly, rule);
+ unsigned char*bitmap1 = render_polygon(poly, &bbox, zoom, rule);
+ unsigned char*bitmap2 = render_polygon(poly2, &bbox, zoom, &windrule_evenodd);
+ if(!bitmap_ok(&bbox, bitmap1) || !bitmap_ok(&bbox, bitmap2)) {
+ save_two_bitmaps(&bbox, bitmap1, bitmap2, "error.png");
+ assert(!"error in bitmaps");
+ }
+ if(!compare_bitmaps(&bbox, bitmap1, bitmap2)) {
+ save_two_bitmaps(&bbox, bitmap1, bitmap2, "error.png");
+ assert(!"bitmaps don't match");
+ }
+ gfxpoly_destroy(poly2);
+ }