Implement logo & favicon generation

This commit is contained in:
2025-06-05 10:20:33 -04:00
parent 244b934be7
commit 597976b1b8
12 changed files with 314 additions and 5 deletions

42
logo.js Normal file
View File

@@ -0,0 +1,42 @@
import { createCanvas, registerFont } from 'canvas'
import fs from 'fs'
const cfg = {
width: 400,
height: 400,
fontPath: 'src/assets/font/obsidian/Obsidian-Roman.otf',
fontName: 'Obsidian',
fontWeight: 'bold',
fontSize: '350pt',
color: '#fffbe3',
background: '#111111',
text: 'g.',
yOffset: 115,
}
if ( cfg.fontPath ) {
registerFont(cfg.fontPath, { family: cfg.fontName })
}
const canvas = createCanvas(cfg.width, cfg.height)
const ctx = canvas.getContext('2d')
// set the background
ctx.fillStyle = cfg.background
ctx.fillRect(0, 0, cfg.width, cfg.height)
// set the font
ctx.font = `${cfg.fontWeight} ${cfg.fontSize} ${cfg.fontName}`
ctx.fillStyle = cfg.color
ctx.textAlign = 'center'
ctx.textBaseline = 'middle'
// add the text to the canvas
ctx.fillText(cfg.text, cfg.width / 2, cfg.yOffset)
// write out logo.png
const png = fs.createWriteStream('src/assets/logo/logo.png')
canvas.createPNGStream().pipe(png)
const jpg = fs.createWriteStream('src/assets/logo/logo.jpg')
canvas.createJPEGStream().pipe(jpg)