UNPKG

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