fix(measuretime): make sure big numbers are aligned as beautiful as small numbers

master
Bernhard 2024-07-14 14:19:16 +02:00
parent 502755b253
commit eda83a74f1
1 changed files with 15 additions and 7 deletions

View File

@ -1,7 +1,5 @@
{ {
require("Font7x11Numeric7Seg").add(Graphics); require("Font7x11Numeric7Seg").add(Graphics);
g.setFont("7x11Numeric7Seg");
g.setFontAlign(0, 0);
const centerY = g.getHeight() / 2; //88 const centerY = g.getHeight() / 2; //88
const lineStart = 25; const lineStart = 25;
@ -70,6 +68,16 @@
g.fillPolyAA(polyRightBottom, true); g.fillPolyAA(polyRightBottom, true);
}; };
let hourStringXOffset = function (hour) {
if (hour == 1) {
return lineEndFull - 5;
}
if (hour < 10 || hour > 20) {
return lineEndFull + 5;
}
return lineEndFull - 5;
};
let drawTime = function () { let drawTime = function () {
g.clear(); g.clear();
var d = new Date(); var d = new Date();
@ -86,19 +94,19 @@
var lineEnd = lineEndDefault; var lineEnd = lineEndDefault;
g.setFont("7x11Numeric7Seg", 2); g.setFont("7x11Numeric7Seg", 2);
g.setFontAlign(0, 0); g.setFontAlign(-1, 0);
// gone // gone
do { do {
switch (yTopLines - 88 + mins) { switch (yTopLines - 88 + mins) {
case -60: case -60:
lineEnd = lineEndFull; lineEnd = lineEndFull;
g.drawString(d.getHours() - 1, lineEnd + 10, yTopLines, true); g.drawString(d.getHours()-1, hourStringXOffset(d.getHours()-1), yTopLines, true);
break; break;
case 0: case 0:
case 60: case 60:
lineEnd = lineEndFull; lineEnd = lineEndFull;
g.drawString(d.getHours(), lineEnd + 10, yTopLines, true); g.drawString(d.getHours(), hourStringXOffset(d.getHours()), yTopLines, true);
break; break;
case 45: case 45:
case -45: case -45:
@ -128,11 +136,11 @@
case 0: case 0:
case 60: case 60:
lineEnd = lineEndFull; lineEnd = lineEndFull;
g.drawString(d.getHours() + 1, lineEnd + 10, yBottomLines, true); g.drawString(d.getHours() + 1, hourStringXOffset(d.getHours()+1), yBottomLines, true);
break; break;
case 120: case 120:
lineEnd = lineEndFull; lineEnd = lineEndFull;
g.drawString(d.getHours() + 2, lineEnd + 10, yBottomLines, true); g.drawString(d.getHours() + 2, hourStringXOffset(d.getHours()+2), yBottomLines, true);
break; break;
case 15: case 15:
case 75: case 75: