3 Example implementation for drawing a shape with rfxswf
5 Part of the swftools package.
7 Copyright (c) 2000, 2001 Rainer Böhme <rfxswf@reflex-studio.de>
9 This file is distributed under the GPL, see file COPYING for details
16 #include "../rfxswf.h"
19 int main (int argc,char ** argv)
25 S32 width=300,height = 300;
29 memset(&swf,0x00,sizeof(SWF)); // set global movie parameters
31 swf.fileVersion = 4; // make flash 4 compatible swf
32 swf.frameRate = 0x1900; // about 0x19 frames per second
34 swf.movieSize.xmax = 20*width; // flash units: 1 pixel = 20 units
35 swf.movieSize.ymax = 20*height;
37 swf.firstTag = swf_InsertTag(NULL,ST_SETBACKGROUNDCOLOR);
39 // now create a tag list be connecting one after another
48 t = swf_InsertTag(t,ST_DEFINESHAPE);
50 swf_ShapeNew(&s); // create new shape instance
52 // add two different linestyles
54 ls1 = swf_ShapeAddLineStyle(s,40,&rgb);
56 rgb.r = 0; rgb.b = 0xff;
57 ls2 = swf_ShapeAddLineStyle(s,40,&rgb);
59 swf_SetU16(t,1); // now set character ID
66 swf_SetRect(t,&r); // set shape bounds
69 swf_SetShapeHeader(t,s); // write all styles to tag
71 swf_ShapeSetAll(t,s,0,0,ls1,0,0); // move to (0,0), select linestyle ls1 and no fillstyle
74 swf_ShapeSetLine(t,s,10*width,10*height); // draw something
75 swf_ShapeSetStyle(t,s,ls2,0,0); // change to second linestyle
78 swf_ShapeSetCircle(t,s,10*width,10*height,i*width,i*height);
80 swf_ShapeSetEnd(t); // finish drawing
82 swf_ShapeFree(s); // clean shape structure (which isn't needed anymore after writing the tag)
84 t = swf_InsertTag(t,ST_PLACEOBJECT2); // append tag to place your shape into the scene
86 swf_ObjectPlace(t,1,1,NULL,NULL,NULL); // set character with id 1 (our shape) to depth 1 (upper most layer)
88 t = swf_InsertTag(t,ST_SHOWFRAME); // finish current frame
90 t = swf_InsertTag(t,ST_END); // finish current movie (which has just one frame)
92 // swf_WriteCGI(&swf); <- use this to create direct CGI output
94 // write movie to file
96 f = open("shape1.swf",O_WRONLY|O_CREAT|O_TRUNC, 0644);
97 if FAILED(swf_WriteSWF(f,&swf)) fprintf(stderr,"WriteSWF() failed.\n");
100 swf_FreeTags(&swf); // cleanup
102 #ifdef __NT__ // start flash player to show result on windows systems
103 system("start ..\\shape1.swf");