Keep text centered in canvas
This commit is contained in:
parent
41508af91e
commit
23a96ff6cd
@ -37,7 +37,9 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
}
|
||||
// Draw instrument ID as text
|
||||
ctx.font = '48px sans-serif';
|
||||
ctx.fillText(idInstr, 45, 350);
|
||||
const txtWidth = Math.round(ctx.measureText(idInstr).width);
|
||||
const txtLeftDist = (200 - txtWidth) / 2 + 25;
|
||||
ctx.fillText(idInstr, txtLeftDist, 350);
|
||||
|
||||
erihsLogo.onload = () => {
|
||||
ctx.drawImage(erihsLogo, 25, 375, 200, 41)
|
||||
|
Loading…
Reference in New Issue
Block a user