Exemplo n.º 1
0
 static function string($shapeRecords, $opts = array())
 {
     $tagCode = $opts['tagCode'];
     if (isset($opts['indent'])) {
         $indent_text = '';
         for ($i = 0; $i < $opts['indent']; $i++) {
             $indent_text .= "\t";
             // str_pad? str_repeat ?
         }
     } else {
         $indent_text = "\t";
     }
     $text = '';
     foreach ($shapeRecords as $shapeRecord) {
         $text .= $indent_text;
         $typeFlag = $shapeRecord['TypeFlag'];
         if ($typeFlag == 0) {
             if (isset($shapeRecord['EndOfShape'])) {
                 $text .= "EndOfShape";
             } else {
                 $moveX = $shapeRecord['MoveX'] / 20;
                 $moveY = $shapeRecord['MoveY'] / 20;
                 $text .= "ChangeStyle: MoveTo: ({$moveX}, {$moveY})";
                 $style_list = array('FillStyle0', 'FillStyle1', 'LineStyle');
                 $text .= "  FillStyle: " . $shapeRecord['FillStyle0'] . "|" . $shapeRecord['FillStyle1'];
                 $text .= "  LineStyle: " . $shapeRecord['LineStyle'];
                 if (isset($shapeRecord['FillStyles']) || isset($shapeRecord['LineStyles'])) {
                     // NewStyle
                     $text .= "\n";
                     if (isset($shapeRecord['FillStyles'])) {
                         $text .= "    FillStyles:\n";
                         $text .= IO_SWF_Type_FILLSTYLEARRAY::string($shapeRecord['FillStyles'], $opts);
                     }
                     if (isset($shapeRecord['LineStyles'])) {
                         $text .= "    LineStyles:\n";
                         $text .= IO_SWF_Type_LINESTYLEARRAY::string($shapeRecord['LineStyles'], $opts);
                     }
                 }
             }
         } else {
             $straightFlag = $shapeRecord['StraightFlag'];
             if ($straightFlag) {
                 $x = $shapeRecord['X'] / 20;
                 $y = $shapeRecord['Y'] / 20;
                 $text .= "StraightEdge: MoveTo: ({$x}, {$y})";
             } else {
                 $controlX = $shapeRecord['ControlX'] / 20;
                 $controlY = $shapeRecord['ControlY'] / 20;
                 $anchorX = $shapeRecord['AnchorX'] / 20;
                 $anchorY = $shapeRecord['AnchorY'] / 20;
                 $text .= "CurvedEdge: MoveTo: Control({$controlX}, {$controlY}) Anchor({$anchorX}, {$anchorY})";
             }
         }
         if (substr($text, -1) != PHP_EOL) {
             $text .= PHP_EOL;
         }
     }
     return $text;
 }
Exemplo n.º 2
0
 function buildContent($tagCode, $opts = array())
 {
     $isMorph = $tagCode == 46 || $tagCode == 84;
     $writer = new IO_Bit();
     if (empty($opts['noShapeId'])) {
         $writer->putUI16LE($this->_shapeId);
     }
     $opts = array('tagCode' => $tagCode);
     if ($isMorph === false) {
         IO_SWF_Type_RECT::build($writer, $this->_shapeBounds);
         // 描画スタイル
         IO_SWF_Type_FILLSTYLEARRAY::build($writer, $this->_fillStyles, $opts);
         IO_SWF_Type_LINESTYLEARRAY::build($writer, $this->_lineStyles, $opts);
         // 描画枠
         $opts['fillStyleCount'] = count($this->_fillStyles);
         $opts['lineStyleCount'] = count($this->_lineStyles);
         IO_SWF_Type_SHAPE::build($writer, $this->_shapeRecords, $opts);
     } else {
         IO_SWF_Type_RECT::build($writer, $this->_startBounds);
         IO_SWF_Type_RECT::build($writer, $this->_endBounds);
         $writer->byteAlign();
         list($offset_offset, $dummy) = $writer->getOffset();
         $this->_offset = $writer->putUI32LE(0);
         // at first, write dummy
         // 描画スタイル
         IO_SWF_Type_FILLSTYLEARRAY::build($writer, $this->_morphFillStyles, $opts);
         IO_SWF_Type_LINESTYLEARRAY::build($writer, $this->_morphLineStyles, $opts);
         // 描画枠
         $opts['fillStyleCount'] = count($this->_morphFillStyles);
         $opts['lineStyleCount'] = count($this->_morphLineStyles);
         // StartEdge
         IO_SWF_Type_SHAPE::build($writer, $this->_startEdge, $opts);
         // EndEdge
         $writer->byteAlign();
         list($end_edge_offset, $dummy) = $writer->getOffset();
         $this->_offset = $end_edge_offset - $offset_offset - 4;
         $writer->setUI32LE($this->_offset, $offset_offset);
         IO_SWF_Type_SHAPE::build($writer, $this->_endEdge, $opts);
     }
     return $writer->output();
 }