public function getData($fragment = false)
    {
        $svg = '';
        $widthAsString = number_format($this->width, 0, '.', '');
        $heightAsString = number_format($this->height, 0, '.', '');
        
        if (!$fragment) {
            $svg .= '<svg xmlns="http://www.w3.org/2000/svg" width="' .
                $widthAsString .'" height="'. $heightAsString .'" viewBox="0 0 '.
                $widthAsString .' '. $heightAsString .
                '" preserveAspectRatio="xMidYMid meet">';
        }

        if ($this->backgroundColor->a > 0) {
            $opacity = (float)$this->backgroundColor->a / 255;
            $svg .= '<rect fill="'. $this->backgroundColor->toHexString(6) .
                '" fill-opacity="'. number_format($opacity, 2, '.', '').
                '" x="0" y="0" width="'. $widthAsString .'" height="'. 
                $heightAsString .'"/>';
        }
        
        foreach ($this->pathsByColor as $color => $path) {
            $svg .= "<path fill=\"$color\" d=\"$path\"/>";
        }

        if (!$fragment) {
            $svg .= '</svg>';
        }
        
        return $svg;
    }
public function getData($fragment = false)
    {
        $svg = '';
        $widthAsString = number_format($this->width, 0, '.', '');
        $heightAsString = number_format($this->height, 0, '.', '');
        
        if (!$fragment) {
            $svg .= '<svg xmlns="http://www.w3.org/2000/svg" width="' .
                $widthAsString .'" height="'. $heightAsString .'" viewBox="0 0 '.
                $widthAsString .' '. $heightAsString .
                '" preserveAspectRatio="xMidYMid meet">';
        }

        if ($this->backgroundColor->a > 0) {
            $opacity = (float)$this->backgroundColor->a / 255;
            $svg .= '<rect fill="'. $this->backgroundColor->toHexString(6) .
                '" fill-opacity="'. number_format($opacity, 2, '.', '').
                '" x="0" y="0" width="'. $widthAsString .'" height="'. 
                $heightAsString .'"/>';
        }
        
        foreach ($this->pathsByColor as $color => $path) {
            $svg .= "<path fill=\"$color\" d=\"$path\"/>";
        }

        if (!$fragment) {
            $svg .= '</svg>';
        }
        
        return $svg;
    }
public function getData ( $ fragment = false ) { $ svg = '' ; $ widthAsString = number_format ( $ this -> width , 0 , '.' , '' ) ; $ heightAsString = number_format ( $ this -> height , 0 , '.' , '' ) ; if ( ! $ fragment ) { $ svg .= '<svg xmlns="http://www.w3.org/2000/svg" width="' . $ widthAsString . '" height="' . $ heightAsString . '" viewBox="0 0 ' . $ widthAsString . ' ' . $ heightAsString . '" preserveAspectRatio="xMidYMid meet">' ; } if ( $ this -> backgroundColor -> a > 0 ) { $ opacity = ( float ) $ this -> backgroundColor -> a / 255 ; $ svg .= '<rect fill="' . $ this -> backgroundColor -> toHexString ( 6 ) . '" fill-opacity="' . number_format ( $ opacity , 2 , '.' , '' ) . '" x="0" y="0" width="' . $ widthAsString . '" height="' . $ heightAsString . '"/>' ; } foreach ( $ this -> pathsByColor as $ color => $ path ) { $ svg .= "<path fill=\"$color\" d=\"$path\"/>" ; } if ( ! $ fragment ) { $ svg .= '</svg>' ; } return $ svg ; }
Generates an SVG string of the renderer output.

@param bool $fragment If true an SVG string without the root svg element
will be rendered.
Generates an SVG string of the renderer output .