1234567891011121314151617181920212223242526272829303132333435 |
- const gm = require('gm')
- module.exports = {
- create(maxLength, value) {
- const path = require('path').join(__dirname, '/bar/')
- const bar = gm(path + 'dummy.png')
- .geometry('+0x16')
- .tile(maxLength)
- .transparent('white')
- if (value > 0) {
- bar.montage(path + 'bar-full-left.png')
- } else {
- bar.montage(path + 'bar-empty-left.png')
- }
- for (let i = 0; i < maxLength - 2; i++) {
- if (i <= value - 2) {
- bar.montage(path + 'bar-full-mid.png')
- } else {
- bar.montage(path + 'bar-empty-mid.png')
- }
- }
- if (maxLength <= value) {
- bar.montage(path + 'bar-full-right.png')
- } else {
- bar.montage(path + 'bar-empty-right.png')
- }
- return bar.stream('PNG')
- },
- }
|