add blend mode tests
[swfdec.git] / test / image / clip-change.c
blob9e7da16b160705e25122ac06e9f61423ddb866a8
1 /* gcc `pkg-config --libs --cflags libming` clip-change.c -o clip-change && ./clip-change
2 */
4 #include <ming.h>
6 static SWFBlock
7 get_rectangle (int r, int g, int b)
9 SWFShape shape;
10 SWFFillStyle fill;
12 shape = newSWFShape ();
13 fill = SWFShape_addSolidFillStyle (shape, r, g, b, 255);
14 SWFShape_setRightFillStyle (shape, fill);
15 SWFShape_drawLineTo (shape, 100, 0);
16 SWFShape_drawLineTo (shape, 100, 100);
17 SWFShape_drawLineTo (shape, 0, 100);
18 SWFShape_drawLineTo (shape, 0, 0);
20 return (SWFBlock) shape;
23 static void
24 do_movie (int version, int reverse)
26 const char *suffixes[4] = { "forward", "backward", "remove", "set" };
27 char name[100];
28 SWFMovie movie;
29 SWFDisplayItem item, clip;
31 movie = newSWFMovieWithVersion (version);
32 SWFMovie_setRate (movie, 1);
33 SWFMovie_setDimension (movie, 200, 150);
35 clip = SWFMovie_add (movie, get_rectangle (255, 0, 0));
36 SWFDisplayItem_setDepth (clip, 0);
37 if (reverse != 3)
38 SWFDisplayItem_setMaskLevel (clip, (reverse & 1) ? 3 : 2);
40 item = SWFMovie_add (movie, get_rectangle (0, 255, 0));
41 SWFDisplayItem_moveTo (item, 0, 50);
42 SWFDisplayItem_setDepth (item, 2);
44 item = SWFMovie_add (movie, get_rectangle (0, 0, 255));
45 SWFDisplayItem_moveTo (item, 50, 0);
46 SWFDisplayItem_setDepth (item, 3);
48 SWFMovie_nextFrame (movie);
49 if (reverse != 2)
50 SWFDisplayItem_setMaskLevel (clip, (reverse & 1) ? 2 : 3);
51 else
52 SWFDisplayItem_setMaskLevel (clip, 0);
53 SWFMovie_nextFrame (movie);
55 sprintf (name, "clip-change-%s-%d.swf", suffixes[reverse], version);
56 SWFMovie_save (movie, name);
59 int
60 main (int argc, char **argv)
62 int i;
64 if (Ming_init ())
65 return 1;
67 for (i = 8; i >= 5; i--) {
68 do_movie (i, 0);
69 do_movie (i, 1);
70 do_movie (i, 2);
71 do_movie (i, 3);
74 return 0;