StarRailCopilot/module/map/grid.py

39 lines
1.1 KiB
Python
Raw Normal View History

2020-03-28 17:22:46 +00:00
import numpy as np
from module.base.utils import area_pad
from module.map.grid_info import GridInfo
from module.map.grid_predictor import GridPredictor
class Grid(GridPredictor, GridInfo):
2020-05-22 17:35:56 +00:00
def __init__(self, location, image, corner, config):
2020-03-28 17:22:46 +00:00
"""
Args:
location(tuple):
image:
corner: (x0, y0) +-------+ (x1, y1)
/ \
/ \
(x2, y2) +-------------+ (x3, y3)
"""
self.location = location
2020-05-22 17:35:56 +00:00
super().__init__(location, image, corner, config)
2020-03-28 17:22:46 +00:00
self.corner = corner.flatten()
@property
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)
@property
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)