show tape margin

This commit is contained in:
Robin Appelman 2025-10-06 21:54:21 +02:00
commit d0ac275e77
3 changed files with 19 additions and 2 deletions

View file

@ -1,6 +1,7 @@
const elementsTable = document.getElementById('elements');
/** @type HTMLCanvasElement preview */
const preview = document.getElementById('preview');
const tapeDiv = document.getElementById('tape');
const renderCtx = preview.getContext("2d");
const elementsTableBody = elementsTable.getElementsByTagName('tbody')[0];
const addTextButton = document.getElementById('add-text');
@ -244,6 +245,13 @@ fetch(apiRoot + '/status')
backgroundColor = status.tape_color;
textColor = status.text_color;
tapeWidthMM = status.media_width;
const pxPerMM = preview.height / tapeWidthMM;
const marginPx = status.margin_width * pxPerMM;
tapeDiv.style.padding = `${marginPx}px 0`;
tapeDiv.style.height = `${status.pixel_width}px`;
render();
addTextElement();
})