badgen
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -1,5 +0,2 @@ | ||
// Generate on https://codesandbox.io/s/lr4ynm652m | ||
/* eslint-disable comma-spacing */ | ||
const Verdana12Widths = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4.2,4.7,5.5,9.8,7.6,13,8.7,3.2,5.4,5.4,7.6,9.8,4.4,5.4,4.4,5.4,7.6,7.6,7.6,7.6,7.6,7.6,7.6,7.6,7.6,7.6,5.4,5.4,9.8,9.8,9.8,6.5,12,8.2,8.2,8.4,9.2,7.6,6.9,9.3,9,5.1,5.5,8.3,6.7,10,9,9.4,7.2,9.4,8.3,8.2,7.4,8.8,8.2,12,8.2,7.4,8.2,5.4,5.4,5.4,9.8,7.6,7.6,7.2,7.5,6.3,7.5,7.1,4.2,7.5,7.6,3.3,4.1,7.1,3.3,12,7.6,7.3,7.5,7.5,5.1,6.3,4.7,7.6,7.1,9.8,7.1,7.1,6.3,7.6,5.4,7.6,9.8] | ||
const Verdana11Widths = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3.9,4.3,5,9,7,12,8,3,5,5,7,9,4,5,4,5,7,7,7,7,7,7,7,7,7,7,5,5,9,9,9,6,11,7.5,7.5,7.7,8.5,7,6.3,8.5,8.3,4.6,5,7.6,6.1,9.3,8.2,8.7,6.6,8.7,7.6,7.5,6.8,8.1,7.5,11,7.5,6.8,7.5,5,5,5,9,7,7,6.6,6.9,5.7,6.9,6.6,3.9,6.9,7,3,3.8,6.5,3,11,7,6.7,6.9,6.9,4.7,5.7,4.3,7,6.5,9,6.5,6.5,5.8,7,5,7,9] | ||
const widthsVerdana11 = require('./widths-verdana-11.json') | ||
@@ -26,4 +23,3 @@ function calcWidth (charWidthTable) { | ||
module.exports = { | ||
Verdana12: calcWidth(Verdana12Widths), | ||
Verdana11: calcWidth(Verdana11Widths) | ||
Verdana11: calcWidth(widthsVerdana11) | ||
} |
@@ -7,6 +7,4 @@ const calcWidth = require('./calc-text-width.js').Verdana11 | ||
const sbRectWidth = calcWidth(subject) + 10 | ||
const sbRectWidth = calcWidth(subject) + 11 | ||
const stRectWidth = calcWidth(status) + 11 | ||
const stTextStart = sbRectWidth + 5 | ||
const width = sbRectWidth + stRectWidth | ||
@@ -20,14 +18,16 @@ | ||
</linearGradient> | ||
<rect rx="3" width="${width}" height="20" fill="#${color}"/> | ||
<rect rx="3" x="0" width="${sbRectWidth}" height="20" fill="#555"/> | ||
<path fill="#555" d="M${sbRectWidth} 0v20h-4v-20h4z"/> | ||
<rect rx="3" width="${width}" height="20" fill="url(#a)"/> | ||
<g fill="#fff" text-anchor="start" font-family="DejaVu Sans,Verdana,sans-serif" font-size="11"> | ||
<text x="6" y="14.8" fill="#000" opacity="0.2">${subject}</text> | ||
<text x="5" y="13.8">${subject}</text> | ||
<text x="${stTextStart + 1}" y="14.8" fill="#000" opacity="0.2">${status}</text> | ||
<text x="${stTextStart}" y="13.8">${status}</text> | ||
</g><script/> | ||
<mask id="m"><rect width="${width}" height="20" rx="3" fill="#FFF"/></mask> | ||
<g mask="url(#m)"> | ||
<rect width="${sbRectWidth}" height="20" fill="#555"/> | ||
<rect x="${sbRectWidth}" width="${stRectWidth}" height="20" fill="#${color}"/> | ||
<rect width="${width}" height="20" fill="url(#a)"/> | ||
</g> | ||
<g fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="11"> | ||
<text x="7" y="14.8" fill="#000" opacity="0.25">${subject}</text> | ||
<text x="6" y="13.8">${subject}</text> | ||
<text x="${sbRectWidth + 5.5}" y="14.8" fill="#000" opacity="0.25">${status}</text> | ||
<text x="${sbRectWidth + 4.5}" y="13.8">${status}</text> | ||
</g> | ||
</svg> | ||
` | ||
} |
{ | ||
"name": "badgen", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "Hand-crafted badge generator.", | ||
@@ -5,0 +5,0 @@ "author": "Amio <amio.cn@gmail.com>", |
@@ -45,3 +45,2 @@ # badgen [![npm-version][npm-badge]][npm-link] [![install size][pp-badge]][pp-link] | ||
```bash | ||
generate by short params x 1,085,052 ops/sec ±1.03% (83 runs sampled) | ||
generate by long params x 1,046,942 ops/sec ±0.61% (93 runs sampled) | ||
@@ -48,0 +47,0 @@ generate by full params x 1,266,881 ops/sec ±0.76% (91 runs sampled) |
7
5223
65
59