<?php include("sample_utils.php"); // provides some utils and using mk $swfFN = "test_clipdepth01.swf"; // will output with this file name $ds1 = new MKshape_container(); // let's begin to draw $ds1->add_fillStyle_solid("#FF9966"); // create new color to fill $ds1->add_rect(0, 0, 148, 74); // draw a rectangle $svgFN = "o.svg"; // we use an svg file $ssr = new MKsimple_svg_reader($svgFN); // open it and read data, // now we are dealing to an mk_shape_container // object instance $ssr->set_shapeID(2); // assign item id $ssr->set_mask(4); // use is as mask $ds2 = new MKshape_container("", 3); // another shape for($i = 0; $i < 80; $i++){ // ... $ds2->add_fillStyle_solid(get_random_color()); // draw 80 random ... $ds2->add_circle($r, $x, $y); // ... } $ds2->move(100, 100); // move to final position $swf = new MKswf($swfFN); // create new swf $swf->set_swfDir(SERVER_MKTMP); // set working directory $swf->set_stageWidth(148); // assign canvas width $swf->set_stageHeight(148); // ... and height $t1 = $ds1->update_tagData(); // get binary data $t2 = $ds1->update_place_tagData(); // placing settings data $t3 = $ssr->sc->update_tagData(); // ... $t4 = $ssr->sc->update_place_tagData(); // ... $t5 = $ds2->update_tagData(); // ... $t6 = $ds2->update_place_tagData(); // ... $swf->add_tagData($t1); // populate swf $swf->add_tagData($t2); // ... $swf->add_tagData($t3); // ... $swf->add_tagData($t4); // ... $swf->add_tagData($t5); // ... $swf->add_tagData($t6); // ... $swf->swf_output(); // save to disk $swfHeader = $swf->fetch_assoc(); // prepare to publish $str = render_swf_box($swfHeader, $imgDir, false); $str .= "<br/><strong>" .$swfFN ." created in :<br />" .SERVER_MKTMP ."</strong>"; ?>
masking is a technique for drawing shape or rendering image clipping in another shape. The way to mask is very similar to use drawing api as seen in sample #03, it differs by using set_mask and take care to the queue used to populate swf with tags. Object that will "mask" has item ID lower than the masked objects, but it must set a number of z-depth (the argument passed to set_mask) higher to the subsequents items id.