def draw_gates(self, y, x): # TODO: take coordinates and put them into global var in a tuple with id # then check to see if the id is less than count --> green gate_d = Settings.WIDTH * 0.2 # diameter of gates aoe_d = Settings.WIDTH * 3 # diameter of gate_AOE # create and add gates gate_x = x * Settings.WIDTH - gate_d / 2 gate_y = y * Settings.HEIGHT - gate_d / 2 gate = QRectF(gate_x, gate_y, gate_d, gate_d) self.addEllipse(gate, Qt.black, QColor(255, 0, 0, 255)) # create and add gate_AOE aoe_x = x * Settings.WIDTH - aoe_d / 2 aoe_y = y * Settings.HEIGHT - aoe_d / 2 aoe = QRectF(aoe_x, aoe_y, aoe_d, aoe_d) print(aoe.getCoords()) self.addEllipse(aoe, Qt.black, QColor(0, 255, 0, 25))
def paintGrid(self, painter: QPainter, rect: QRectF, gridSize: int): left, top, right, bottom = rect.getCoords() x_min = (int(left - 1) // gridSize + 1) * gridSize y_min = (int(top - 1) // gridSize + 1) * gridSize x_max = (int(right) // gridSize) * gridSize y_max = (int(bottom) // gridSize) * gridSize # logging.debug( # "x=(%s<=%s..%s<=%s) y=(%s<=%s..%s<=%s)", # *(left, x_min, x_max, right), # *(top, y_min, y_max, bottom) # ) painter.setPen(QPen(Qt.gray, 2)) painter.drawLines(QLineF(0, top, 0, bottom), QLineF(left, 0, right, 0)) painter.setPen(QPen(Qt.gray, 1)) painter.drawLines( QLineF(x, top, x, bottom) for x in range(x_min, x_max + 1, gridSize) if x) painter.drawLines( QLineF(left, y, right, y) for y in range(y_min, y_max + 1, gridSize) if y)