5 #include "../gfxtools.h"
9 gfxline_t*mkstar(int x1, int y1, int x2, int y2)
11 gfxline_t*l=0,*line = 0;
13 for(x=x1;x<=x2;x+=50) {
14 l = rfx_calloc(sizeof(gfxline_t));
17 line = gfxline_append(line, l);
19 l = rfx_calloc(sizeof(gfxline_t));
21 l->x = x2-x;l->y = y2;
22 line = gfxline_append(line, l);
29 gfxline_t*box1 = gfxline_makerectangle(50,50,150,150);
30 // put box2 and box3 on top of each other *snicker*
31 gfxline_t*box2 = gfxline_makerectangle(100,100,200,200);
32 gfxline_t*box3 = gfxline_makerectangle(100,100,200,200);
33 gfxline_t*star = mkstar(50,50, 150,150);
35 b = gfxline_append(b, box1);
36 b = gfxline_append(b, box2);
37 b = gfxline_append(b, box3);
38 b = gfxline_append(b, star);
41 memset(&matrix, 0, sizeof(gfxmatrix_t));
43 matrix.m00=cos(ua);matrix.m10=sin(ua);
44 matrix.m01=-sin(ua);matrix.m11=cos(ua);
46 gfxline_transform(b, &matrix);
47 gfxpoly_t*poly = gfxpoly_fillToPoly(b);
54 gfxpoly_process(poly);
57 int test_square(int width, int height, int num)
60 gfxline_t* line = malloc(sizeof(gfxline_t)*num);
62 line[t].type = t?gfx_lineTo:gfx_moveTo;
63 line[t].x = (lrand48()%width)-width/2;
64 line[t].y = (lrand48()%height)-height/2;
65 line[t].next = &line[t+1];
67 line[num-1].x = line[0].x;
68 line[num-1].y = line[0].y;
71 gfxpoly_t*poly = gfxpoly_fillToPoly(line);
72 gfxpoly_t*poly2 = gfxpoly_process(poly);
74 gfxpoly_destroy(poly);
75 gfxpoly_destroy(poly2);
80 test_square(200,5, 1000);
81 test_square(5,200, 1000);
82 test_square(10,10, 200);
83 test_square(500,500, 50);
84 test_square(65536,65536,256);
87 #include "../rfxswf.h"
96 gfxline_t* line = malloc(sizeof(gfxline_t)*N*2);
98 line[i].type = i?gfx_lineTo:gfx_moveTo;
99 line[i].x = lrand48()%RANGE - RANGE/2;
100 line[i].y = lrand48()%RANGE - RANGE/2;
101 line[i].next = &line[i+1];
102 line[i+N].x = lrand48()%RANGE - RANGE/2;
103 line[i+N].y = lrand48()%RANGE - RANGE/2;
104 line[i+N].next = &line[N+i+1];
106 line[N*2-1].x = line[0].x;
107 line[N*2-1].y = line[0].y;
108 line[N*2-1].next = 0;
111 memset(&m, 0, sizeof(m));
114 memset(&swf, 0, sizeof(SWF));
115 swf.movieSize.xmax = RANGE*20*1.41;
116 swf.movieSize.ymax = RANGE*20*1.41;
118 swf.frameRate = 25*0x100;
119 TAG * tag = swf.firstTag = swf_InsertTag(0, ST_SETBACKGROUNDCOLOR);
126 m.m00 = cos(t*M_PI/180.0);
127 m.m01 = sin(t*M_PI/180.0);
128 m.m10 = -sin(t*M_PI/180.0);
129 m.m11 = cos(t*M_PI/180.0);
132 gfxline_t*l = gfxline_clone(line);
133 gfxline_transform(l, &m);
135 gfxpoly_t*poly = gfxpoly_fillToPoly(l);
136 gfxpoly_t*poly2 = gfxpoly_process(poly);
138 tag = swf_InsertTag(tag, ST_DEFINESHAPE);
142 rgb.r = rgb.g = 0x00; rgb.b = 0xff;
144 int fs = swf_ShapeAddSolidFillStyle(s,&rgb);
145 int ls = swf_ShapeAddLineStyle(s,20,&rgb);
147 swf_SetRect(tag,&swf.movieSize);
148 swf_SetShapeHeader(tag,s);
151 swf_ShapeSetAll(tag,s,0,0,0,fs,0);
154 swf_ShapeSetMove(tag, s, e->a.x*20, e->a.y*20);
155 swf_ShapeSetLine(tag, s, e->b.x*20 - e->a.x*20, e->b.y*20 - e->a.y*20);
159 swf_ShapeSetAll(tag,s,0,0,ls,0,0);
162 swf_ShapeSetMove(tag, s, e->a.x*20, e->a.y*20);
163 swf_ShapeSetLine(tag, s, e->b.x*20 - e->a.x*20, e->b.y*20 - e->a.y*20);
165 swf_ShapeSetCircle(tag, s, e->a.x*20, e->a.y*20, 5*20, 5*20);
166 swf_ShapeSetCircle(tag, s, e->b.x*20, e->b.y*20, 5*20, 5*20);
171 swf_ShapeSetEnd(tag);
174 gfxpoly_destroy(poly);
175 gfxpoly_destroy(poly2);
180 tag = swf_InsertTag(tag,ST_REMOVEOBJECT2);
183 tag = swf_InsertTag(tag,ST_PLACEOBJECT2);
184 swf_ObjectPlace(tag,t+1,t+1,NULL,NULL,NULL);
186 tag = swf_InsertTag(tag, ST_SHOWFRAME);
188 tag = swf_InsertTag(tag, ST_END);
190 swf_SaveSWF(&swf, "test.swf");