def __init__(self, item: QGraphicsItem, old_pos: QPointF, scene: QGraphicsScene, parent: QUndoCommand = None): super().__init__(parent) self.item = item self.old_pos = old_pos self.new_pos = item.pos() self.scene = scene scene.update() self.setText(f"Move {str(item)}")
def __init__(self, item: QGraphicsItem, old_pos: QPointF, old_line_or_rect: Union[QLineF, QRectF], scene: QGraphicsScene, parent: QUndoCommand = None): super().__init__(parent) self.item = item self.old_pos = old_pos self.old_line_or_rect = old_line_or_rect self.new_pos = item.pos() self.new_line_or_rect = item.rect() if isinstance(old_line_or_rect, QRectF) else item.line() self.scene = scene scene.update() self.setText(f"Resize {str(item)}")
def upAlpha(self, particle: QGraphicsItem): if self.pokemon.collidesWithItem(particle): # particle.setVisible(False) pos = QPointF( particle.pos().x() - 220 + self.image.width() / 2, particle.pos().y() - 220 + self.image.height() / 2) # self.pokemon.mapToItem(self.pokemon, particle.pos()) border = 2 if pos.x() > border and pos.x() < self.image.width()-border and\ pos.y() > border and pos.y() < self.image.height()-border: for i in range(-border, border): for j in range(-border, border): color = self.image.pixelColor(pos.x() + i, pos.y() + j) if color.alpha() > 0 and color.alpha() < 245: color.setAlpha(color.alpha() + 10) self.image.setPixel(pos.x() + i, pos.y() + j, color.rgba()) self.pokemon.setPixmap(QPixmap().fromImage( self.image)) self.pokemon.show()