improved image by making overlay transparent, fix #3

This commit is contained in:
Quentin Roussel
2024-10-14 18:09:04 +08:00
parent 9470548449
commit 30974eb85f

View File

@@ -6,14 +6,17 @@ async function overlayImage(time_string) {
let ctx = createCanvas(853, 479).getContext('2d'); let ctx = createCanvas(853, 479).getContext('2d');
let bg = await loadImage('bg.png') let bg = await loadImage('bg.png')
ctx.globalAlpha = 1;
ctx.drawImage(bg, 0, 0, 853, 479) ctx.drawImage(bg, 0, 0, 853, 479)
let overlay = await loadImage('images/raw/' + time_string + '.png') let overlay = await loadImage('images/raw/' + time_string + '.png')
ctx.globalAlpha = 0.6;
ctx.drawImage(overlay, 0, 0, 853, 479) ctx.drawImage(overlay, 0, 0, 853, 479)
let text = time_string.substring(8, 10) + ':' + time_string.substring(10, 12); let text = time_string.substring(8, 10) + ':' + time_string.substring(10, 12);
ctx.font = 'bold 70px sans-serif'; ctx.font = 'bold 70px sans-serif';
ctx.fillStyle = 'rgba(0,0,0,0.7)'; ctx.fillStyle = 'rgba(0,0,0,0.7)';
ctx.globalAlpha = 0.9;
ctx.fillText(text, 853 - 250, 479 - 40); ctx.fillText(text, 853 - 250, 479 - 40);
return ctx.canvas.toBuffer("image/png"); return ctx.canvas.toBuffer("image/png");