<?php include("sample_utils.php"); // provides some utils and using mk $sc = new MKshape_container(); // the shape, default shapeID is 1 $sc->add_lineStyle(); // default value is 1px line width and #000000 color $sc->add_rect(10, 10, 300, 200); // a simple rectangle from x,y and width,height $sd = $sc->update_tagData(); // get shape tag $po = $sc->update_place_tagData(); // get placing data $swf = new MKswf("test_draw01.swf"); // start a fresh swf $swf->set_swfDir(SERVER_MKTMP); // change default working dir $swf->set_backgroundColor("#EEEEFF"); // set background color $swf->add_tagData($sd); // populate with shape $swf->add_tagData($po); // place on stage $swf->swf_output(); // save to disk $swfHeader = $swf->fetch_assoc(); $str = render_swf_box($swfHeader, $imgDir, false); $str .= "<br/><strong>test_draw01.swf created in" .SERVER_MKTMP ."</strong>"; ?>
to draw in an swf like you have a sketch pad is one of the features of mk.
All you have to do is instantiate an MKshape_container class and populate it using its several drawing methods. It supports simple primitives such rectangles, circles and ellipses, single straight/bezier line and little bit more complex figures such are irregular shapes, polygons and stars.
You may add fill color style and line width/color, gradient fills and bitmap fills that you have seen in sample #07.
The concept behind drawing in mk is simple (at least it is what I hope), but there are some issues related to the way that flash supports fills and line styles.
When drawing you must add a fill style o line style or both. Next drawing shape you will add (all mk drawing methods begin with "add_") will use last fill/line settings. In the next sample #09 we will see how to draw many "holed" figures.
![]()