def avoid_area(self):
     x0, y0, x1, y1, x2, y2, x3, y3 = self.corner
     area = tuple(
         np.rint((min(x0, x2), min(y0, y1), max(x1,
                                                x3), max(y2,
                                                         y3))).astype(int))
     return area_pad(area, pad=-25)
Exemple #2
0
    def _sos_signal_confirm(self, entrance, skip_first_screenshot=True):
        """
        Search a SOS signal, goto target chapter.

        Args:
            entrance (Button): Entrance button.
            skip_first_screenshot (bool):

        Pages:
            in: SIGNAL_SEARCH
            out: page_campaign
        """
        while 1:
            if skip_first_screenshot:
                skip_first_screenshot = False
            else:
                self.device.screenshot()

            if self.appear(SIGNAL_LIST_CHECK, offset=(20, 20), interval=2):
                image = self.image_crop(area_pad(entrance.area, pad=-30))
                if TEMPLATE_SIGNAL_SEARCH.match(image):
                    self.device.click(entrance)
                if TEMPLATE_SIGNAL_GOTO.match(image):
                    self.device.click(entrance)

            # End
            if self.appear(CAMPAIGN_CHECK, offset=(20, 20)):
                break
Exemple #3
0
def trapezoid2area(corner, pad=0):
    """
    Convert corners of a trapezoid to area.

    Args:
        corner: ((x0, y0), (x1, y1), (x2, y2), (x3, y3))
        pad (int):
            Positive value for inscribed area.
            Negative value and 0 for circumscribed area.

    Returns:
        tuple[int]: (upper_left_x, upper_left_y, bottom_right_x, bottom_right_y).
    """
    if pad > 0:
        return area_pad(corner2inner(corner), pad=pad)
    elif pad < 0:
        return area_pad(corner2outer(corner), pad=pad)
    else:
        return area_pad(corner2area(corner), pad=pad)
 def button(self):
     """
     Returns:
         tuple: area
     """
     x0, y0, x1, y1, x2, y2, x3, y3 = self.corner
     area = tuple(
         np.rint((max(x0, x2), max(y0, y1), min(x1,
                                                x3), min(y2,
                                                         y3))).astype(int))
     return area_pad(area, pad=25)