Yes, that's it.

On Tue, Jul 14, 2026 at 4:51 PM DR <[email protected]> wrote:

> 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)
>
> --
> You received this message because you are subscribed to the Google Groups
> "weewx-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion visit
> https://groups.google.com/d/msgid/weewx-user/f72b6d8a-c393-4b11-abe9-a5894158012a%40gmail.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/weewx-user/CAPq0zEBvmmxTcCk3c_y%3DkJSeXswkcf%3D8UWf836tt3CH0eBrdKg%40mail.gmail.com.

Reply via email to