Returns svg representation of an instance
@method toSVG
@return {string} svg representation of an instance
428100
function() {

      var textLines = this.text.split(/\r?\n/),
          lineTopOffset = this.useNative
            ? this.fontSize * this.lineHeight
            : (-this._fontAscent - ((this._fontAscent / 5) * this.lineHeight)),

          textLeftOffset = -(this.width/2),
          textTopOffset = this.useNative
            ? this.fontSize - 1
            : (this.height/2) - (textLines.length * this.fontSize) - this._totalLineHeight,

          textAndBg = this._getSVGTextAndBg(lineTopOffset, textLeftOffset, textLines),
          shadowSpans = this._getSVGShadows(lineTopOffset, textLines);

      // move top offset by an ascent
      textTopOffset += (this._fontAscent ? ((this._fontAscent / 5) * this.lineHeight) : 0);

      return [
        '<g transform="', this.getSvgTransform(), '">',
          textAndBg.textBgRects.join(''),
          '<text ',
            (this.fontFamily ? 'font-family="\'' + this.fontFamily + '\'" ': ''),
            (this.fontSize ? 'font-size="' + this.fontSize + '" ': ''),
            (this.fontStyle ? 'font-style="' + this.fontStyle + '" ': ''),
            (this.fontWeight ? 'font-weight="' + this.fontWeight + '" ': ''),
            (this.textDecoration ? 'text-decoration="' + this.textDecoration + '" ': ''),
            'style="', this.getSvgStyles(), '" ',
            /* svg starts from left/bottom corner so we normalize height */
            'transform="translate(', toFixed(textLeftOffset, 2), ' ', toFixed(textTopOffset, 2), ')">',
            shadowSpans.join(''),
            textAndBg.textSpans.join(''),
          '</text>',
        '</g>'
      ].join('');
    }
598123
function convertSVGToPNG(source, dest, options) {
    if (!fs.existsSync(source)) return Promise.reject(new error.FileNotFoundError({ filename: source }));

    return command.spawn('svgexport', [source, dest])
    .fail(function(err) {
        if (err.code == 'ENOENT') {
            err = error.RequireInstallError({
                cmd: 'svgexport',
                install: 'Install it using: "npm install svgexport -g"'
            });
        }
        throw err;
    })
    .then(function() {
        if (fs.existsSync(dest)) return;

        throw new Error('Error converting '+source+' into '+dest);
    });
}
1178521
function() {

    var matrix = (this.attr('transform') || '')
      // split transformations
      .split(/\)\s*/).slice(0,-1).map(function(str){
        // generate key => value pairs
        var kv = str.trim().split('(')
        return [kv[0], kv[1].split(SVG.regex.matrixElements).map(function(str){ return parseFloat(str) })]
      })
      // calculate every transformation into one matrix
      .reduce(function(matrix, transform){

        if(transform[0] == 'matrix') return matrix.multiply(arrayToMatrix(transform[1]))
        return matrix[transform[0]].apply(matrix, transform[1])

      }, new SVG.Matrix())

    return matrix
  }
320729
function svdPack() {
                var result = lapack$1.sgesvd('A', 'A', this.elements);

                return {
                    U: $M(result.U),
                    S: $M(result.S).column(1).toDiagonalMatrix(),
            	V: $M(result.VT).transpose()
                };
            }
707274
function optimizeSVGs(src) {
  const startOptimizeTaskName = swlog.logSubStart('optimize SVGs');

  // Optimize with svgo:
  const svgoOptimize = new svgo({
    js2svg: { useShortTags: false },
    plugins: [
      { removeViewBox: false },
      { convertColors: { currentColor: '#000000' }},
      { removeDimensions: true },
      { moveGroupAttrsToElems: true },
      { removeUselessStrokeAndFill: true },
      { customSvgoRemoveGroupFill },
      { customSvgoNonScalingStroke },
      { customSvgoFillStroke }
    ]
  });

  const svgFiles = glob.sync(`${src}/*.svg`);

  // Divide each optimization into a promise
  const svgPromises = svgFiles.map(async filepath => {
    try {
      const data = await readFile(filepath, 'utf8');
      const dataOptimized = await svgoOptimize.optimize(data);

      await writeFile(filepath, dataOptimized.data, 'utf-8');
    } catch(err) {
      swlog.error(err);
    }
  });

  return Promise.all(svgPromises).then(() => {
    swlog.logSubEnd(startOptimizeTaskName);
  }).catch(swlog.error);
}
395256
function() {
      var chunks = [];
      for (var i = 0, len = this.path.length; i < len; i++) {
        chunks.push(this.path[i].join(' '));
      }
      var path = chunks.join(' ');

      return [
        '<g transform="', this.getSvgTransform(), '">',
          '<path ',
            'width="', this.width, '" height="', this.height, '" ',
            'd="', path, '" ',
            'style="', this.getSvgStyles(), '" ',
            'transform="translate(', (-this.width / 2), ' ', (-this.height/2), ')" />',
        '</g>'
      ].join('');
    }
39266
function convertSVGBufferToPNG(buf, dest) {
    // Create a temporary SVG file to convert
    return fs.tmpFile({
        postfix: '.svg'
    })
    .then(function(tmpSvg) {
        return fs.writeFile(tmpSvg, buf)
        .then(function() {
            return convertSVGToPNG(tmpSvg, dest);
        });
    });
}
398087
def fig_to_svg(fig):
    
    buf = io.StringIO()
    fig.savefig(buf, format='svg')
    buf.seek(0)
    return buf.getvalue()
1173803
def svg
      if self.svg_id.nil?
       svg = obconversion(smiles,"smi","svg")
       file = Mongo::Grid::File.new(svg, :filename => "#{id}.svg", :content_type => "image/svg")
       update(:svg_id => $gridfs.insert_one(file))
      end
      $gridfs.find_one(_id: self.svg_id).data
    end
723755
def graph_to_svg(graph):
    

    import tempfile
    import subprocess
    with tempfile.NamedTemporaryFile() as dot_file:
        nx.drawing.nx_agraph.write_dot(graph, dot_file.name)
        svg = subprocess.check_output(['dot', dot_file.name, '-Tsvg'])
    return svg
118954
function convert ({ prefix, base, svg }) {
  const data = process(svg, { prefix })

  return dedent`
    @function ${prefix}-${base}-image($color: #000000) {
      @return url(${JSON.stringify(data)});
    }

    @mixin ${prefix}-${base}($size: 16px, $color: #000000) {
      @include ${prefix}-base;
      background: ${prefix}-${base}-image($color) center center / $size $size no-repeat;
      height: $size;
      width: $size;
    }
  `
}
605449
def extract_svg(display_object, dpi=300, compress='auto'):
    
    image_svg = svg2str(display_object, dpi)
    if compress is True or compress == 'auto':
        image_svg = svg_compress(image_svg, compress)
    image_svg = re.sub(' height="[0-9]+[a-z]*"', '', image_svg, count=1)
    image_svg = re.sub(' width="[0-9]+[a-z]*"', '', image_svg, count=1)
    image_svg = re.sub(' viewBox',
                       ' preseveAspectRation="xMidYMid meet" viewBox',
                       image_svg, count=1)
    start_tag = '<svg '
    start_idx = image_svg.find(start_tag)
    end_tag = '</svg>'
    end_idx = image_svg.rfind(end_tag)
    if start_idx is -1 or end_idx is -1:
        NIWORKFLOWS_LOG.info('svg tags not found in extract_svg')
    # rfind gives the start index of the substr. We want this substr
    # included in our return value so we add its length to the index.
    end_idx += len(end_tag)
    return image_svg[start_idx:end_idx]
1282200
public function svgForHtml5()
    {
        $arr_svg = array();
        $arr_svg[] = sprintf('<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="%1$d" height="%1$d">', $this->size);
        $arr_svg[] = sprintf('<title>Identicon of %s</title>', $this->seed->str);
        $arr_svg[] = sprintf('<desc>The hash string used to generate this identicon is %s.</desc>', $this->seed->hash);

        $arr_svg[] = sprintf(
            '<g transform="scale(%f)">',
            $this->size / self::SIZE
        );

        foreach ($this->arr_quarters as $k => $q) {
            $arr_svg[] = $q->svg();
        }
        $arr_svg[] = '</g>';
        $arr_svg[] = '</svg>';

        $str_svg = implode("\n", $arr_svg);

        return $str_svg;
    }
925076
public function svg()
    {
        $str_g = '';

        foreach ($this->arr_units as $k => $u) {
            $int_dx = 0;
            $int_dy = 0;

            if ($k == self::TOP_RIGHT) {
                $int_dx = Unit::SIZE;
            } elseif ($k == self::BOTTOM_RIGHT) {
                $int_dx = Unit::SIZE;
                $int_dy = Unit::SIZE;
            } elseif ($k == self::BOTTOM_LEFT) {
                $int_dy = Unit::SIZE;
            }

            $str_attr_translate = sprintf(
                ' transform="translate(%d, %d)"',
                $int_dx,
                $int_dy
            );

            if ($int_dx || $int_dy) {
                $str_g .= sprintf('<g%s>%s</g>', $str_attr_translate, $u->svg()) . "\n";
            } else {
                $str_g .= $u->svg() . "\n";
            }
        }

        $str_attr = '';

        if ($this->type != self::TOP_LEFT) {
            $int_dx = 0;
            $int_dy = 0;

            if ($this->type == self::TOP_RIGHT) {
                $int_dx = self::SIZE;
            } elseif ($this->type == self::BOTTOM_RIGHT) {
                $int_dx = self::SIZE;
                $int_dy = self::SIZE;
            } elseif ($this->type == self::BOTTOM_LEFT) {
                $int_dy = self::SIZE;
            }

            $int_way = $this->bool_rotate_way ? -1 : 1;
            $str_attr = sprintf(
                ' transform="translate(%d, %d) rotate(%d, %d, %d)"',
                $int_dx,
                $int_dy,
                $this->type * 90 * $int_way,
                Unit::SIZE,
                Unit::SIZE
            );
        }

        return sprintf(
            '<g id="quarter-%d"%s>%s</g>'."\n",
            $this->type,
            $str_attr,
            $str_g
        );
    }
1041329
function toSvg(name, attrs = {}) {
  console.warn(
    'feather.toSvg() is deprecated. Please use feather.icons[name].toSvg() instead.',
  );

  if (!name) {
    throw new Error('The required `key` (icon name) parameter is missing.');
  }

  if (!icons[name]) {
    throw new Error(
      `No icon matching '${
        name
      }'. See the complete list of icons at https://feathericons.com`,
    );
  }

  return icons[name].toSvg(attrs);
}
604158
function svgToImg(baseFolder, currentFile, $) {
    var currentDirectory = path.dirname(currentFile);

    return editHTMLElement($, 'svg', function($svg) {
        var content = '<?xml version="1.0" encoding="UTF-8"?>' +
            renderDOM($, $svg);

        // We avoid generating twice the same PNG
        var hash = crc.crc32(content).toString(16);
        var fileName = hash + '.svg';
        var filePath = path.join(baseFolder, fileName);

        // Write the svg to the file
        return fs.assertFile(filePath, function() {
            return fs.writeFile(filePath, content, 'utf8');
        })

        // Return as image
        .then(function() {
            var src = LocationUtils.relative(currentDirectory, fileName);
            $svg.replaceWith('<img src="' + src + '" />');
        });
    });
}
392667
function getSvgHeight (svg, filename) {
  const parseSvg = /<svg[^>]+height\s*=\s*["']?(\d+)\s*(pt|px|)["']?/i.exec(svg);
  if (!parseSvg) {
    throw new Error(`could not read height for '${filename}'.`);
  }
  return parseSvg[1];
}