Initial revision
[swftools.git] / lib / example / shape1.c
1 #include <stdio.h>
2 #include <fcntl.h>
3 #include <math.h>
4 #include "../rfxswf.h"
5
6                
7 int main (int argc,char ** argv)
8 { SWF swf;
9   LPTAG t;
10   RGBA rgb;
11   SRECT r;
12   LPSHAPE s;
13   S32 width=300,height = 300;
14   
15   int f,i,j;
16
17   memset(&swf,0x00,sizeof(SWF));
18
19   swf.FileVersion    = 4;
20   swf.FrameRate      = 0x1900;
21   swf.MovieSize.xmax = 20*width;
22   swf.MovieSize.ymax = 20*height;
23
24   swf.FirstTag = InsertTag(NULL,ST_SETBACKGROUNDCOLOR);
25   t = swf.FirstTag;
26
27         rgb.r = 0xff;
28         rgb.g = 0xff;
29         rgb.b = 0xff;
30         SetRGB(t,&rgb);
31
32   t = InsertTag(t,ST_DEFINESHAPE);
33
34         NewShape(&s);
35         rgb.b = rgb.g = 0x00;
36         j = ShapeAddLineStyle(s,40,&rgb);
37         rgb.r = 0; rgb.b = 0xff;
38         ShapeAddLineStyle(s,40,&rgb);
39
40         SetU16(t,1);  // ID
41
42         r.xmin = 0;
43         r.ymin = 0;
44         r.xmax = 4*width;
45         r.ymax = 4*height;
46         
47         SetRect(t,&r);
48
49         SetShapeStyles(t,s);
50         ShapeCountBits(s,NULL,NULL);
51         SetShapeBits(t,s);
52
53         ShapeSetAll(t,s,0,0,j,0,0);
54 //        ShapeSetCurve(t,s,4*width,0,0,4*height);
55         ShapeSetLine(t,s,4*width,4*height);
56         ShapeSetStyle(t,s,2,0,0);
57         for (i=1;i<10;i++)
58         ShapeSetCircle(t,s,4*width,4*height,i*width/2,i*height/2);
59         ShapeSetEnd(t);
60
61   t = InsertTag(t,ST_PLACEOBJECT2);
62
63         ObjectPlace(t,1,1,NULL,NULL,NULL);
64
65   t = InsertTag(t,ST_SHOWFRAME);
66
67   t = InsertTag(t,ST_END);
68   
69 //  WriteCGI(&swf);
70   
71
72   f = open("shape1.swf",O_WRONLY|O_CREAT, 0777);
73 //  f = 1;
74   if FAILED(WriteSWF(f,&swf)) fprintf(stderr,"WriteSWF() failed.\n");
75   close(f);
76
77   FreeTags(&swf);
78
79 #ifdef __NT__
80   system("start ..\\shape1.swf");
81 #endif
82   
83   return 0;
84 }
85
86