aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/shapes/cubicCurve.qml
blob: 3fa4ed6f4b8f6951a5dedcb1aab0f21db7875d3f (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick
import QtQuick.Shapes

Rectangle {
    color: "lightGray"
    width: 256
    height: 256

    Item {
        width: 200
        height: 200
        anchors.centerIn: parent

        Shape {
            id: shape
            anchors.fill: parent

            ShapePath {
                strokeWidth: 4
                strokeColor: "black"
                fillGradient: ConicalGradient {
                    id: conGrad
                    centerX: 100
                    centerY: 75
                    NumberAnimation on angle {
                        from: 0
                        to: 360
                        duration: 10000
                        loops: Animation.Infinite
                    }
                    GradientStop {
                        position: 0
                        color: "#00000000"
                    }
                    GradientStop {
                        position: 0.10
                        color: "#ffe0cc73"
                    }
                    GradientStop {
                        position: 0.17
                        color: "#ffc6a006"
                    }
                    GradientStop {
                        position: 0.46
                        color: "#ff600659"
                    }
                    GradientStop {
                        position: 0.72
                        color: "#ff0680ac"
                    }
                    GradientStop {
                        position: 0.92
                        color: "#ffb9d9e6"
                    }
                    GradientStop {
                        position: 1.00
                        color: "#00000000"
                    }
                }

                startX: 50
                startY: 100
                PathCubic {
                    x: 150
                    y: 100
                    control1X: cp1.x
                    control1Y: cp1.y
                    control2X: cp2.x
                    control2Y: cp2.y
                }
            }
        }

        Rectangle {
            id: cp1
            color: "red"
            width: 10
            height: 10
            SequentialAnimation {
                loops: Animation.Infinite
                running: true
                NumberAnimation {
                    target: cp1
                    property: "x"
                    from: 0
                    to: shape.width - cp1.width
                    duration: 5000
                }
                NumberAnimation {
                    target: cp1
                    property: "x"
                    from: shape.width - cp1.width
                    to: 0
                    duration: 5000
                }
                NumberAnimation {
                    target: cp1
                    property: "y"
                    from: 0
                    to: shape.height - cp1.height
                    duration: 5000
                }
                NumberAnimation {
                    target: cp1
                    property: "y"
                    from: shape.height - cp1.height
                    to: 0
                    duration: 5000
                }
            }
        }

        Rectangle {
            id: cp2
            color: "blue"
            width: 10
            height: 10
            x: shape.width - width
            SequentialAnimation {
                loops: Animation.Infinite
                running: true
                NumberAnimation {
                    target: cp2
                    property: "y"
                    from: 0
                    to: shape.height - cp2.height
                    duration: 5000
                }
                NumberAnimation {
                    target: cp2
                    property: "y"
                    from: shape.height - cp2.height
                    to: 0
                    duration: 5000
                }
                NumberAnimation {
                    target: cp2
                    property: "x"
                    from: shape.width - cp2.width
                    to: 0
                    duration: 5000
                }
                NumberAnimation {
                    target: cp2
                    property: "x"
                    from: 0
                    to: shape.width - cp2.width
                    duration: 5000
                }
            }
        }
    }

    Text {
        anchors {
            right: parent.right
            top: parent.top
        }
        text: qsTr("Conical gradient angle: ") + Math.round(conGrad.angle)
    }
}