UNPKG

1.28 kBJavaScriptView Raw
1/**
2 * Define theme "h".
3 * @function h
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'use strict'
11
12const _svg = require('./_svg')
13const numcal = require('numcal')
14
15/** @lends h */
16function h (width, height, color1, color2) {
17 let r = numcal.min(height, width)
18 let lineWidth = numcal.min(width, height) * 0.05
19
20 return _svg(width, height, {
21 rect: [
22 {
23 '@': {
24 x: 0,
25 y: 0,
26 rx: r,
27 ry: r,
28 width: width,
29 height: height,
30 fill: color2
31 }
32 },
33 {
34 '@': {
35 x: lineWidth / 2,
36 y: lineWidth / 2,
37 rx: r,
38 ry: r,
39 width: width - lineWidth,
40 height: height - lineWidth,
41 fill: 'none',
42 'stroke-width': lineWidth,
43 stroke: color1
44 }
45 },
46 {
47 '@': {
48 x: lineWidth * 2,
49 y: lineWidth * 2,
50 rx: r,
51 ry: r,
52 width: width - lineWidth * 4,
53 height: height - lineWidth * 4,
54 fill: color1
55 }
56 }
57 ]
58 })
59}
60
61h.$reversed = false
62
63module.exports = h