$swf->SetBackgroundColor(255, 255, 255); $swf->BeginMovie(); function rgbConvert($rgb_str) { $rgb = $rgb_str; $rgb = str_replace("rgb(", "", $rgb); $rgb = str_replace(")", "", $rgb); $rgbArray = explode(",", $rgb); return $rgbArray; } $totalSWFObjects = 0; foreach ($xml->svg as $svg) { if ($svg['t'] != 'f') { if ($charid != null || $chardepth != null) { for ($p = 0; $p <= $totalSWFObjects - 1; $p++) { $swf->RemoveObjectFromLayer($charid[$p], $chardepth[$p]); } } } foreach ($svg->line as $line) { $linefillColor = rgbConvert($line['stroke']); $CharacterInfo = $swf->DefineStraightLine($line['x1'] * 20, $height * 20 - $line['y1'] * 20, $line['x2'] * 20, $height * 20 - $line['y2'] * 20, $line['stroke-width'] * 20, false, $linefillColor[0], $linefillColor[1], $linefillColor[2], 0); $CharacterDepth = $swf->EasyPlaceObject($CharacterInfo["CharacterID"]); $charid[$totalSWFObjects] = $CharacterInfo["CharacterID"]; $chardepth[$totalSWFObjects] = $CharacterDepth; $totalSWFObjects++; } foreach ($svg->rect as $rect) { $rectfillColor = rgbConvert($rect['fill']); $rectlineColor = rgbConvert($rect['stroke']); $CharacterInfo = $swf->DefineRectangleSolid($rect['x'] * 20, $height * 20 - $rect['y'] * 20, $rect['x'] * 20 + $rect['width'] * 20, $height * 20 - ($rect['y'] * 20 + $rect['height'] * 20), $rect['stroke-width'] * 2, false, true, $rectlineColor[0], $rectlineColor[1], $rectlineColor[2], 255, true, $rectfillColor[0], $rectfillColor[1], $rectfillColor[2], 255);
include "../lib/freemoviecompilertoolbox.php"; //include "test.php"; $swf = new FreeMovieCompilerToolbox(); $cwidth = 480; $cheight = 272; $swf->SetSWFVersion(5); $swf->SetFrameSize($cwidth * 20, $cheight * 20); // = 800 x 20, 600 x 20 $swf->SetFrameRate(12.0); $swf->SetBackgroundColor(255, 255, 255); $animation_array = json_decode(stripslashes($_REQUEST["animation"]), true); $previous_id_array = array(); $previous_depth_array = array(); foreach ($animation_array as $frame_contents) { for ($p = 0; $p < count($previous_depth_array); $p++) { $swf->RemoveObjectFromLayer($previous_id_array[$p], $previous_depth_array[$p]); } $previous_id_array = array(); $previous_depth_array = array(); foreach ($frame_contents as $shape) { switch ($shape["type"]) { case "rect": case "roundrect": $x1 = $shape["left"]; $y1 = $cheight - $shape["top"]; $x2 = $shape["left"] + $shape["width"]; $y2 = $cheight - ($shape["top"] + $shape["height"]); $lw = $shape["lineWidth"]; $fillArray = sscanf($shape['fillColor'], '#%2x%2x%2x'); $strokeArray = sscanf($shape['lineColor'], '#%2x%2x%2x'); $CharacterInfo = $swf->DefineRectangleSolid($x1 * 20, $y1 * 20, $x2 * 20, $y2 * 20, $lw * 20, false, true, $strokeArray[0], $strokeArray[1], $strokeArray[2], 255, true, $fillArray[0], $fillArray[1], $fillArray[2], $fillArray[3]);