UNPKG

633 BJavaScriptView Raw
1/**
2 * SVG XML.
3 * @function _svg
4 * @param {number} width - Image width
5 * @param {number} height - Image height
6 * @param {object} contents - SVG contents data
7 * @returns {string} - SVG XML string.
8 */
9
10'use strict'
11
12const stringcase = require('stringcase')
13const randomval = require('randomval')
14
15/** @lends _svg */
16function _svg (width, height, contents) {
17 return {
18 '@': {
19 id: 'fur-shape-' + randomval.randomHash(),
20 xmlns: 'http://www.w3.org/2000/svg',
21 width: width,
22 height: height,
23 viewbox: [
24 0, 0, width, height
25 ].join(' ')
26 },
27 g: contents
28 }
29}
30
31module.exports = _svg