aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/shapes/tapableTriangle.qml
blob: a3692933004926c60d4bdc41cd52c8e104f717c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick
import QtQuick.Shapes

Rectangle {
    width: 256
    height: 256
    color: th.pressed ? "steelBlue" : "lightGray"
    containmentMask: ctr

    TapHandler { id: th }

    Shape {
        id: ctr
        anchors.fill: parent
        containsMode: Shape.FillContains

        ShapePath {
            strokeColor: "red"
            fillColor: "blue"

            SequentialAnimation on strokeWidth {
                loops: Animation.Infinite
                NumberAnimation { from: 1; to: 30; duration: 5000 }
                NumberAnimation { from: 30; to: 1; duration: 5000 }
                PauseAnimation { duration: 2000 }
            }

            startX: 30; startY: 30
            PathLine { x: ctr.width - 30; y: ctr.height - 30 }
            PathLine { x: 30; y: ctr.height - 30 }
            PathLine { x: 30; y: 30 }
        }

        // Besides ShapePath, Shape supports visual and non-visual objects too, allowing
        // free mixing without going through extra hoops:
        Rectangle {
            id: testRect
            color: "green"
            opacity: 0.3
            width: 20
            height: 20
            anchors.right: parent.right
        }
        Timer {
            interval: 100
            repeat: true
            onTriggered: testRect.width = testRect.width > 1 ? testRect.width - 1 : 20
            running: true
        }
    }
}