2 * Copyright (C) 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * Zou Lunkai, zoulunkai@gmail.com
22 * Test for nested layer (static) masks
29 #include "ming_utils.h"
31 #define OUTPUT_VERSION 6
32 #define OUTPUT_FILENAME "masks_test2.swf"
34 SWFMovieClip
defineMovieclip(int x
, int y
, int w
, int h
);
36 SWFMovieClip
defineMovieclip(int x
, int y
, int w
, int h
)
40 mc
= newSWFMovieClip();
41 sh
= make_fill_square (x
, y
, w
, h
, 255, 0, 0, 255, 0, 0);
42 SWFMovieClip_add(mc
, (SWFBlock
)sh
);
43 SWFMovieClip_nextFrame(mc
);
48 main(int argc
, char** argv
)
51 SWFMovieClip mc1
, mc2
, mc3
, mc4
, mc5
, mc6
, mc7
, dejagnuclip
;
54 const char *srcdir
=".";
55 if ( argc
>1 ) srcdir
=argv
[1];
58 mo
= newSWFMovieWithVersion(OUTPUT_VERSION
);
59 SWFMovie_setDimension(mo
, 800, 600);
60 SWFMovie_setRate (mo
, 1.0);
62 * Don't add dejagnu clip to this file.
63 * Or place it in a safe depth.
65 dejagnuclip
= get_dejagnu_clip((SWFBlock
)get_default_font(srcdir
), 10, 0, 0, 800, 600);
66 it
= SWFMovie_add(mo
, (SWFBlock
)dejagnuclip
);
67 SWFDisplayItem_setDepth(it
, 1000);
68 SWFDisplayItem_moveTo(it
, 0, 220);
70 SWFMovie_nextFrame(mo
);
72 mc1
= defineMovieclip(0, 0, 30, 30); // placed at depth 1, masking up to level 4
73 mc2
= defineMovieclip(0, 0, 60, 60); // placed at depth 2, masking up to level 5
74 mc3
= defineMovieclip(0, 0, 90, 90); // placed at depth 3, masking up to level 6
75 mc4
= defineMovieclip(0, 0, 120, 120); // placed at depth 4
76 mc5
= defineMovieclip(0, 0, 150, 150); // placed at depth 5
77 mc6
= defineMovieclip(0, 0, 180, 180); // placed at depth 6
78 mc7
= defineMovieclip(0, 0, 210, 210); // placed at depth 7
80 it
= SWFMovie_add(mo
, (SWFBlock
)mc1
);
81 SWFDisplayItem_setDepth(it
, 1);
82 SWFDisplayItem_setMaskLevel(it
, 4);
83 SWFDisplayItem_setName(it
, "mc1");
85 it
= SWFMovie_add(mo
, (SWFBlock
)mc2
);
86 SWFDisplayItem_setDepth(it
, 2);
87 SWFDisplayItem_setMaskLevel(it
, 5);
88 SWFDisplayItem_setName(it
, "mc2");
90 it
= SWFMovie_add(mo
, (SWFBlock
)mc3
);
91 SWFDisplayItem_setDepth(it
, 3);
92 SWFDisplayItem_setMaskLevel(it
, 6);
93 SWFDisplayItem_setName(it
, "mc3");
95 it
= SWFMovie_add(mo
, (SWFBlock
)mc4
);
96 SWFDisplayItem_setDepth(it
, 4);
97 SWFDisplayItem_setName(it
, "mc4");
99 it
= SWFMovie_add(mo
, (SWFBlock
)mc5
);
100 SWFDisplayItem_setDepth(it
, 5);
101 SWFDisplayItem_setName(it
, "mc5");
103 it
= SWFMovie_add(mo
, (SWFBlock
)mc6
);
104 SWFDisplayItem_setDepth(it
, 6);
105 SWFDisplayItem_setName(it
, "mc6");
107 check(mo
, "mc1.hitTest(28, 28, true)");
108 check(mo
, "mc2.hitTest(58, 58, true)");
109 check(mo
, "mc3.hitTest(88, 88, true)");
110 check(mo
, "mc4.hitTest(118, 118, true)");
111 check(mo
, "mc5.hitTest(148, 148, true)");
112 check(mo
, "mc6.hitTest(178, 178, true)");
115 "mc4.onRollOver = function() { this._alpha = 50; };"
116 "mc4.onRollOut = function() { this._alpha = 100; };"
119 SWFMovie_nextFrame(mo
);
121 it
= SWFMovie_add(mo
, (SWFBlock
)mc7
);
122 SWFDisplayItem_setDepth(it
, 7);
123 SWFDisplayItem_setName(it
, "mc7");
125 check(mo
, "mc7.hitTest(208, 208, true)");
127 add_actions(mo
, "_root.totals(7); stop();");
129 SWFMovie_nextFrame(mo
);
132 puts("Saving " OUTPUT_FILENAME
);
133 SWFMovie_save(mo
, OUTPUT_FILENAME
);