2 #include "../gfxtools.h"
8 gfxline_t l[512], f[256*5];
10 int width=700,height=700;
12 gfxdevice_swf_init(&dev);
13 dev.setparameter(&dev, "framerate", "25.0");
16 dev.startpage(&dev, 700,700);
22 if(g->x<200) {g->x=400-g->x;g->sx=-g->sx;}
23 if(g->y<200) {g->y=400-g->y;g->sy=-g->sy;}
24 if(g->x>500) {g->x=1000-g->x;g->sx=-g->sx;}
25 if(g->y>500) {g->y=1000-g->y;g->sy=-g->sy;}
32 double a = i*0.05+t*M_PI/150;
34 l[i].x = cos(a)*r + width/2;
35 l[i].y = sin(a)*r + height/2;
36 l[i].sx = (int)((l[i].x-width/2)/30);
37 l[i].sy = (int)((l[i].y-height/2)/30);
38 l[i].sx = l[i].sy = 0;
39 l[i].type = gfx_lineTo;
42 l[0].type = gfx_moveTo;
48 for(xx=0;xx<16;xx++) if((xx^yy)&1) {
49 double x = -128+xx*64+t*128.0/300;
50 double y = -128+yy*64;//+t*64.0/300;
53 f[i].next = &f[i+1];f[i++].type = gfx_moveTo;
56 f[i].next = &f[i+1];f[i++].type = gfx_lineTo;
59 f[i].next = &f[i+1];f[i++].type = gfx_lineTo;
62 f[i].next = &f[i+1];f[i++].type = gfx_lineTo;
65 f[i].next = &f[i+1];f[i++].type = gfx_lineTo;
72 //gfxdrawer_target_gfxline(&d);
73 //draw_stroke(l, &d, width, gfx_capRound, gfx_joinBevel, 500);
74 //gfxline_t*line = (gfxline_t*)d.result(&d);
76 //gfxpoly_t*p = gfxpoly_fromstroke(l, width, gfx_capRound, gfx_joinRound, 500);
77 gfxpoly_t*p1 = gfxpoly_from_stroke(l, width, gfx_capRound, gfx_joinRound, 500, 0.05);
78 assert(gfxpoly_check(p1));
80 //gfxpoly_t*p2 = gfxpoly_from_fill(f, 0.05);
81 gfxline_t*l2 = gfxline_clone(l);
83 double c = cos(t*M_PI/75);
84 double s = sin(t*M_PI/75);
85 static int x1 = 0, xdir = 1;
86 static int y1 = 0, ydir = 5;
87 x1+=xdir; if(x1>=150) {x1=300-x1;xdir=-xdir;} if(x1<-150) {x1=-300-x1;xdir=-xdir;}
88 y1+=ydir; if(y1>=150) {y1=300-y1;ydir=-ydir;} if(y1<-150) {y1=-300-y1;ydir=-ydir;}
89 gfxmatrix_t m = { c, s, -(350+x1)*c-350*s+350,
90 -s, c, 350*s-(350+x1)*c+350};
91 gfxline_transform(l2, &m);
92 gfxpoly_t*p2 = gfxpoly_from_stroke(l2, width, gfx_capRound, gfx_joinRound, 500, 0.05);
93 assert(gfxpoly_check(p2));
95 gfxpoly_t*p3 = gfxpoly_intersect(p1, p2);
96 assert(gfxpoly_check(p3));
98 //gfxpoly_t*p4 = gfxpoly_from_fill(f, 0.05);
99 //gfxpoly_t*p5 = gfxpoly_intersect(p1, p4);
101 gfxline_t*line = gfxline_from_gfxpoly(p3);
106 //gfxline_dump(line, stdout, "");
108 gfxcolor_t blue = {255,0,0,255};
109 gfxline_t*r = gfxline_makerectangle(0,0,700,700);
110 dev.fill(&dev, r, &blue);
112 gfxcolor_t black = {255,0,0,64};
113 gfxcolor_t white = {255,255,255,255};
114 gfxcolor_t cyan = {255,0,192,192};
115 //dev.stroke(&dev, l, 2, &black, gfx_capRound, gfx_joinRound, 0);
116 //dev.stroke(&dev, line, 2, &cyan, gfx_capRound, gfx_joinRound, 0);
117 dev.fill(&dev, line, &black);
118 gfxmatrix_t m2 = {1.0, 0, -10,
120 gfxline_transform(line, &m2);
121 dev.fill(&dev, line, &cyan);
122 dev.stroke(&dev, line, 2.0, &white, gfx_capRound, gfx_joinRound, 0);
128 gfxresult_t* result = dev.finish(&dev);
129 result->save(result, "test.swf");
130 result->destroy(result);