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 program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
26 #include "../rfxswf.h"
29 int main (int argc,char ** argv)
35 S32 width=300,height = 300;
39 memset(&swf,0x00,sizeof(SWF)); // set global movie parameters
41 swf.fileVersion = 4; // make flash 4 compatible swf
42 swf.frameRate = 0x1900; // about 0x19 frames per second
44 swf.movieSize.xmax = 20*width; // flash units: 1 pixel = 20 units
45 swf.movieSize.ymax = 20*height;
47 swf.firstTag = swf_InsertTag(NULL,ST_SETBACKGROUNDCOLOR);
49 // now create a tag list be connecting one after another
58 t = swf_InsertTag(t,ST_DEFINESHAPE);
60 swf_ShapeNew(&s); // create new shape instance
62 // add two different linestyles
64 ls1 = swf_ShapeAddLineStyle(s,40,&rgb);
66 rgb.r = 0; rgb.b = 0xff;
67 ls2 = swf_ShapeAddLineStyle(s,40,&rgb);
69 swf_SetU16(t,1); // now set character ID
76 swf_SetRect(t,&r); // set shape bounds
79 swf_SetShapeHeader(t,s); // write all styles to tag
81 swf_ShapeSetAll(t,s,0,0,ls1,0,0); // move to (0,0), select linestyle ls1 and no fillstyle
84 swf_ShapeSetLine(t,s,10*width,10*height); // draw something
85 swf_ShapeSetStyle(t,s,ls2,0,0); // change to second linestyle
88 swf_ShapeSetCircle(t,s,10*width,10*height,i*width,i*height);
90 swf_ShapeSetEnd(t); // finish drawing
92 swf_ShapeFree(s); // clean shape structure (which isn't needed anymore after writing the tag)
94 t = swf_InsertTag(t,ST_PLACEOBJECT2); // append tag to place your shape into the scene
96 swf_ObjectPlace(t,1,1,NULL,NULL,NULL); // set character with id 1 (our shape) to depth 1 (upper most layer)
98 t = swf_InsertTag(t,ST_SHOWFRAME); // finish current frame
100 t = swf_InsertTag(t,ST_END); // finish current movie (which has just one frame)
102 // swf_WriteCGI(&swf); <- use this to create direct CGI output
104 // write movie to file
106 f = open("shape1.swf",O_WRONLY|O_CREAT|O_TRUNC, 0644);
107 if FAILED(swf_WriteSWF(f,&swf)) fprintf(stderr,"WriteSWF() failed.\n");
110 swf_FreeTags(&swf); // cleanup
112 #ifdef __NT__ // start flash player to show result on windows systems
113 system("start ..\\shape1.swf");