1 /* gcc `pkg-config --libs --cflags libming` mask-and-clip.c -o mask-and-clip && ./mask-and-clip
9 THIRD_MOVIE_SWAP_DEPTH
,
13 #define FLAG_SET(var, flag) ((var) & (1 << (flag)))
16 get_rectangle (int r
, int g
, int b
)
22 clip
= newSWFMovieClip ();
23 shape
= newSWFShape ();
24 fill
= SWFShape_addSolidFillStyle (shape
, r
, g
, b
, 255);
25 SWFShape_setRightFillStyle (shape
, fill
);
26 SWFShape_drawLineTo (shape
, 100, 0);
27 SWFShape_drawLineTo (shape
, 100, 100);
28 SWFShape_drawLineTo (shape
, 0, 100);
29 SWFShape_drawLineTo (shape
, 0, 0);
31 SWFMovieClip_add (clip
, (SWFBlock
) shape
);
32 SWFMovieClip_nextFrame (clip
);
33 return (SWFBlock
) clip
;
37 do_movie (int version
, unsigned int flags
)
41 SWFDisplayItem item
, item1
, item2
;
43 movie
= newSWFMovieWithVersion (version
);
44 SWFMovie_setRate (movie
, 1);
45 SWFMovie_setDimension (movie
, 200, 150);
47 item1
= item
= SWFMovie_add (movie
, get_rectangle (255, 0, 0));
48 SWFDisplayItem_setDepth (item
, 0);
49 SWFDisplayItem_setName (item
, "a");
50 if (FLAG_SET (flags
, FIRST_MOVIE_CLIP_ALL
)) {
51 SWFDisplayItem_setMaskLevel (item
, 3);
53 SWFDisplayItem_setMaskLevel (item
, 1);
56 item2
= item
= SWFMovie_add (movie
, get_rectangle (0, 255, 0));
57 SWFDisplayItem_moveTo (item
, 50, 25);
58 SWFDisplayItem_setDepth (item
, 1);
59 SWFDisplayItem_setName (item
, "b");
60 if (FLAG_SET (flags
, SECOND_MOVIE_CLIP_ALL
)) {
61 SWFDisplayItem_setMaskLevel (item
, 3);
63 SWFDisplayItem_setMaskLevel (item
, 2);
66 item
= SWFMovie_add (movie
, get_rectangle (0, 0, 255));
67 SWFDisplayItem_moveTo (item
, 25, 50);
68 SWFDisplayItem_setDepth (item
, 3);
69 SWFDisplayItem_setName (item
, "c");
71 if (FLAG_SET (flags
, THIRD_MOVIE_SWAP_DEPTH
)) {
72 SWFMovie_add (movie
, (SWFBlock
) newSWFAction ("c.swapDepths (100);"));
74 if (FLAG_SET (flags
, THIRD_MOVIE_MASK
)) {
75 SWFDisplayItem mask
= SWFMovie_add (movie
, get_rectangle (128, 128, 128));
76 SWFDisplayItem_moveTo (mask
, 50, 50);
77 SWFDisplayItem_setDepth (mask
, 50);
78 SWFDisplayItem_setName (mask
, "mask");
79 SWFMovie_add (movie
, (SWFBlock
) newSWFAction (
83 SWFMovie_nextFrame (movie
);
85 sprintf (name
, "mask-and-clip-%u-%d.swf", flags
, version
);
86 SWFMovie_save (movie
, name
);
90 main (int argc
, char **argv
)
97 for (i
= 8; i
<= 8; i
++) {
98 for (j
= 0; j
< (1 << N_FLAGS
); j
++) {