badge-icon
Create badge icon image
Why?
I want to set badge icon to an electron based Windows app. First of all I need to create such an icon, then invoke setOverlayIcon
of BrowserWindow
:
mainWndow.setOverlayIcon(electron.nativeImage.createFromPath('path-to-badge-icon-image'), 'badge description')
Install
yarn add badge-icon
import BadgeIcon from 'badge-icon'
Or you include it in your web page directly:
<script src="https://unpkg.com/badge-icon@0.1.0/dist/badge-icon.js"></script>
Samples
const icon8 = new BadgeIcon({
badgeWidth: 128,
badgeHeight: 128,
text: '8',
fontSize: 96,
color: 'white',
bgColor: 'red'
})
fs.writeFileSync('8.svg', icon8.svg())
const icon66 = new BadgeIcon({
badgeWidth: 128,
badgeHeight: 128,
text: '66',
fontSize: 64,
color: 'white',
bgColor: 'green'
})
fs.writeFileSync('66.svg', icon66.svg())
const icon99Plus = new BadgeIcon({
badgeWidth: 128,
badgeHeight: 64,
text: '99+',
fontSize: 48,
color: 'white',
bgColor: 'blue'
})
fs.writeFileSync('99+.svg', icon99Plus.svg())