UNPKG

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