From e15ea561bceeaa80d9b5d3688bbc83c59a1def7f Mon Sep 17 00:00:00 2001 From: CaCO3 Date: Wed, 16 Nov 2022 18:32:53 +0100 Subject: [PATCH] Enhance ROI editing (#1357) * add labels to ROIs * . * fix naming check * . * . Co-authored-by: CaCO3 --- sd-card/html/edit_analog.html | 23 ++++++ sd-card/html/edit_digits.html | 123 +++++++++++++++++++++++++------- sd-card/html/readconfigparam.js | 7 +- 3 files changed, 124 insertions(+), 29 deletions(-) diff --git a/sd-card/html/edit_analog.html b/sd-card/html/edit_analog.html index d9bd3577..8e4c2ed0 100644 --- a/sd-card/html/edit_analog.html +++ b/sd-card/html/edit_analog.html @@ -482,10 +482,31 @@ function removeNumber(){ } +function drawTextBG(context, txt, x, y, padding) { + context.font = "15px Arial"; + context.textAlign = "center"; + + context.fillStyle = 'rgba(255, 0, 0, 0.5)'; + var width = context.measureText(txt).width; + context.fillRect(x-(width+padding)/2, y-12, width + padding*2, parseInt(context.font, 10) + padding); + + context.fillStyle = "black"; + context.fillText(txt, x + padding / 2, y + padding / 2); +} + function draw() { + if (typeof ROIInfo === 'undefined') { // During init, ROIInfo is not defined yet + return; + } + var canvas = document.getElementById('canvas'); var context = canvas.getContext('2d'); context.drawImage(imageObj, 0, 0); + + context.font = "15px Arial"; + context.fillStyle = "red"; + context.textAlign = "center"; + if (document.getElementById("Category_Analog_enabled").checked) { var sel = document.getElementById("index"); @@ -515,6 +536,7 @@ function removeNumber(){ var dx = parseInt(ROIInfo[_nb].dx) + parseInt(lw); var dy = parseInt(ROIInfo[_nb].dy) + parseInt(lw); context.strokeRect(x0, y0, dx, dy); + drawTextBG(context, ROIInfo[_nb]["name"], x0+dx/2-0.5, y0-13, 5); } } @@ -529,6 +551,7 @@ function removeNumber(){ var dx = parseInt(rect.w) + parseInt(lw); var dy = parseInt(rect.h) + parseInt(lw); context.strokeRect(x0, y0, dx, dy); + drawTextBG(context, ROIInfo[aktindex]["name"], x0+dx/2, y0-11, 5); context.lineWidth = 1; context.beginPath(); context.arc(x0+dx/2, y0+dy/2, dx/2, 0, 2 * Math.PI); diff --git a/sd-card/html/edit_digits.html b/sd-card/html/edit_digits.html index 7484fd64..fb124337 100644 --- a/sd-card/html/edit_digits.html +++ b/sd-card/html/edit_digits.html @@ -106,17 +106,17 @@ th, td { x: Δx: - + y: Δy: - + - -