Exemple #1
0
 public function saveDeliveryContent($directory, $image_as_svg = false)
 {
     if (!file_exists($directory)) {
         mkdir($directory, 0775);
     }
     file_put_contents($directory . '/index.json', json_encode($this->stage->convertArray()));
     if (!file_exists($directory . "/defines")) {
         mkdir($directory . "/defines", 0775);
     }
     $excules = $image_as_svg ? array(Media_SWF_Tag::DEFINE_SPRITE) : false;
     // Shapes
     $frameSize = $this->stage->getHeader('FrameSize');
     $defsList = $this->stage->getSVGDefinitions($excules);
     foreach ($defsList as $savedName => $defs) {
         $svg = new Media_SVG($frameSize['Xmax'], $frameSize['Ymax']);
         $svg->addNode($defs);
         file_put_contents($directory . '/' . $savedName, $svg->toString($this->stage->saveWithCompress));
         $svg = null;
     }
     // for canvas
     // file_put_contents($directory.'/shapes.json', json_encode($defs->createArray()));
     // JSON
     $defsList = $this->stage->getArrayDefinitions();
     foreach ($defsList as $savedName => $defs) {
         file_put_contents($directory . '/' . $savedName, json_encode($defs));
     }
     // Resouce
     foreach ($this->stage->getResourceTags() as $tag) {
         $image = $tag->convertImageData();
         file_put_contents($directory . '/defines/' . $tag->getElementIdString() . '.' . $tag->filetype, $image);
     }
     return true;
 }
 public function saveAsSVG($filename = null)
 {
     $bounds = $this->getField('ShapeBounds');
     $svg_element = $this->convertSVG();
     $width = $bounds['Xmax'] - $bounds['Xmin'];
     $height = $bounds['Ymax'] - $bounds['Ymin'];
     $x = -$bounds['Xmin'];
     $y = -$bounds['Ymin'];
     $svg = new Media_SVG($width / 20 + 10, $height / 20 + 10);
     $svg->addNode(Media_SVG::newElement('Group')->set('transform', array('translate' => array($x / 20 + 5, $y / 20 + 5), 'scale' => array('0.05')))->addNode($svg_element));
     if ($filename) {
         return true;
     } else {
         return $svg->toString();
     }
 }
Exemple #3
0
 public function convertSVG()
 {
     $frameSize = $this->getHeader('FrameSize');
     $frameRate = $this->getHeader('FrameRate');
     $frameCount = $this->getHeader('FrameCount');
     $svg = new Media_SVG($frameSize['Xmax'] / 20, $frameSize['Ymax'] / 20);
     //$defs = Media_SVG::newElement('defs');
     // Definition
     $defs = $this->getSVGDefinitions(array());
     $display = parent::convertSVG();
     foreach ($defs as $def) {
         $svg->addNode($def);
     }
     $svg->addNode($display->set('transform', 'scale(0.05)'));
     return $svg;
 }