DR
unread,Jul 14, 2026, 7:51:39 PM (7 days ago) Jul 14Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to weewx...@googlegroups.com
Would this be the code to study to try to figure out a 'simple'
solution, especially the last four lines?
def _renderDayNight(self, sdraw):
"""Draw vertical bands for day/night."""
(first, transitions) = weeutil.weeutil.getDayNightTransitions(
self.xscale[0], self.xscale[1], self.latitude, self.longitude)
color = self.daynight_day_color \
if first == 'day' else self.daynight_night_color
xleft = self.xscale[0]
for x in transitions:
sdraw.rectangle(((xleft,self.yscale[0]),
(x,self.yscale[1])), fill=color)
xleft = x
color = self.daynight_night_color \
if color == self.daynight_day_color else
self.daynight_day_color
sdraw.rectangle(((xleft,self.yscale[0]),
(self.xscale[1],self.yscale[1])), fill=color)
if self.daynight_gradient:
if first == 'day':
color1 = self.daynight_day_color
color2 = self.daynight_night_color
else:
color1 = self.daynight_night_color
color2 = self.daynight_day_color
nfade = self.daynight_gradient
# gradient is longer at the poles than the equator
d = 120 + 300 * (1 - (90.0 - abs(self.latitude)) / 90.0)
for i in range(len(transitions)):
last_ = self.xscale[0] if i == 0 else transitions[i-1]
next_ = transitions[i+1] if i < len(transitions)-1 else
self.xscale[1]
for z in range(1,nfade):
c = blend_hls(color2, color1, float(z)/float(nfade))
rgbc = int2rgbstr(c)
x1 = transitions[i]-d*(nfade+1)/2+d*z
if last_ < x1 < next_:
sdraw.rectangle(((x1, self.yscale[0]),
(x1+d, self.yscale[1])),
fill=rgbc)
if color1 == self.daynight_day_color:
color1 = self.daynight_night_color
color2 = self.daynight_day_color
else:
color1 = self.daynight_day_color
color2 = self.daynight_night_color
# draw a line at the actual sunrise/sunset
for x in transitions:
sdraw.line((x,x),(self.yscale[0],self.yscale[1]),
fill=self.daynight_edge_color)