aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/multieffect/itemswitcher/qml/SwitchEffectThunder.qml
blob: ba26675dd79483f62b67dfcfb3a54626249696b6 (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
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick
import QtQuick.Effects

Item {
    id: rootItem
    // We expect all effects to be placed under ItemSwitcher
    property Item switcher: rootItem.parent

    property real _xPos: Math.sin(switcher.inAnimation * Math.PI * 50) * width * 0.03 * (0.5 - Math.abs(0.5 - switcher.inAnimation))
    property real _yPos: Math.sin(switcher.inAnimation * Math.PI * 35) * width * 0.02 * (0.5 - Math.abs(0.5 - switcher.inAnimation))

    anchors.fill: parent

    Image {
        id: maskImage
        source: "images/stripes.png"
        visible: false
    }

    MultiEffect {
        source: switcher.fromItem
        width: parent.width
        height: parent.height
        x: rootItem._xPos
        y: rootItem._yPos
        blurEnabled: true
        blur: switcher.inAnimation
        blurMax: 32
        blurMultiplier: 0.5
        opacity: switcher.outAnimation
        colorizeColor: "#f0d060"
        colorize: switcher.inAnimation

        contrast: switcher.inAnimation
        brightness: switcher.inAnimation

        maskEnabled: true
        maskSource: maskImage
        maskThresholdLow: switcher.inAnimation * 0.9
        maskSpreadLow: 0.2
        maskThresholdUp: 1.0

        shadowEnabled: true
        shadowColor: "#f04000"
        shadowBlur: 1.0
        shadowOpacity: 5.0 - switcher.outAnimation * 5.0
        shadowHorizontalOffset: 0
        shadowVerticalOffset: 0
        shadowScale: 1.04

    }
    MultiEffect {
        source: switcher.toItem
        width: parent.width
        height: parent.height
        x: -rootItem._xPos
        y: -rootItem._yPos
        blurEnabled: true
        blur: switcher.outAnimation * 2
        blurMax: 32
        blurMultiplier: 0.5
        opacity: switcher.inAnimation * 3.0 - 1.0

        colorizeColor: "#f0d060"
        colorize: switcher.outAnimation
        contrast: switcher.outAnimation
        brightness: switcher.outAnimation

        maskEnabled: true
        maskSource: maskImage
        maskThresholdLow: switcher.outAnimation * 0.6
        maskSpreadLow: 0.2
        maskThresholdUp: 1.0

        shadowEnabled: true
        shadowColor: "#f04000"
        shadowBlur: 1.0
        shadowOpacity: 5.0 - switcher.inAnimation * 5.0
        shadowHorizontalOffset: 0
        shadowVerticalOffset: 0
        shadowScale: 1.04
    }

}