Beispiel #1
0
    def resize(self, screen):
        Background.resize(self, screen)
        if self._need_update and self.arrow_location != ARROW_HIDDEN:
            if self.arrow_location == ARROW_TOUCH:
                size = (self._rect.width * 0.2, self._rect.height * 0.2)

                self.left_arrow = pictures.get_pygame_image(
                    "camera.png", size, vflip=False, color=self._text_color)

                x = int(self._rect.width * 0.2)
                y = int(self._rect.height // 2)
            else:
                size = (self._rect.width * 0.3, self._rect.height * 0.3)

                vflip = True if self.arrow_location == ARROW_TOP else False
                self.left_arrow = pictures.get_pygame_image(
                    "arrow.png", size, vflip=vflip, color=self._text_color)

                x = int(self._rect.left + self._rect.width // 4 -
                        self.left_arrow.get_rect().width // 2)
                if self.arrow_location == ARROW_TOP:
                    y = self._rect.top + 10
                else:
                    y = int(self._rect.top + 2 * self._rect.height // 3)

            self.left_arrow_pos = (x - self.arrow_offset, y)
Beispiel #2
0
    def resize(self, screen):
        Background.resize(self, screen)
        if self._need_update:
            # Note: '0.9' ratio comes from PiWindow._update_foreground() method which
            # lets a margin between window borders and fullscreen foreground picture
            frgnd_rect = pygame.Rect(0, 0, *pictures.sizing.new_size_keep_aspect_ratio(
                self.foreground_size, (self._rect.size[0] * 0.9, self._rect.size[1]*0.9)))
            xmargin = abs(self._rect.width - frgnd_rect.width) // 2
            ymargin = abs(self._rect.height - frgnd_rect.height) // 2

            if xmargin > 50:
                margin = min(xmargin, self._rect.height // 3)
            elif ymargin > 50:
                margin = min(ymargin, self._rect.width // 3)
            else: # Too small
                self.left_people = None
                self.right_people = None
                return

            left_rect = pygame.Rect(0, 0, margin, margin)
            right_rect = pygame.Rect(0, 0, margin, margin)
            left_rect.bottom = self._rect.bottom
            right_rect.right = self._rect.right

            self.left_people = pictures.get_pygame_image("finished_left.png", size=left_rect.size,
                                                         color=self._text_color)
            self.right_people = pictures.get_pygame_image("finished_right.png", size=right_rect.size,
                                                          color=self._text_color)

            self.left_people_pos = self.left_people.get_rect(center=left_rect.center).topleft
            self.right_people_pos = self.right_people.get_rect(center=right_rect.center).topleft

            if self._show_outlines and left_rect and right_rect:
                self._outlines.append((self._make_outlines(left_rect.size), left_rect.topleft))
                self._outlines.append((self._make_outlines(right_rect.size), right_rect.topleft))
Beispiel #3
0
    def resize(self, screen):
        """Resize objects to fit to the screen.
        """
        if self._rect != screen.get_rect():
            self._rect = screen.get_rect()

            overlay_name = "{}.png".format(self._name)
            if osp.isfile(pictures.get_filename(overlay_name)):
                self._overlay = pictures.get_pygame_image(
                    pictures.get_filename(overlay_name),
                    (self._rect.width, self._rect.height),
                    color=self._text_color,
                    bg_color=self._background_color)

            if self._background_image:
                self._background = pictures.get_pygame_image(
                    self._background_image,
                    (self._rect.width, self._rect.height),
                    crop=True,
                    color=None)
                self._background_color = pictures.get_pygame_main_color(
                    self._background)

            self.resize_texts()

            self._need_update = True
Beispiel #4
0
    def resize(self, screen):
        IntroBackground.resize(self, screen)
        if self._need_update and self.arrow_location != ARROW_HIDDEN:
            size = (self._rect.width * 0.1, self._rect.height * 0.1)
            if self.arrow_location == ARROW_TOUCH:
                self.right_arrow = pictures.get_pygame_image(
                    "hand.png",
                    size,
                    hflip=False,
                    vflip=False,
                    angle=-70,
                    color=self._text_color)
            else:
                vflip = True if self.arrow_location == ARROW_TOP else False
                angle = -70 if self.arrow_location == ARROW_TOP else 70
                self.right_arrow = pictures.get_pygame_image(
                    "arrow.png",
                    size,
                    hflip=False,
                    vflip=vflip,
                    angle=angle,
                    color=self._text_color)

            x = int(self._rect.left + self._rect.width // 2 -
                    self.right_arrow.get_rect().width // 2)
            if self.arrow_location == ARROW_TOP:
                y = self._rect.top + 10
            else:
                y = int(self._rect.bottom -
                        self.right_arrow.get_rect().height * 1.1)
            self.right_arrow_pos = (x - self.arrow_offset, y)
Beispiel #5
0
    def resize(self, screen):
        if Background.resize(self, screen):
            size = (self.get_rect().width * 0.6, self.get_rect().height * 0.6)
            self.layout0 = pictures.get_pygame_image(
                "layout{}.png".format(self.choices[0]), size)
            self.layout1 = pictures.get_pygame_image(
                "layout{}.png".format(self.choices[1]), size)

            inter = (self.get_rect().width -
                     2 * self.layout0.get_rect().width) // 3

            x0 = int(self.get_rect().left + inter)
            x1 = int(self.get_rect().left + 2 * inter +
                     self.layout0.get_rect().width)
            y = int(self.get_rect().top + self.get_rect().height * 0.3)

            self.layout0_pos = (x0, y)
            self.layout1_pos = (x1, y)

            if self.arrow_location != ARROW_HIDDEN:
                if self.arrow_location == ARROW_TOP:
                    y = self.get_rect().top + 5
                    x_offset = 30
                    size = (self.get_rect().width * 0.1,
                            self.layout0_pos[1] - y - 10)
                else:
                    x_offset = 0
                    y = self.layout0_pos[1] + self.layout0.get_rect(
                    ).height + 5
                    size = (self.get_rect().width * 0.1,
                            self.get_rect().bottom - y - 5)

                vflip = True if self.arrow_location == ARROW_TOP else False
                self.left_arrow = pictures.get_pygame_image("arrow.png",
                                                            size,
                                                            vflip=vflip)
                self.right_arrow = pictures.get_pygame_image("arrow.png",
                                                             size,
                                                             hflip=True,
                                                             vflip=vflip)

                inter = (self.get_rect().width -
                         2 * self.left_arrow.get_rect().width) // 4

                x0 = int(self.get_rect().left + inter) - x_offset
                x1 = int(self.get_rect().left + 3 * inter +
                         self.left_arrow.get_rect().width) + x_offset

                self.left_arrow_pos = (x0 - self.arrow_offset, y)
                self.right_arrow_pos = (x1 + self.arrow_offset, y)

            return True
        return False
Beispiel #6
0
 def resize(self, screen):
     """Resize objects to fit to the screen.
     """
     if self._rect != screen.get_rect():
         self._rect = screen.get_rect()
         self._overlay = pictures.get_pygame_image(
             self._overlay_image, (self._rect.width, self._rect.height))
         if self._background_image:
             self._background = pictures.get_pygame_image(
                 self._background_image,
                 (self._rect.width, self._rect.height),
                 crop=True)
         self._need_update = True
Beispiel #7
0
    def resize(self, screen):
        Background.resize(self, screen)
        if self._need_update and self.arrow_location != ARROW_HIDDEN:

            if self.arrow_location == ARROW_TOUCH:
                size = (self._rect.width // 4, self._rect.height // 4)
                # Right arrow
                self.right_arrow = pictures.get_pygame_image(
                    "printer_touch.png", size, hflip=False, vflip=False, color=self._text_color)
                x = int(self._rect.left + self._rect.width * 0.70
                        - self.right_arrow.get_rect().width // 2)
                y = int(self._rect.top + self._rect.height * 0.45)
            else:
                size = (self._rect.width * 0.3, self._rect.height * 0.3)

                vflip = True if self.arrow_location == ARROW_TOP else False

                # Right arrow
                self.right_arrow = pictures.get_pygame_image(
                    "arrow.png", size, hflip=True, vflip=vflip, color=self._text_color)

                x = int(self._rect.left + self._rect.width * 0.75
                        - self.right_arrow.get_rect().width // 2)
                if self.arrow_location == ARROW_TOP:
                    y = self._rect.top + 10
                else:
                    y = int(self._rect.top + 2 * self._rect.height // 3)

            self.right_arrow_pos = (x + self.arrow_offset, y)

            # Left arrow
            size = (self._rect.width * 0.1, self._rect.height * 0.1)

            if self.arrow_location == ARROW_TOUCH:
                self.left_arrow = pictures.get_pygame_image(
                    "hand.png", size, hflip=False, vflip=False, angle=70, color=self._text_color)
            else:
                vflip = True if self.arrow_location == ARROW_TOP else False
                angle = 70 if self.arrow_location == ARROW_TOP else -70
                self.left_arrow = pictures.get_pygame_image(
                    "arrow.png", size, hflip=False, vflip=vflip, angle=angle, color=self._text_color)

            x = int(self._rect.left + self._rect.width // 2
                    - self.left_arrow.get_rect().width // 2)

            if self.arrow_location == ARROW_TOP:
                y = self._rect.top + 10
            else:
                y = int(self._rect.bottom - self.left_arrow.get_rect().height * 1.1)

            self.left_arrow_pos = (x - self.arrow_offset, y)
Beispiel #8
0
    def resize(self, screen):
        Background.resize(self, screen)
        if self._need_update:
            size = (self._rect.width * 0.6, self._rect.height * 0.6)
            self.layout0 = pictures.get_layout_image(self._text_color,
                                                     self._background_color,
                                                     self.choices[0], size)
            self.layout1 = pictures.get_layout_image(self._text_color,
                                                     self._background_color,
                                                     self.choices[1], size)

            inter = (self._rect.width - 2 * self.layout0.get_rect().width) // 3

            x0 = int(self._rect.left + inter)
            x1 = int(self._rect.left + 2 * inter +
                     self.layout0.get_rect().width)
            y = int(self._rect.top + self._rect.height * 0.3)

            self.layout0_pos = (x0, y)
            self.layout1_pos = (x1, y)

            if self.arrow_location != ARROW_HIDDEN:
                if self.arrow_location == ARROW_TOP:
                    y = 5
                    x_offset = 30
                    size = (self._rect.width * 0.1, self._rect.top + y + 30)
                else:
                    x_offset = 0
                    y = self.layout0_pos[1] + self.layout0.get_rect(
                    ).height + 5
                    size = (self._rect.width * 0.1, self._rect.bottom - y - 5)

                vflip = True if self.arrow_location == ARROW_TOP else False
                self.left_arrow = pictures.get_pygame_image(
                    "arrow.png", size, vflip=vflip, color=self._text_color)
                self.right_arrow = pictures.get_pygame_image(
                    "arrow.png",
                    size,
                    hflip=True,
                    vflip=vflip,
                    color=self._text_color)

                inter = (self._rect.width -
                         2 * self.left_arrow.get_rect().width) // 4

                x0 = int(self._rect.left + inter) - x_offset
                x1 = int(self._rect.left + 3 * inter +
                         self.left_arrow.get_rect().width) + x_offset

                self.left_arrow_pos = (x0 - self.arrow_offset, y)
                self.right_arrow_pos = (x1 + self.arrow_offset, y)
Beispiel #9
0
    def resize(self, screen):
        Background.resize(self, screen)
        if self._need_update:
            images_height = self._rect.height / 4
            size = (3 * images_height, images_height)

            self.left_image = pictures.get_pygame_image(
                "capture_left_image.png", size=size)
            self.right_image = pictures.get_pygame_image(
                "capture_right_image.png", size=size)

            x = int(self._rect.right - 2 * self.right_image.get_rect().width)
            y = int(self._rect.bottom - images_height)

            self.left_image_pos = (0, y)
            self.right_image_pos = (x, y)
Beispiel #10
0
def state_wait_exit(win):
    win_rect = win.get_rect()
    text = "Get Ready!"

    # Get best font size according to window size
    font = fonts.get_pygame_font(text, fonts.CURRENT,
                                 win_rect.width//1.5, win_rect.height//1.5)

    # Build a surface to display at screen
    text_surface = font.render(text, True, win.text_color)

    # Clear screen
    if isinstance(win.bg_color, (tuple, list)):
        win.surface.fill(win.bg_color)
    else:
        bg_surface = pictures.get_pygame_image(win.bg_color, win_rect.size, crop=True, color=None)
        win.surface.blit(bg_surface, (0, 0))

    # Draw the surface at screen
    win.surface.blit(text_surface, text_surface.get_rect(center=win_rect.center).topleft)

    # Force screen update and events process
    pygame.display.update()
    pygame.event.pump()

    # Wait 1s
    time.sleep(1)
Beispiel #11
0
    def resize(self, screen):
        """Resize objects to fit to the screen.
        """
        if self._rect != screen.get_rect():
            self._rect = screen.get_rect()

            overlay_name = "{}.png".format(self._name)
            if osp.isfile(pictures.get_filename(overlay_name)):
                self._overlay = pictures.get_pygame_image(
                    pictures.get_filename(overlay_name), (self._rect.width, self._rect.height), invert=self._invert)

            if self._background_image:
                self._background = pictures.get_pygame_image(
                    self._background_image, (self._rect.width, self._rect.height), crop=True)

            self.write_text()

            self._need_update = True
Beispiel #12
0
 def resize(self, screen):
     """Resize objects to fit to the screen.
     """
     if self._rect != screen.get_rect():
         self._rect = screen.get_rect()
         self.background = pictures.get_pygame_image(
             self.image_name, (self._rect.width, self._rect.height))
         return True
     return False
Beispiel #13
0
    def _update_print_number(self):
        """Update the number of files in the printer queue.
        """
        if not self._print_number:
            return  # Dont show counter: no file in queue

        smaller = self.size[1] if self.size[1] < self.size[0] else self.size[0]
        side = int(smaller * 0.05)  # 5% of the window

        if side > 0:
            if self._print_failure:
                image = pictures.get_pygame_image('printer_failure.png', (side, side))
            else:
                image = pictures.get_pygame_image('printer.png', (side, side))
            y = self.surface.get_rect().height - image.get_rect().height - 10
            self.surface.blit(image, (10, y))
            font = pygame.font.Font(fonts.CURRENT, side)
            label = font.render(str(self._print_number), True, self.text_color)
            self.surface.blit(label, (side + 20, y))
Beispiel #14
0
    def resize(self, screen):
        Background.resize(self, screen)
        if self._need_update:
            images_height = self._rect.height / 4
            size = (images_height * 2, images_height)

            self.left_people = pictures.get_pygame_image("capture_left.png", size=size,
                                                         color=self._text_color)
            self.right_people = pictures.get_pygame_image("capture_right.png", size=size,
                                                          color=self._text_color)

            x = int(self._rect.right - size[0])
            y = int(self._rect.bottom - images_height)

            self.left_people_pos = (0, y)
            self.right_people_pos = (x + size[0] - 1.5 * self.right_people.get_rect().width, y)

            if self._show_outlines:
                self._outlines.append((self._make_outlines(size), (0, y)))
                self._outlines.append((self._make_outlines(size), (x, y)))
Beispiel #15
0
    def resize(self, screen):
        Background.resize(self, screen)
        if self._need_update:
            left_rect = pygame.Rect(10, 0, self._rect.width * 0.4, self._rect.height * 0.5)
            left_rect.top = self._rect.centery - left_rect.centery
            right_rect = pygame.Rect(0, 0, self._rect.width * 0.3, self._rect.height * 0.5)
            right_rect.top = self._rect.centery - right_rect.centery
            right_rect.right = self._rect.right - 10

            self.left_people = pictures.get_pygame_image("finished_left.png", size=left_rect.size,
                                                         color=self._text_color)
            self.right_people = pictures.get_pygame_image("finished_right.png", size=right_rect.size,
                                                          color=self._text_color)

            self.left_people_pos = self.left_people.get_rect(center=left_rect.center).topleft
            self.right_people_pos = self.right_people.get_rect(center=right_rect.center).topleft

            if self._show_outlines:
                self._outlines.append((self._make_outlines(left_rect.size), left_rect.topleft))
                self._outlines.append((self._make_outlines(right_rect.size), right_rect.topleft))
Beispiel #16
0
    def resize(self, screen):
        Background.resize(self, screen)
        if self._need_update:
            size = (self.get_rect().width * 0.6, self.get_rect().height * 0.6)

            self.layout = pictures.get_pygame_image(
                "layout{}.png".format(self.selected), size)

            x = self.layout.get_rect(center=self.get_rect().center).left
            y = int(self.get_rect().top + self.get_rect().height * 0.3)

            self.layout_pos = (x, y)
Beispiel #17
0
    def resize(self, screen):
        Background.resize(self, screen)
        if self._need_update and self.arrow_location != ARROW_HIDDEN:
            size = (self._rect.width * 0.3, self._rect.height * 0.3)

            vflip = True if self.arrow_location == ARROW_TOP else False
            self.left_arrow = pictures.get_pygame_image("arrow.png",
                                                        size,
                                                        vflip=vflip,
                                                        color=self._text_color)
            self.qr_download_link = pictures.get_pygame_image(
                "link.jpg", (300, 300))

            x = int(self._rect.left + self._rect.width // 4 -
                    self.left_arrow.get_rect().width // 2)
            if self.arrow_location == ARROW_TOP:
                y = self._rect.top + 10
            else:
                y = int(self._rect.top + 2 * self._rect.height // 3)

            self.left_arrow_pos = (x - self.arrow_offset, y)
            self.qr_download_link_pos = (50, 50)
Beispiel #18
0
    def resize(self, screen):
        Background.resize(self, screen)
        if self._need_update and self.arrow_location != ARROW_HIDDEN:
            size = (self._rect.width * 0.3, self._rect.height * 0.3)

            vflip = True if self.arrow_location == ARROW_TOP else False
            self.right_arrow = pictures.get_pygame_image("arrow.png", size, hflip=True, vflip=vflip)

            x = int(self._rect.left + self._rect.width * 0.75
                    - self.right_arrow.get_rect().width // 2)

            if self.arrow_location == ARROW_TOP:
                y = self._rect.top + 10
            else:
                y = int(self._rect.top + 2 * self._rect.height // 3)

            self.right_arrow_pos = (x + self.arrow_offset, y)
Beispiel #19
0
    def resize(self, screen):
        if Background.resize(self, screen):
            if self.arrow_location != ARROW_HIDDEN:
                size = (self.get_rect().width * 0.3,
                        self.get_rect().height * 0.3)

                vflip = True if self.arrow_location == ARROW_TOP else False
                self.left_arrow = pictures.get_pygame_image("arrow.png",
                                                            size,
                                                            vflip=vflip)

                x = int(self.get_rect().left + self.get_rect().width // 4 -
                        self.left_arrow.get_rect().width // 2)
                if self.arrow_location == ARROW_TOP:
                    y = self.get_rect().top + 10
                else:
                    y = int(self.get_rect().top +
                            2 * self.get_rect().height // 3)

                self.left_arrow_pos = (x - self.arrow_offset, y)
            return True
        return False