Exemple #1
0
def test_rot_center_interval():
    nd = node.Node()
    b = vec2.Vec2(0)
    e = vec2.Vec2(1)
    animation.RotationCenterInterval(nd, 1.0, b, e).play()
    aam = animation.AnimationManager()
    assert nd.traverse() is True
    assert nd.rotation_center == b
    aam.animate(0.5)
    assert nd.traverse() is True
    assert nd.rotation_center == vec2.Vec2(0.5)
    aam.animate(0.5)
    assert nd.traverse() is True
    assert nd.rotation_center == e
    nd.remove()
Exemple #2
0
def test_pos_interval():
    nd = node.Node()
    b = vec2.Vec2(0)
    e = vec2.Vec2(1)
    animation.PosInterval(nd, 1.0, b, e).play()
    aam = animation.AnimationManager()
    assert nd.traverse() is True
    assert nd.pos == b
    aam.animate(0.5)
    assert nd.traverse() is True
    assert nd.pos == vec2.Vec2(0.5)
    aam.animate(0.5)
    assert nd.traverse() is True
    assert nd.pos == e
    nd.remove()
Exemple #3
0
def test_rotation_interval():
    nd = node.Node()
    b = 0.0
    e = 180.0
    animation.RotationInterval(nd, 1.0, b, e).play()
    aam = animation.AnimationManager()
    assert nd.traverse() is True
    assert nd.angle == b
    aam.animate(0.5)
    assert nd.traverse() is True
    assert nd.angle == 90.0
    aam.animate(0.5)
    assert nd.traverse() is True
    assert nd.angle == e
    nd.remove()
Exemple #4
0
def test_depth_animation():
    nd = node.Node()
    b = 1
    e = 11
    animation.DepthAnimation(nd, 10, b, e).play()
    aam = animation.AnimationManager()
    assert nd.traverse() is True
    assert nd.depth == b
    aam.animate(0.5)
    assert nd.traverse() is True
    assert nd.depth == 6
    aam.animate(0.5)
    assert nd.traverse() is True
    assert nd.depth == e
    nd.remove()
Exemple #5
0
def test_scale_interval():
    nd = node.Node()
    b = 1.0, 2.0
    e = 2.0, 1.0
    nd.scale = b
    animation.ScaleInterval(nd, 1.0, b, e).play()
    aam = animation.AnimationManager()
    assert nd.traverse() is True
    assert nd.scale == b
    aam.animate(0.5)
    assert nd.traverse() is True
    assert nd.scale == (1.5, 1.5)
    aam.animate(0.5)
    assert nd.traverse() is True
    assert nd.scale == e
    nd.remove()
Exemple #6
0
def test_combined_interval():
    nd = node.Node()
    pb = vec2.Vec2(0)
    pe = vec2.Vec2(1)
    db = 1
    de = 11
    ival = animation.PosInterval(nd, 1.0, pb, pe)
    ival += animation.DepthInterval(nd, 1.0, db, de)
    ival.play()
    aam = animation.AnimationManager()
    assert nd.traverse() is True
    assert nd.pos == pb
    assert nd.depth == db
    aam.animate(0.5)
    assert nd.traverse() is True
    assert nd.pos == vec2.Vec2(0.5)
    assert nd.depth == 6
    aam.animate(0.5)
    assert nd.traverse() is True
    assert nd.pos == pe
    assert nd.depth == de
    nd.remove()
Exemple #7
0
def create_empty_nd():
    """Setup function to create an empty Node."""
    nd = node.Node()
    nd.size = 1.0, 1.0
    nd.traverse()
    return nd
Exemple #8
0
    def __init__(self, card_ratio: float, padding: float,
                 status_size: Tuple[float, float],
                 toolbar_size: Tuple[float, float]) -> None:
        card_size = (1 / (7 + 8 * padding),
                     card_ratio * (1 / (7 + 8 * padding)))
        self._cfg = TableConfig(card_size=card_size,
                                padding=(card_size[0] * padding,
                                         card_size[1] * padding),
                                status_size=status_size,
                                toolbar_size=toolbar_size)
        root = node.Node('Table Root')
        root.distance_relative = True
        root.depth = -100
        self._nodes = TableNodes(
            root=root,
            stack=root.attach_image_node('Stack', common.STACK),
            waste=root.attach_node('Waste Root'),
            foundation=root.attach_node('Foundation Root'),
            tableau=root.attach_node('Tableau Root'),
            status=root.attach_node('Status'),
            toolbar=root.attach_node('Toolbar'))
        self._children = ChildNodes(
            waste=[
                self._nodes.waste.attach_image_node(f'Waste {i}', common.WASTE)
                if not i else self._nodes.waste.attach_node(f'Waste {i}')
                for i in range(4)
            ],
            foundation=[
                self._nodes.foundation.attach_image_node(
                    f'Foundation {i}', common.FOUNDATION) for i in range(4)
            ],
            tableau=[
                self._nodes.tableau.attach_image_node(f'Tableau {i}',
                                                      common.TABLEAU)
                for i in range(7)
            ])

        # Background
        background = self._nodes.root.attach_node('BG Root')
        background.depth = -500
        offset = .1
        for x_pos in range(26):
            for y_pos in range(26):
                tmp_node = background.attach_image_node(
                    image=common.BACKGROUND)
                tmp_node.pos = x_pos * offset, y_pos * offset
        self._v_offset = (0.0, self._cfg.card_size[1] / 3)

        # Cards
        card_dummy = self._nodes.root.attach_node('Card Layer')
        card_dummy.depth = 99
        self._cards: Dict[Tuple[int, int], CardNode] = {
            (suit, value):
            CardNode(k=(suit, value),
                     node=card_dummy.attach_image_node(
                         f'{suit},{value}', f'images/{common.COLORS[suit]}'
                         f'{common.DENOMINATIONS[value]}.png'),
                     location=common.TableLocation(area=common.TableArea.NONE,
                                                   visible=False))
            for suit in range(4) for value in range(13)
        }
        for k in self._cards:
            self._cards[k].node.add_image(common.CARDBACK)
            self._cards[k].node.index = 1

        self._drag_info: DragInfo = DragInfo()
        self._depth_queue = DepthQueue()
        self._relative_positions = RelativePositions(
            stack=vec2.Vec2(),
            waste=[vec2.Vec2() for _ in range(4)],
            foundation=[vec2.Vec2() for _ in range(4)],
            tableau=[vec2.Vec2() for _ in range(7)])
        self._table: Optional[Table] = None