/* * Copyright (C) 2005, 2006 Free Software Foundation, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ /* * Zou Lunkai, address@hidden * * Test for nested masks */ #include #include #include #include "ming_utils.h" #define OUTPUT_VERSION 6 #define OUTPUT_FILENAME "masks_test4.swf" SWFMovieClip defineMovieclip(int x, int y, int w, int h); SWFMovieClip defineMovieclip(int x, int y, int w, int h) { SWFMovieClip mc; SWFShape sh; mc = newSWFMovieClip(); sh = make_fill_square (x, y, w, h, 255, 0, 0, 255, 0, 0); SWFMovieClip_add(mc, (SWFBlock)sh); SWFMovieClip_nextFrame(mc); return mc; } int main(int argc, char** argv) { SWFMovie mo; SWFMovieClip mc1, mc2, mc3, dejagnuclip; SWFDisplayItem it; const char *srcdir="."; Ming_init(); mo = newSWFMovieWithVersion(OUTPUT_VERSION); SWFMovie_setDimension(mo, 800, 600); SWFMovie_setRate (mo, 0.5); // NOTE: take care of the TextFiled instance box! // Better not use it here:)! it seems violates this test. // dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600); // SWFMovie_add(mo, (SWFBlock)dejagnuclip); SWFMovie_nextFrame(mo); // frame1 mc1 = defineMovieclip(0, 0, 30, 30); // medium square mc2 = defineMovieclip(0, 0, 10, 10); // small square mc3 = defineMovieclip(0, 0, 90, 90); // big square // -- case1 -- // mask1: at depth 1 masks up to layer 3 // mask2: at depth 2 (masked by mask1) masks up to layer 5 // maskee: at depth 4 // expected: maskee masked by both mask1 and mask2. it = SWFMovie_add(mo, (SWFBlock)mc1); SWFDisplayItem_setDepth(it, 1); SWFDisplayItem_setMaskLevel(it, 3); SWFDisplayItem_addAction(it, compileSWFActionCode( " _root.note(this + ' pressed'); "), SWFACTION_PRESS); SWFDisplayItem_setName(it, "mask1"); SWFDisplayItem_moveTo(it, 200, 200); it = SWFMovie_add(mo, (SWFBlock)mc2); SWFDisplayItem_setDepth(it, 2); SWFDisplayItem_setMaskLevel(it, 5); SWFDisplayItem_addAction(it, compileSWFActionCode( " _root.note(this + ' pressed'); "), SWFACTION_PRESS); SWFDisplayItem_setName(it, "mask2"); SWFDisplayItem_moveTo(it, 200, 200); it = SWFMovie_add(mo, (SWFBlock)mc3); SWFDisplayItem_setDepth(it, 4); SWFDisplayItem_addAction(it, compileSWFActionCode( " _root.note(this + ' pressed'); "), SWFACTION_PRESS); SWFDisplayItem_setName(it, "maskee"); SWFDisplayItem_moveTo(it, 200, 200); // visual check: show a small square, the result of mask1 & mask2 SWFMovie_nextFrame(mo); // frame 2 // -- case2 -- // mask1: at depth 11 masks up to layer 16 // mask2: at depth 12 masks up to layer 13 // maskee: at depth 14 // expected: maskee masked by only mask1. it = SWFMovie_add(mo, (SWFBlock)mc1); SWFDisplayItem_setDepth(it, 11); SWFDisplayItem_setMaskLevel(it, 16); SWFDisplayItem_moveTo(it, 400, 400); SWFDisplayItem_addAction(it, compileSWFActionCode( " _root.note(this + ' pressed'); "), SWFACTION_PRESS); SWFDisplayItem_setName(it, "mask1"); it = SWFMovie_add(mo, (SWFBlock)mc2); SWFDisplayItem_setDepth(it, 12); SWFDisplayItem_setMaskLevel(it, 13); SWFDisplayItem_moveTo(it, 400, 400); SWFDisplayItem_addAction(it, compileSWFActionCode( " _root.note(this + ' pressed'); "), SWFACTION_PRESS); SWFDisplayItem_setName(it, "mask2"); it = SWFMovie_add(mo, (SWFBlock)mc3); SWFDisplayItem_setDepth(it, 14); SWFDisplayItem_moveTo(it, 400, 400); SWFDisplayItem_addAction(it, compileSWFActionCode( " _root.note(this + ' pressed'); "), SWFACTION_PRESS); SWFDisplayItem_setName(it, "maskee"); // visual check: show a medium square, the result of mask1. SWFMovie_nextFrame(mo); // frame 4 //Output movie puts("Saving " OUTPUT_FILENAME ); SWFMovie_save(mo, OUTPUT_FILENAME); return 0; }