Ring gets inverted when it's nighttime
parent
ebf2362682
commit
13092d5c74
|
|
@ -115,6 +115,7 @@ var drawCount = 0;
|
||||||
var sunStart; // In terms of ms
|
var sunStart; // In terms of ms
|
||||||
var sunEnd; // In terms of minutes
|
var sunEnd; // In terms of minutes
|
||||||
var sunFull; // In terms of ms
|
var sunFull; // In terms of ms
|
||||||
|
var isDaytime = true;
|
||||||
|
|
||||||
function getMinutesFromDate(date) {
|
function getMinutesFromDate(date) {
|
||||||
return (60 * date.getHours()) + date.getMinutes();
|
return (60 * date.getHours()) + date.getMinutes();
|
||||||
|
|
@ -134,6 +135,7 @@ function updateSunRiseSunSet(now, lat, lon, sunLeftCalcs){
|
||||||
if (sunLeft < 0) { // If it's already night
|
if (sunLeft < 0) { // If it's already night
|
||||||
dateCopy.setDate(dateCopy.getDate() + 1);
|
dateCopy.setDate(dateCopy.getDate() + 1);
|
||||||
let timesTmrw = SunCalc.getTimes(dateCopy, lat, lon);
|
let timesTmrw = SunCalc.getTimes(dateCopy, lat, lon);
|
||||||
|
isDaytime = false;
|
||||||
sunStart = times.sunset;
|
sunStart = times.sunset;
|
||||||
sunFull = timesTmrw.sunrise - sunStart;
|
sunFull = timesTmrw.sunrise - sunStart;
|
||||||
sunEnd = getMinutesFromDate(timesTmrw.sunrise);
|
sunEnd = getMinutesFromDate(timesTmrw.sunrise);
|
||||||
|
|
@ -143,11 +145,13 @@ function updateSunRiseSunSet(now, lat, lon, sunLeftCalcs){
|
||||||
if (sunLeft < 0) { // If it's not morning yet.
|
if (sunLeft < 0) { // If it's not morning yet.
|
||||||
dateCopy.setDate(dateCopy.getDate() - 1);
|
dateCopy.setDate(dateCopy.getDate() - 1);
|
||||||
let timesYest = SunCalc.getTimes(dateCopy, lat, lon);
|
let timesYest = SunCalc.getTimes(dateCopy, lat, lon);
|
||||||
|
isDaytime = false;
|
||||||
sunStart = timesYest.sunset;
|
sunStart = timesYest.sunset;
|
||||||
sunFull = times.sunrise - sunStart;
|
sunFull = times.sunrise - sunStart;
|
||||||
sunEnd = getMinutesFromDate(times.sunrise);
|
sunEnd = getMinutesFromDate(times.sunrise);
|
||||||
}
|
}
|
||||||
else { // We're in the middle of the day
|
else { // We're in the middle of the day
|
||||||
|
isDaytime = true;
|
||||||
sunStart = times.sunrise;
|
sunStart = times.sunrise;
|
||||||
sunFull = times.sunset - sunStart;
|
sunFull = times.sunset - sunStart;
|
||||||
sunEnd = getMinutesFromDate(times.sunset);
|
sunEnd = getMinutesFromDate(times.sunset);
|
||||||
|
|
@ -260,6 +264,7 @@ function drawClock() {
|
||||||
var hh = date.getHours();
|
var hh = date.getHours();
|
||||||
var mm = date.getMinutes();
|
var mm = date.getMinutes();
|
||||||
var ring_percent;
|
var ring_percent;
|
||||||
|
var invertRing = false;
|
||||||
switch (settings.ring) {
|
switch (settings.ring) {
|
||||||
case 'Hours':
|
case 'Hours':
|
||||||
ring_percent = Math.round((10*(((hh % 12) * 60) + mm))/72);
|
ring_percent = Math.round((10*(((hh % 12) * 60) + mm))/72);
|
||||||
|
|
@ -284,6 +289,7 @@ function drawClock() {
|
||||||
}
|
}
|
||||||
// If we're exactly on the minute that the sun is setting/rising
|
// If we're exactly on the minute that the sun is setting/rising
|
||||||
if (getMinutesFromDate(date) == sunEnd) ring_percent = 100;
|
if (getMinutesFromDate(date) == sunEnd) ring_percent = 100;
|
||||||
|
invertRing = !isDaytime;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -297,7 +303,7 @@ function drawClock() {
|
||||||
g.reset();
|
g.reset();
|
||||||
g.setColor(g.theme.bg);
|
g.setColor(g.theme.bg);
|
||||||
g.fillRect(0, 0, w, h);
|
g.fillRect(0, 0, w, h);
|
||||||
g.drawImage(getGaugeImage(ring_percent, settings.ring, false), 0, 0);
|
g.drawImage(getGaugeImage(ring_percent, settings.ring, invertRing), 0, 0);
|
||||||
setLargeFont();
|
setLargeFont();
|
||||||
|
|
||||||
g.setColor(settings.fg);
|
g.setColor(settings.fg);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue