Debian Codegraph @

tests/manual/nodetypes_ng/LotsOfRects.qml

raw
1 /****************************************************************************
2 **
3 ** Copyright (C) 2019 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the demonstration applications of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:BSD$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** BSD License Usage
18 ** Alternatively, you may use this file under the terms of the BSD license
19 ** as follows:
20 **
21 ** "Redistribution and use in source and binary forms, with or without
22 ** modification, are permitted provided that the following conditions are
23 ** met:
24 ** * Redistributions of source code must retain the above copyright
25 ** notice, this list of conditions and the following disclaimer.
26 ** * Redistributions in binary form must reproduce the above copyright
27 ** notice, this list of conditions and the following disclaimer in
28 ** the documentation and/or other materials provided with the
29 ** distribution.
30 ** * Neither the name of The Qt Company Ltd nor the names of its
31 ** contributors may be used to endorse or promote products derived
32 ** from this software without specific prior written permission.
33 **
34 **
35 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
36 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
37 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
38 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
39 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
42 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
43 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
44 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
45 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
46 **
47 ** $QT_END_LICENSE$
48 **
49 ****************************************************************************/
50
51 import QtQuick 2.0
52
53 Item {
54 Rectangle {
55 anchors.margins: 4
56 anchors.fill: parent
57
58 // Background
59 gradient: Gradient {
60 GradientStop { position: 0; color: "steelblue" }
61 GradientStop { position: 1; color: "black" }
62 }
63
64 // Animated gradient stops.
65 // NB! Causes a full buffer rebuild on every animated change due to the geometry change!
66 Row {
67 spacing: 10
68 Repeater {
69 model: 20
70 Rectangle {
71 width: 20
72 height: 20
73 gradient: Gradient {
74 GradientStop { position: 0.0; color: "red" }
75 GradientStop { NumberAnimation on position { from: 0.01; to: 0.99; duration: 5000; loops: Animation.Infinite } color: "yellow" }
76 GradientStop { position: 1.0; color: "green" }
77 }
78 }
79 }
80 }
81
82 // Rounded rects with border (smooth material)
83 Row {
84 spacing: 10
85 Repeater {
86 model: 5
87 Rectangle {
88 color: "blue"
89 width: 100
90 height: 50
91 y: 50
92 radius: 16
93 border.color: "red"
94 border.width: 4
95
96 SequentialAnimation on y {
97 loops: Animation.Infinite
98 NumberAnimation {
99 from: 50
100 to: 150
101 duration: 7000
102 }
103 NumberAnimation {
104 from: 150
105 to: 50
106 duration: 3000
107 }
108 }
109 }
110 }
111 }
112
113 // Clip using scissor
114 Row {
115 spacing: 10
116 Repeater {
117 model: 5
118 Rectangle {
119 color: "green"
120 width: 100
121 height: 100
122 y: 150
123 NumberAnimation on y {
124 from: 150
125 to: 200
126 duration: 2000
127 loops: Animation.Infinite
128 }
129 clip: true
130 Rectangle {
131 color: "lightGreen"
132 width: 50
133 height: 50
134 x: 75
135 y: 75
136 }
137 }
138 }
139 }
140
141 // Clip using scissor
142 Row {
143 spacing: 10
144 Repeater {
145 model: 5
146 Rectangle {
147 color: "green"
148 width: 100
149 height: 100
150 y: 300
151 NumberAnimation on y {
152 from: 300
153 to: 400
154 duration: 2000
155 loops: Animation.Infinite
156 }
157 clip: true
158 Rectangle {
159 color: "lightGreen"
160 width: 50
161 height: 50
162 x: 75
163 y: 75
164 NumberAnimation on rotation { from: 0; to: 360; duration: 2000; loops: Animation.Infinite; }
165 }
166 }
167 }
168 }
169
170 // Clip using stencil
171 Row {
172 spacing: 10
173 Repeater {
174 model: 5
175 Rectangle {
176 color: "green"
177 width: 100
178 height: 100
179 y: 450
180 NumberAnimation on y {
181 from: 450
182 to: 550
183 duration: 2000
184 loops: Animation.Infinite
185 }
186 NumberAnimation on rotation { from: 0; to: 360; duration: 2000; loops: Animation.Infinite; }
187 clip: true
188 Rectangle {
189 color: "lightGreen"
190 width: 50
191 height: 50
192 x: 75
193 y: 75
194 }
195 }
196 }
197 }
198
199 // The signature red square with another item with animated opacity blended on top
200 Rectangle {
201 width: 100
202 height: 100
203 anchors.centerIn: parent
204 color: "red"
205 NumberAnimation on rotation { from: 0; to: 360; duration: 2000; loops: Animation.Infinite; }
206
207 Rectangle {
208 color: "gray"
209 width: 50
210 height: 50
211 anchors.centerIn: parent
212
213 SequentialAnimation on opacity {
214 loops: Animation.Infinite
215 NumberAnimation {
216 from: 1.0
217 to: 0.0
218 duration: 4000
219 }
220 NumberAnimation {
221 from: 0.0
222 to: 1.0
223 duration: 4000
224 easing.type: Easing.InOutQuad
225 }
226 }
227 }
228 }
229
230 // Animated size and color.
231 // NB! Causes a full buffer rebuild on every animated change due to the geometry change!
232 Rectangle {
233 anchors.right: parent.right
234 anchors.bottom: parent.bottom
235 width: 10
236 height: 100
237 ColorAnimation on color {
238 from: "blue"
239 to: "purple"
240 duration: 5000
241 loops: Animation.Infinite
242 }
243 NumberAnimation on width {
244 from: 10
245 to: 300
246 duration: 5000
247 loops: Animation.Infinite
248 }
249 }
250
251 // Semi-transparent rect on top.
252 Rectangle {
253 anchors.centerIn: parent
254 opacity: 0.2
255 color: "black"
256 anchors.fill: parent
257 anchors.margins: 10
258 }
259 }
260 }