Skip to content

Commit

Permalink
draw twilights
Browse files Browse the repository at this point in the history
fixes bug where twilight periods are drawn incorrectly in polar regions
  • Loading branch information
forrestguice committed Oct 11, 2024
1 parent b8fa2b6 commit dc3a0b7
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -693,15 +693,21 @@ protected void drawBackground(Context context, NaturalHourData data, Canvas canv
boolean showDay = flags.getAsBoolean(FLAG_SHOW_BACKGROUND_DAY);
if (showTwilights || showDay)
{
double a0 = getAdjustedAngle(startAngle, data.getAngle(twilightHours[0], timezone), data);
long time0 = (twilightHours[0] != -1) ? twilightHours[0] : naturalHours[18];
double a0 = getAdjustedAngle(startAngle, data.getAngle(time0, timezone), data);

for (int i=1; i<twilightHours.length; i++)
{
double a1 = getAdjustedAngle(startAngle, data.getAngle(twilightHours[i], timezone), data);
long time = (twilightHours[i] != -1) ? twilightHours[i] : naturalHours[18];
double a1 = getAdjustedAngle(startAngle, data.getAngle(time, timezone), data);

if ((i == 4 && showDay) || i != 4 && showTwilights)
{
double span = a1 - a0;
paintFillDay.setColor(getTwilightColor(i-1));
drawPie(canvas, cX, cY, radiusInner(cX), a0, span, paintFillDay);
double span = NaturalHourData.simplifyAngle(a1 - a0);
if (span != 0) {
paintFillDay.setColor(getTwilightColor(i - 1));
drawPie(canvas, cX, cY, radiusInner(cX), a0, span, paintFillDay);
}
}
a0 = a1;
}
Expand Down

0 comments on commit dc3a0b7

Please sign in to comment.