Exemple #1
0
 def _stamp(self,
            draw: ImageDraw,
            position: int,
            img: Image,
            color: str = None):  # 32x32 at 150x44
     if color is None:
         color = self.theme.details
     draw.bitmap(((self.width * self.multiplier - img.width) // 2 - 1,
                  position * self.multiplier), img, color)
Exemple #2
0
 def draw(self, active_index: float, canvas: ImageDraw):
     """Draw the menu into a canvas.
     `active_index` can be a float for smooth transitions
     """
     # copy the relevant part of the pre-rendered menu
     y_start = self._y_offset + \
         self._lineToEntryIndex(active_index, 0) * self._line_h
     rect = (0, y_start, self._line_w,
             y_start + self._num_rows * self._line_h)
     visible = self._full_menu.crop(rect)
     canvas.bitmap((0, 0), visible, fill="white")
     # then draw the active menu frame
     n = active_index % self._num_rows
     canvas.rectangle((0, int(n * self._line_h), self._line_w - 1,
                       int((n + 1) * self._line_h - 1)),
                      outline="white")
Exemple #3
0
 def draw(self, active_index: float, canvas: ImageDraw):
     """Draw the menu into a canvas.
     `active_index` can be a float for smooth transitions
     """
     # copy the relevant part of the pre-rendered menu
     y_middle = int(active_index * self._line_h + self._line_h // 2)
     y_start = int((active_index - self._num_rows // 2) * self._line_h)
     y_end = int((active_index + 1 + self._num_rows // 2) * self._line_h)
     rect = (0, self._y_offset + y_start, self._line_w,
             self._y_offset + y_end)
     visible = self._full_menu.crop(rect)
     canvas.bitmap((0, self._y_center - (y_middle - y_start)),
                   visible,
                   fill="white")
     # then draw the active menu frame
     canvas.rectangle(
         (0, self._y_center - 1 - self._line_h // 2, self._line_w - 1,
          self._y_center + 1 + self._line_h // 2),
         outline="white")
Exemple #4
0
 def draw(self, draw: ImageDraw):
     draw.bitmap(self.points, self.bitmap, self.fill)