Beispiel #1
0
 def draw_tile_header(self, x, y, w, h, fcast):
     """ Draw tile header
     
     :param x: tile x coordinate
     :param y: tile y coordinate
     :param w: tile width
     :param h: tile height
     :param fcast: one day forecast
     """
     height = (h / 100) * TILE_HEADER_HEIGHT
     comp = Component(self.util)
     comp.content_x = x
     comp.content_y = y
     rect = pygame.Rect(x, y, w, height)
     comp.content = rect
     comp.fgr = self.semi_transparent_color
     comp.bgr = self.semi_transparent_color
     comp.bounding_box = rect
     self.add_component(comp)
     
     text_color = self.util.weather_config[COLOR_BRIGHT]
     font_size = int((height / 100) * DAY_HEIGHT)
     
     if fcast[DAY] == UNKNOWN:
         d = UNKNOWN
     else:
         d = self.weather_config[fcast[DAY].lower()]
         
     c = self.util.get_text_component(d, text_color, font_size)
     c.content_x = x + (w - c.content.get_size()[0]) / 2
     c.content_y = y + font_size / 8
     self.add_component(c)
Beispiel #2
0
 def draw_background(self, x, y, w, h):
     """ Draw background defined by input parameters
     
     :param x: x coordinate
     :param y: y coordinate
     :param w: width
     :param h: height
     """
     c = Component(self.util)
     c.content = pygame.Rect(x, y, w, h)
     c.content_x = x
     c.content_y = y
     c.bounding_box = c.content
     c.bgr = self.semi_transparent_color
     self.add_component(c)
Beispiel #3
0
 def draw_separator(self, x, y, w, h):
     """ Draw tile separator
     
     :param x: tile x coordinate
     :param y: tile y coordinate
     :param w: tile width
     :param h: tile height
     """
     height = (h / 100) * TILE_HEADER_HEIGHT
     comp = Component(self.util)
     rect = pygame.Rect(x + w, y + height, 1, h - height + 2)
     comp.content = rect
     comp.fgr = self.util.weather_config[COLOR_DARK_LIGHT]
     comp.bgr = self.util.weather_config[COLOR_DARK_LIGHT]
     comp.bounding_box = rect
     self.add_component(comp)               
Beispiel #4
0
 def draw_tile_body(self, x, y, w, h, fcast):
     """ Draw center part of the tile
     
     :param x: tile x coordinate
     :param y: tile y coordinate
     :param w: tile width
     :param h: tile height
     :param fcast: one day forecast
     """
     top_height = (h / 100) * TILE_HEADER_HEIGHT
     y += top_height
     h = h - top_height + 1
     comp = Component(self.util)
     comp.content_x = x
     comp.content_y = y
     rect = pygame.Rect(x, y, w, h)
     comp.content = rect
     comp.fgr = self.util.weather_config[COLOR_BRIGHT]
     comp.bgr = self.util.weather_config[COLOR_BRIGHT]
     comp.bounding_box = rect
     self.add_component(comp)
Beispiel #5
0
 def draw_high_low(self):
     """ Draw high/low today's temperatures """
     
     bb_x = self.temp_right_edge
     bb_y = int((self.rect.h / 100) * TOP_HEIGHT)
     bb_w = self.rect.w - bb_x
     bb_h = self.rect.h - bb_y - int((self.rect.h / 100) * BOTTOM_HEIGHT)
     text_color = self.util.weather_config[COLOR_CONTRAST]
     font_size = int((bb_w / 100) * HIGH_LOW_TEXT_SIZE)
     
     c = self.util.get_text_component(self.high, text_color, font_size)
     w = c.content.get_size()[0]
     h = c.content.get_size()[1]
     c.content_x = bb_x + int((bb_w - w) / 2)
     c.content_y = bb_y + int((bb_h - h) / 2) - (font_size / 2)
     self.add_component(c)
     
     c = self.util.get_text_component(self.low, text_color, font_size)
     w = c.content.get_size()[0]
     h = c.content.get_size()[1]
     c.content_x = bb_x + int((bb_w - w) / 2)
     c.content_y = bb_y + int((bb_h - h) / 2) + (font_size / 1.4)
     self.add_component(c)
     
     x = c.content_x
     y = bb_y + int(bb_h / 2)
     w = c.content.get_size()[0]
     h = 2
     r = pygame.Rect(x, y, w, h)
     c = Component(self.util, r)
     c.name = "sep" + ".text"
     c.content_x = 0
     c.content_y = 0
     c.fgr = text_color
     c.bgr = text_color
     self.add_component(c)