Change label proportions

This commit is contained in:
2023-08-29 15:54:49 +02:00
parent 23a96ff6cd
commit ecc60460b9
4 changed files with 14 additions and 8 deletions

View File

@@ -9,7 +9,11 @@ document.addEventListener('DOMContentLoaded', () => {
const ctx = canvas.getContext('2d');
ctx.clearRect(0,0,canvas.width, canvas.height);
ctx.fillStyle = "#333";
const txtColor = "#000";
const qrWidth = 220;
const leftMargin = 12;
ctx.fillStyle = txtColor;
// Prepare img elements
const qrImg = new Image();
@@ -28,21 +32,21 @@ document.addEventListener('DOMContentLoaded', () => {
// Draw images
ispcLogo.onload = () => {
ctx.drawImage(ispcLogo, 25, 30, 200, 75)
ctx.drawImage(ispcLogo, leftMargin, 10, 200, 75)
}
qrImg.src = qr.toDataURL();
qrImg.onload = () => {
ctx.drawImage(qrImg, 25, 110, 200, 200)
ctx.drawImage(qrImg, leftMargin, 90, qrWidth, qrWidth)
}
// Draw instrument ID as text
ctx.font = '48px sans-serif';
const txtWidth = Math.round(ctx.measureText(idInstr).width);
const txtLeftDist = (200 - txtWidth) / 2 + 25;
ctx.fillText(idInstr, txtLeftDist, 350);
const txtLeftDist = (220 - txtWidth) / 2 + leftMargin;
ctx.fillText(idInstr, txtLeftDist, 352);
erihsLogo.onload = () => {
ctx.drawImage(erihsLogo, 25, 375, 200, 41)
ctx.drawImage(erihsLogo, 20, 370, 210, 41)
}
download.classList.remove('disabled');
});