Exemple #1
0
def fin(pix):  ## delete pixitem
    node = Node(pix)
    node.pix.setOriginPt()
    sync = random.randint(6, 10) * 75
    rot = 270
    if not random.randint(0, 1): rot = -270

    rotate = QPropertyAnimation(node, b'rotate')
    rotate.setDuration(sync)
    rotate.setStartValue(node.pix.rotation)
    rotate.setEndValue(rot + node.pix.rotation)

    opacity = QPropertyAnimation(node, b'opacity')
    opacity.setDuration(sync)
    opacity.setStartValue(node.pix.opacity())
    opacity.setEndValue(0)

    scale = QPropertyAnimation(node, b'scale')
    scale.setDuration(sync)
    scale.setStartValue(node.pix.scale)
    scale.setEndValue(node.pix.scale * .25)

    group = QParallelAnimationGroup()

    group.addAnimation(rotate)
    group.addAnimation(opacity)
    group.addAnimation(scale)

    group.setLoopCount(1)

    return group
    def __init__(self):
        super(Robot, self).__init__()

        self.setFlag(self.ItemHasNoContents)

        self.torsoItem = RobotTorso(self)
        self.headItem = RobotHead(self.torsoItem)
        self.upperLeftArmItem = RobotLimb(self.torsoItem)
        self.lowerLeftArmItem = RobotLimb(self.upperLeftArmItem)
        self.upperRightArmItem = RobotLimb(self.torsoItem)
        self.lowerRightArmItem = RobotLimb(self.upperRightArmItem)
        self.upperRightLegItem = RobotLimb(self.torsoItem)
        self.lowerRightLegItem = RobotLimb(self.upperRightLegItem)
        self.upperLeftLegItem = RobotLimb(self.torsoItem)
        self.lowerLeftLegItem = RobotLimb(self.upperLeftLegItem)

        settings = (
            #    Item                       Position        Rotation  Scale
            #                                x     y    start    end
            (self.headItem, 0, -18, 20, -20, 1.1),
            (self.upperLeftArmItem, -15, -10, 190, 180, 0),
            (self.lowerLeftArmItem, 30, 0, 50, 10, 0),
            (self.upperRightArmItem, 15, -10, 300, 310, 0),
            (self.lowerRightArmItem, 30, 0, 0, -70, 0),
            (self.upperRightLegItem, 10, 32, 40, 120, 0),
            (self.lowerRightLegItem, 30, 0, 10, 50, 0),
            (self.upperLeftLegItem, -10, 32, 150, 80, 0),
            (self.lowerLeftLegItem, 30, 0, 70, 10, 0),
            (self.torsoItem, 0, 0, 5, -20, 0),
        )

        animation = QParallelAnimationGroup(self)
        for item, pos_x, pos_y, start_rot, end_rot, scale in settings:
            item.setPos(pos_x, pos_y)

            rot_animation = QPropertyAnimation(item, b"rotation")
            rot_animation.setStartValue(start_rot)
            rot_animation.setEndValue(end_rot)
            rot_animation.setEasingCurve(QEasingCurve.SineCurve)
            rot_animation.setDuration(2000)
            animation.addAnimation(rot_animation)

            if scale > 0:
                scale_animation = QPropertyAnimation(item, b"scale")
                scale_animation.setEndValue(scale)
                scale_animation.setEasingCurve(QEasingCurve.SineCurve)
                scale_animation.setDuration(2000)
                animation.addAnimation(scale_animation)

        animation.setLoopCount(-1)
        animation.start()
    def __init__(self):
        super(Robot, self).__init__()

        self.setFlag(self.ItemHasNoContents)

        self.torsoItem = RobotTorso(self)
        self.headItem = RobotHead(self.torsoItem)
        self.upperLeftArmItem = RobotLimb(self.torsoItem)
        self.lowerLeftArmItem = RobotLimb(self.upperLeftArmItem)
        self.upperRightArmItem = RobotLimb(self.torsoItem)
        self.lowerRightArmItem = RobotLimb(self.upperRightArmItem)
        self.upperRightLegItem = RobotLimb(self.torsoItem)
        self.lowerRightLegItem = RobotLimb(self.upperRightLegItem)
        self.upperLeftLegItem = RobotLimb(self.torsoItem)
        self.lowerLeftLegItem = RobotLimb(self.upperLeftLegItem)

        settings = (
            #    Item                       Position        Rotation  Scale
            #                                x     y    start    end
            (self.headItem, 0, -18, 20, -20, 1.1),
            (self.upperLeftArmItem, -15, -10, 190, 180, 0),
            (self.lowerLeftArmItem, 30, 0, 50, 10, 0),
            (self.upperRightArmItem, 15, -10, 300, 310, 0),
            (self.lowerRightArmItem, 30, 0, 0, -70, 0),
            (self.upperRightLegItem, 10, 32, 40, 120, 0),
            (self.lowerRightLegItem, 30, 0, 10, 50, 0),
            (self.upperLeftLegItem, -10, 32, 150, 80, 0),
            (self.lowerLeftLegItem, 30, 0, 70, 10, 0),
            (self.torsoItem, 0, 0, 5, -20, 0),
        )

        animation = QParallelAnimationGroup(self)
        for item, pos_x, pos_y, start_rot, end_rot, scale in settings:
            item.setPos(pos_x, pos_y)

            rot_animation = QPropertyAnimation(item, b"rotation")
            rot_animation.setStartValue(start_rot)
            rot_animation.setEndValue(end_rot)
            rot_animation.setEasingCurve(QEasingCurve.SineCurve)
            rot_animation.setDuration(2000)
            animation.addAnimation(rot_animation)

            if scale > 0:
                scale_animation = QPropertyAnimation(item, b"scale")
                scale_animation.setEndValue(scale)
                scale_animation.setEasingCurve(QEasingCurve.SineCurve)
                scale_animation.setDuration(2000)
                animation.addAnimation(scale_animation)

        animation.setLoopCount(-1)
        animation.start()
Exemple #4
0
    def __init__(self, parent=None):
        super(myobj, self).__init__(parent)

        self.color = QColor(Qt.lightGray)
        animation = QParallelAnimationGroup(self)

        rot_animation = QPropertyAnimation(self, b'rotation')
        rot_animation.setStartValue(-200)
        rot_animation.setEndValue(600)
        rot_animation.setEasingCurve(QEasingCurve.SineCurve)
        rot_animation.setDuration(3000)
        animation.addAnimation(rot_animation)

        animation.setLoopCount(-1)
        animation.start()