From 6c2d266bb7497d1875ba56aec9637b58ffe76ecf Mon Sep 17 00:00:00 2001 From: Alain Saas Date: Wed, 28 Dec 2022 10:53:18 -0500 Subject: [PATCH] Shows night time on the map --- apps/a_clock_timer/app.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/apps/a_clock_timer/app.js b/apps/a_clock_timer/app.js index 5f9a3a468..d13098b26 100644 --- a/apps/a_clock_timer/app.js +++ b/apps/a_clock_timer/app.js @@ -102,13 +102,24 @@ function queueNextDraw() { function draw() { g.reset().clearRect(0,24,g.getWidth(),g.getHeight()-IMAGEHEIGHT); g.drawImage(getImg(),0,g.getHeight()-IMAGEHEIGHT); - + var x_sun = 176 - (getGmt().getHours() / 24 * 176 + 4); g.setColor('#ff0').drawLine(x_sun, g.getHeight()-IMAGEHEIGHT, x_sun, g.getHeight()); g.reset(); + var x_night_start = 176 - (((getGmt().getHours()-6)%24) / 24 * 176 + 4); + var x_night_end = 176 - (((getGmt().getHours()+6)%24) / 24 * 176 + 4); + for (let x = x_night_start; x < 176; x+=2) { + g.setColor('#000').drawLine(x, g.getHeight()-IMAGEHEIGHT, x, g.getHeight()); + } + if (x_night_end < x_night_start) { + for (let x = 0; x < x_night_end; x+=2) { + g.setColor('#000').drawLine(x, g.getHeight()-IMAGEHEIGHT, x, g.getHeight()); + } + } + var locale = require("locale"); - + var date = new Date(); g.setFontAlign(0,0); g.setFont("Michroma36").drawString(locale.time(date,1), g.getWidth()/2, 46);