Update annotate.js

This commit is contained in:
meeki007 2020-12-16 09:01:11 -05:00 committed by GitHub
parent 936576e7d9
commit 6715ab01c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -84,38 +84,31 @@ module.exports = function(RED) {
ctx.textBaseline = "top";
ctx.textAlign = "left";
//set offset value so txt is above or below image
if (annotation.labelLocation)
{
if (annotation.labelLocation === "top")
{
if (annotation.labelLocation) {
if (annotation.labelLocation === "top") {
y = y - (20+((defaultLineWidth*0.5)+(Number(defaultFontSize))));
if (y < 0)
{
y = 0;
}
}
else if (annotation.labelLocation === "bottom")
{
else if (annotation.labelLocation === "bottom") {
y = y + (10+h+(((defaultLineWidth*0.5)+(Number(defaultFontSize)))));
ctx.textBaseline = "bottom";
}
}
//if not user defined make best guess for top or bottom based on location
else
{
else {
//not enought room above imagebox, put label on the bottom
if (y < 0 + (20+((defaultLineWidth*0.5)+(Number(defaultFontSize)))))
{
if (y < 0 + (20+((defaultLineWidth*0.5)+(Number(defaultFontSize))))) {
y = y + (10+h+(((defaultLineWidth*0.5)+(Number(defaultFontSize)))));
ctx.textBaseline = "bottom";
}
//else put the label on the top
else
{
else {
y = y - (20+((defaultLineWidth*0.5)+(Number(defaultFontSize))));
if (y < 0)
{
if (y < 0) {
y = 0;
}
}