From 502755b253fba0cdc4350a6fc6b7540d5c41e145 Mon Sep 17 00:00:00 2001 From: Bernhard Date: Sun, 14 Jul 2024 14:17:54 +0200 Subject: [PATCH 1/2] feat(measuretime): add outline for 3d effect --- apps/measuretime/measuretime.app.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/measuretime/measuretime.app.js b/apps/measuretime/measuretime.app.js index c7865bffe..0780ba9bd 100644 --- a/apps/measuretime/measuretime.app.js +++ b/apps/measuretime/measuretime.app.js @@ -27,10 +27,10 @@ var steps = [0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]; var stepsReversed = steps.slice(); stepsReversed.reverse(); - var polyLeftTop = []; - var polyLeftBottom = []; - var polyRightTop = []; - var polyRightBottom = []; + var polyLeftTop = [0, 0]; + var polyLeftBottom = [0, g.getHeight()]; + var polyRightTop = [g.getWidth() - 1, 0]; + var polyRightBottom = [g.getWidth() - 1, g.getHeight()]; let xL = 0; let xR = g.getWidth() - 1; let yT = centerY - 13; From eda83a74f17155867a2e3e7d3b1b711a729e1ee2 Mon Sep 17 00:00:00 2001 From: Bernhard Date: Sun, 14 Jul 2024 14:19:16 +0200 Subject: [PATCH 2/2] fix(measuretime): make sure big numbers are aligned as beautiful as small numbers --- apps/measuretime/measuretime.app.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/apps/measuretime/measuretime.app.js b/apps/measuretime/measuretime.app.js index 0780ba9bd..975996aa4 100644 --- a/apps/measuretime/measuretime.app.js +++ b/apps/measuretime/measuretime.app.js @@ -1,7 +1,5 @@ { require("Font7x11Numeric7Seg").add(Graphics); - g.setFont("7x11Numeric7Seg"); - g.setFontAlign(0, 0); const centerY = g.getHeight() / 2; //88 const lineStart = 25; @@ -70,6 +68,16 @@ 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 () { g.clear(); var d = new Date(); @@ -86,19 +94,19 @@ var lineEnd = lineEndDefault; g.setFont("7x11Numeric7Seg", 2); - g.setFontAlign(0, 0); + g.setFontAlign(-1, 0); // gone do { switch (yTopLines - 88 + mins) { case -60: lineEnd = lineEndFull; - g.drawString(d.getHours() - 1, lineEnd + 10, yTopLines, true); + g.drawString(d.getHours()-1, hourStringXOffset(d.getHours()-1), yTopLines, true); break; case 0: case 60: lineEnd = lineEndFull; - g.drawString(d.getHours(), lineEnd + 10, yTopLines, true); + g.drawString(d.getHours(), hourStringXOffset(d.getHours()), yTopLines, true); break; case 45: case -45: @@ -128,11 +136,11 @@ case 0: case 60: lineEnd = lineEndFull; - g.drawString(d.getHours() + 1, lineEnd + 10, yBottomLines, true); + g.drawString(d.getHours() + 1, hourStringXOffset(d.getHours()+1), yBottomLines, true); break; case 120: lineEnd = lineEndFull; - g.drawString(d.getHours() + 2, lineEnd + 10, yBottomLines, true); + g.drawString(d.getHours() + 2, hourStringXOffset(d.getHours()+2), yBottomLines, true); break; case 15: case 75: