X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;ds=inline;f=lib%2Fgfxpoly%2Ftest.c;h=766b1a7901a1d9a5a0813bc4d74d51bcdf2c4260;hb=163bdd5cab1758e4517e8365b3e40b5461d63640;hp=e4e845596950e4370f472135d17ed508531dde14;hpb=66a03382aab040571f94b0861719753bda3ff8f1;p=swftools.git diff --git a/lib/gfxpoly/test.c b/lib/gfxpoly/test.c index e4e8455..766b1a7 100644 --- a/lib/gfxpoly/test.c +++ b/lib/gfxpoly/test.c @@ -11,12 +11,12 @@ gfxline_t*mkstar(int x1, int y1, int x2, int y2) gfxline_t*l=0,*line = 0; int x; for(x=x1;x<=x2;x+=50) { - l = malloc(sizeof(gfxline_t)); + l = rfx_calloc(sizeof(gfxline_t)); l->type = gfx_moveTo; l->x = x;l->y = y1; line = gfxline_append(line, l); - l = malloc(sizeof(gfxline_t)); + l = rfx_calloc(sizeof(gfxline_t)); l->type = gfx_lineTo; l->x = x2-x;l->y = y2; line = gfxline_append(line, l); @@ -27,7 +27,6 @@ gfxline_t*mkstar(int x1, int y1, int x2, int y2) int test1() { gfxline_t*box1 = gfxline_makerectangle(50,50,150,150); - // put box2 and box3 on top of each other *snicker* gfxline_t*box2 = gfxline_makerectangle(100,100,200,200); gfxline_t*box3 = gfxline_makerectangle(100,100,200,200); @@ -49,30 +48,146 @@ int test1() gfxline_free(box1); gfxline_free(box2); gfxline_free(box3); + gfxline_free(star); gfxpoly_dump(poly); gfxpoly_process(poly); } -int test2() +int test_square(int width, int height, int num) { -#define N 1000 int t; - gfxline_t* line = malloc(sizeof(gfxline_t)*N); - for(t=0;ta.x*20, e->a.y*20); + swf_ShapeSetLine(tag, s, e->b.x*20 - e->a.x*20, e->b.y*20 - e->a.y*20); + e = e->next; + } +#else + swf_ShapeSetAll(tag,s,0,0,ls,0,0); + edge_t*e = poly2; + while(e) { + swf_ShapeSetMove(tag, s, e->a.x*20, e->a.y*20); + swf_ShapeSetLine(tag, s, e->b.x*20 - e->a.x*20, e->b.y*20 - e->a.y*20); + + swf_ShapeSetCircle(tag, s, e->a.x*20, e->a.y*20, 5*20, 5*20); + swf_ShapeSetCircle(tag, s, e->b.x*20, e->b.y*20, 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"); } int main()