mirror of
https://codeberg.org/icewind/ptouch-api.git
synced 2026-06-03 19:04:08 +02:00
show tape margin
This commit is contained in:
parent
4c4a9119b3
commit
d0ac275e77
3 changed files with 19 additions and 2 deletions
|
|
@ -28,10 +28,12 @@
|
||||||
<option value="mm">mm</option>
|
<option value="mm">mm</option>
|
||||||
</select>
|
</select>
|
||||||
</p>
|
</p>
|
||||||
<canvas id="preview" height="32" width="300"></canvas>
|
<div id='tape'>
|
||||||
|
<canvas id="preview" height="32" width="300"></canvas>
|
||||||
|
</div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<input type="button" value="Print" id="print"/>
|
<input type="button" value="Print" id="print"/>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<script src="label.js"></script>
|
<script src="label.js"></script>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
const elementsTable = document.getElementById('elements');
|
const elementsTable = document.getElementById('elements');
|
||||||
/** @type HTMLCanvasElement preview */
|
/** @type HTMLCanvasElement preview */
|
||||||
const preview = document.getElementById('preview');
|
const preview = document.getElementById('preview');
|
||||||
|
const tapeDiv = document.getElementById('tape');
|
||||||
const renderCtx = preview.getContext("2d");
|
const renderCtx = preview.getContext("2d");
|
||||||
const elementsTableBody = elementsTable.getElementsByTagName('tbody')[0];
|
const elementsTableBody = elementsTable.getElementsByTagName('tbody')[0];
|
||||||
const addTextButton = document.getElementById('add-text');
|
const addTextButton = document.getElementById('add-text');
|
||||||
|
|
@ -244,6 +245,13 @@ fetch(apiRoot + '/status')
|
||||||
backgroundColor = status.tape_color;
|
backgroundColor = status.tape_color;
|
||||||
textColor = status.text_color;
|
textColor = status.text_color;
|
||||||
tapeWidthMM = status.media_width;
|
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();
|
render();
|
||||||
addTextElement();
|
addTextElement();
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
:root {
|
:root {
|
||||||
--background-color: #ffffff;
|
--background-color: #ffffff;
|
||||||
--font-color: #000000;
|
--font-color: #000000;
|
||||||
|
--margin-color: #888;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) {
|
@media (prefers-color-scheme: dark) {
|
||||||
|
|
@ -60,4 +61,10 @@ input {
|
||||||
width: auto;
|
width: auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#tape {
|
||||||
|
display: inline-block;
|
||||||
|
width: auto;
|
||||||
|
background: var(--margin-color);
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue