aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/quickshapes/shapes/tapableTriangle.qml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/quick/quickshapes/shapes/tapableTriangle.qml')
-rw-r--r--examples/quick/quickshapes/shapes/tapableTriangle.qml76
1 files changed, 76 insertions, 0 deletions
diff --git a/examples/quick/quickshapes/shapes/tapableTriangle.qml b/examples/quick/quickshapes/shapes/tapableTriangle.qml
new file mode 100644
index 0000000000..c76821e898
--- /dev/null
+++ b/examples/quick/quickshapes/shapes/tapableTriangle.qml
@@ -0,0 +1,76 @@
+// 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
+ }
+ }
+}