UNPKG

1.03 kBJavaScriptView Raw
1/**
2 * Define theme "i".
3 * @function i
4 * @param {number} width - Image width
5 * @param {number} height - Image height
6 * @param {string} color1 - Shape color 1.
7 * @param {string} color2 - Shape color 2.
8 * @returns {string} - SVG string.
9 */
10
11const _svg = require('./_svg')
12const numcal = require('numcal')
13
14/** @lends i */
15function i (width, height, color1, color2) {
16 let r = numcal.min(height, width)
17 let lineWidth = numcal.min(width, height) * 0.05
18
19 return _svg(width, height, {
20 rect: [
21 {
22 '@': {
23 x: 0,
24 y: 0,
25 rx: r,
26 ry: r,
27 width: width,
28 height: height,
29 fill: color2
30 }
31 },
32 {
33 '@': {
34 x: lineWidth / 2,
35 y: lineWidth / 2,
36 rx: r,
37 ry: r,
38 width: width - lineWidth,
39 height: height - lineWidth,
40 fill: 'none',
41 'stroke-width': lineWidth,
42 stroke: color1
43 }
44 }
45 ]
46 })
47}
48
49i.$reversed = true
50
51module.exports = i