2 // linux/gcc: cc box.c ../rfxswf.c -funsigned-char -o box -lm; cp box /home/www/cgi-bin/box
11 #define BANNER_TEXT "reflex"
13 #define ID_BANNER 2001
14 #define ID_HIGHLIGHT 2002
15 #define ID_BUTTON 2003
18 int sX[] = { a,-a, a,-a, a,-a, a,-a};
19 int sY[] = { a, a,-a,-a, a, a,-a,-a};
20 int sZ[] = { a, a, a, a,-a,-a,-a,-a};
26 int sin_[512],cos_[512];
32 { d = ((double)i)/128*3.14159;
33 sin_[i] = (int)(sin(d)*256);
34 cos_[i] = (int)(cos(d)*256);
38 void ShapeSquare(LPTAG t,LPSHAPE s,int p1,int p2,int p3,int p4,int dx,int dy)
41 if (((dX[p2]-dX[p1])*(dY[p3]-dY[p1])-(dX[p3]-dX[p1])*(dY[p2]-dY[p1]))<0) return;
43 ShapeSetMove(t,s,dX[p1]+dx,dY[p1]+dy);
44 ShapeSetLine(t,s,dX[p2]-dX[p1],dY[p2]-dY[p1]);
45 ShapeSetLine(t,s,dX[p3]-dX[p2],dY[p3]-dY[p2]);
46 ShapeSetLine(t,s,dX[p4]-dX[p3],dY[p4]-dY[p3]);
47 ShapeSetLine(t,s,dX[p1]-dX[p4],dY[p1]-dY[p4]);
51 void mapBox(int xw,int yw,int zw)
53 int x1,y1,z1,x2,y2,z2,x3,y3,z3;
65 y1 = ( y*cos_[xw]- z*sin_[xw])>>8;
66 z1 = ( y*sin_[xw]+ z*cos_[xw])>>8;
69 x2 = (x1*cos_[yw]+z1*sin_[yw])>>8;
72 x3 = (x2*cos_[zw]-y2*sin_[zw])>>8;
73 y3 = (x2*sin_[zw]+y2*cos_[zw])>>8;
74 z3 = (z1*cos_[yw]-x1*sin_[yw])>>8;
76 dX[i] = x3*4000/(z3+950);
77 dY[i] = y3*4000/(z3+950);
82 int main (int argc,char ** argv)
88 S32 width = 800,height = 800;
97 /* f = open("Arial.efont",O_RDONLY);
99 { if (FAILED(FontImport(f,&font)))
100 { fprintf(stderr,"Font import failed\n");
106 { fprintf(stderr,"Font not found\n");
111 FontSetID(font,ID_FONT);
113 FontUse(&use,BANNER_TEXT);
114 FontReduce(font,&use);*/
118 memset(&swf,0x00,sizeof(SWF));
121 swf.FrameRate = 0x4000;
122 swf.MovieSize.xmax = 4*width;
123 swf.MovieSize.ymax = 4*height;
125 swf.FirstTag = InsertTag(NULL,ST_SETBACKGROUNDCOLOR);
133 t = InsertTag(t,ST_DEFINEFONT);
135 FontSetDefine(t,font);
137 t = InsertTag(t,ST_DEFINEFONTINFO);
141 t = InsertTag(t,ST_DEFINETEXT);
143 SetU16(t,ID_BANNER); // ID
153 TextCountBits(font,BANNER_TEXT,80,&gbits,&abits);
162 TextSetInfoRecord(t,font,height/4,&rgb,0,200);
163 TextSetCharRecord(t,font,BANNER_TEXT,80,gbits,abits);
167 t = InsertTag(t,ST_DEFINETEXT);
169 SetU16(t,ID_HIGHLIGHT); // ID
179 TextCountBits(font,BANNER_TEXT,80,&gbits,&abits);
188 TextSetInfoRecord(t,font,height/4,&rgb,0,200);
189 TextSetCharRecord(t,font,BANNER_TEXT,80,gbits,abits);
193 t = InsertTag(t,ST_DEFINEBUTTON);
200 SetU16(t,ID_BUTTON); // ID
201 ButtonSetRecord(t,BS_UP,ID_BANNER,1,&m,NULL);
202 ButtonSetRecord(t,BS_DOWN|BS_HIT|BS_OVER,ID_HIGHLIGHT,1,&m,NULL);
203 SetU8(t,0); // End of Button Records
204 SetU8(t,0); // End of Action Records
207 t = InsertTag(t,ST_PLACEOBJECT2);
209 ObjectPlace(t,ID_BUTTON,1,NULL,NULL,NULL);
211 GetCXForm(NULL,&cx1,1);
212 GetCXForm(NULL,&cx2,1);
214 // cx1.a1 = -(0x40*1);
215 // cx2.a1 = -(0x40*2);
217 cx1.r1 = cx1.g1 = 0x80;
218 cx2.r1 = cx2.g1 = 0xc0;
222 for (frame=0;frame<256;frame+=2)
225 t = InsertTag(t,ST_DEFINESHAPE);
228 rgb.r = rgb.g = 0x00; rgb.b = 0xff;
229 j = ShapeAddLineStyle(s,40,&rgb);
241 ShapeCountBits(s,NULL,NULL);
244 ShapeSetAll(t,s,0,0,j,0,0);
246 mapBox(frame,frame,frame>>1);
248 ShapeSquare(t,s,0,2,3,1,2*width,2*height);
249 ShapeSquare(t,s,4,5,7,6,2*width,2*height);
250 ShapeSquare(t,s,0,4,6,2,2*width,2*height);
251 ShapeSquare(t,s,1,3,7,5,2*width,2*height);
252 ShapeSquare(t,s,0,1,5,4,2*width,2*height);
253 ShapeSquare(t,s,2,6,7,3,2*width,2*height);
258 for (frame=0;frame<256;frame+=2)
260 int id2 = ((frame-2)&255)+1;
261 int id3 = ((frame-4)&255)+1;
264 { t = InsertTag(t,ST_REMOVEOBJECT2); SetU16(t,2); // depth
265 t = InsertTag(t,ST_REMOVEOBJECT2); SetU16(t,3); // depth
266 t = InsertTag(t,ST_REMOVEOBJECT2); SetU16(t,4); // depth
269 t = InsertTag(t,ST_PLACEOBJECT2);
271 ObjectPlace(t,id,4,NULL,NULL,NULL);
273 t = InsertTag(t,ST_PLACEOBJECT2);
275 ObjectPlace(t,id2,3,NULL,&cx1,NULL);
277 t = InsertTag(t,ST_PLACEOBJECT2);
279 ObjectPlace(t,id3,2,NULL,&cx2,NULL);
282 t = InsertTag(t,ST_SHOWFRAME);
287 t = InsertTag(t,ST_END);
292 f = open("shape1.swf",O_RDWR|O_CREAT|O_TRUNC);
293 if FAILED(WriteSWF(f,&swf)) fprintf(stderr,"WriteSWF() failed.\n");
299 system("start ..\\shape1.swf");