mirror of
https://github.com/javl/image2cpp.git
synced 2026-09-11 09:03:04 +00:00
don't draw preview canvas for text input unless there is something to show
This commit is contained in:
+16
-16
@@ -648,22 +648,6 @@ function checkImagesAvailable() {
|
|||||||
// Handle inserting an image by pasting code
|
// Handle inserting an image by pasting code
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
function handleTextInput(drawMode) {
|
function handleTextInput(drawMode) {
|
||||||
const canvasContainer = document.getElementById('images-canvas-container');
|
|
||||||
const canvas = document.createElement('canvas');
|
|
||||||
|
|
||||||
canvas.width = parseInt(document.getElementById('text-input-width').value);
|
|
||||||
canvas.height = parseInt(document.getElementById('text-input-height').value);
|
|
||||||
settings.screenWidth = canvas.width;
|
|
||||||
settings.screenHeight = canvas.height;
|
|
||||||
|
|
||||||
if (canvasContainer.children.length) {
|
|
||||||
canvasContainer.removeChild(canvasContainer.firstChild);
|
|
||||||
}
|
|
||||||
canvasContainer.appendChild(canvas);
|
|
||||||
|
|
||||||
const image = new Image();
|
|
||||||
images.setByIndex(0, { img: image, canvas, ctx: canvas.getContext('2d') });
|
|
||||||
|
|
||||||
let input = document.getElementById('byte-input').value;
|
let input = document.getElementById('byte-input').value;
|
||||||
|
|
||||||
// Remove Arduino code
|
// Remove Arduino code
|
||||||
@@ -691,6 +675,22 @@ function handleTextInput(drawMode) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const canvasContainer = document.getElementById('images-canvas-container');
|
||||||
|
const canvas = document.createElement('canvas');
|
||||||
|
|
||||||
|
canvas.width = parseInt(document.getElementById('text-input-width').value);
|
||||||
|
canvas.height = parseInt(document.getElementById('text-input-height').value);
|
||||||
|
settings.screenWidth = canvas.width;
|
||||||
|
settings.screenHeight = canvas.height;
|
||||||
|
|
||||||
|
if (canvasContainer.children.length) {
|
||||||
|
canvasContainer.removeChild(canvasContainer.firstChild);
|
||||||
|
}
|
||||||
|
canvasContainer.appendChild(canvas);
|
||||||
|
|
||||||
|
const image = new Image();
|
||||||
|
images.setByIndex(0, { img: image, canvas, ctx: canvas.getContext('2d') });
|
||||||
|
|
||||||
const success = drawMode === 'horizontal'
|
const success = drawMode === 'horizontal'
|
||||||
? listToImageHorizontal(list, canvas)
|
? listToImageHorizontal(list, canvas)
|
||||||
: listToImageVertical(list, canvas);
|
: listToImageVertical(list, canvas);
|
||||||
|
|||||||
Reference in New Issue
Block a user