From 643da502885bb3ad4cd0fd7f0e4d08edba598c96 Mon Sep 17 00:00:00 2001 From: artoka Date: Thu, 17 Nov 2011 15:49:57 +0100 Subject: shadereffects example modifications Modified the example to use centralized qmlapplicationviewer, removed duplicate files and modified project files according to the changes. Merge-request: 2719 Reviewed-by: Casper van Donderen --- examples/declarative/shadereffects/main.cpp | 19 +-- examples/declarative/shadereffects/qml/Curtain.qml | 106 ------------- .../shadereffects/qml/CurtainEffect.qml | 97 ------------ .../declarative/shadereffects/qml/DropShadow.qml | 117 -------------- .../shadereffects/qml/DropShadowEffect.qml | 174 --------------------- .../declarative/shadereffects/qml/Grayscale.qml | 77 --------- .../shadereffects/qml/GrayscaleEffect.qml | 62 -------- .../declarative/shadereffects/qml/ImageMask.qml | 143 ----------------- .../shadereffects/qml/ImageMaskEffect.qml | 60 ------- .../declarative/shadereffects/qml/RadialWave.qml | 85 ---------- .../shadereffects/qml/RadialWaveEffect.qml | 81 ---------- examples/declarative/shadereffects/qml/Water.qml | 60 ------- .../declarative/shadereffects/qml/WaterEffect.qml | 126 --------------- .../shadereffects/qml/images/Curtain.jpg | Bin 16112 -> 0 bytes .../shadereffects/qml/images/DropShadow.jpg | Bin 12975 -> 0 bytes .../shadereffects/qml/images/Grayscale.jpg | Bin 19048 -> 0 bytes .../shadereffects/qml/images/ImageMask.jpg | Bin 18751 -> 0 bytes .../shadereffects/qml/images/RadialWave.jpg | Bin 41406 -> 0 bytes .../declarative/shadereffects/qml/images/Water.jpg | Bin 17751 -> 0 bytes .../declarative/shadereffects/qml/images/back.png | Bin 370 -> 0 bytes .../declarative/shadereffects/qml/images/bg.jpg | Bin 10189 -> 0 bytes .../shadereffects/qml/images/desaturate.jpg | Bin 203942 -> 0 bytes .../shadereffects/qml/images/drop_shadow.png | Bin 219220 -> 0 bytes .../shadereffects/qml/images/fabric.jpg | Bin 163431 -> 0 bytes .../shadereffects/qml/images/flower.png | Bin 219220 -> 0 bytes .../shadereffects/qml/images/image1.jpg | Bin 115770 -> 0 bytes .../shadereffects/qml/images/image2.jpg | Bin 45837 -> 0 bytes .../shadereffects/qml/images/qt-logo.png | Bin 22746 -> 0 bytes .../shadereffects/qml/images/shader_effects.jpg | Bin 4906 -> 0 bytes .../declarative/shadereffects/qml/images/sky.jpg | Bin 36734 -> 0 bytes .../shadereffects/qml/images/toolbar.png | Bin 342 -> 0 bytes .../declarative/shadereffects/qml/images/wave.jpg | Bin 176681 -> 0 bytes examples/declarative/shadereffects/qml/main.qml | 160 ------------------- .../shadereffects/qml/shadereffects/Curtain.qml | 106 +++++++++++++ .../qml/shadereffects/CurtainEffect.qml | 97 ++++++++++++ .../shadereffects/qml/shadereffects/DropShadow.qml | 117 ++++++++++++++ .../qml/shadereffects/DropShadowEffect.qml | 174 +++++++++++++++++++++ .../shadereffects/qml/shadereffects/Grayscale.qml | 77 +++++++++ .../qml/shadereffects/GrayscaleEffect.qml | 62 ++++++++ .../shadereffects/qml/shadereffects/ImageMask.qml | 143 +++++++++++++++++ .../qml/shadereffects/ImageMaskEffect.qml | 60 +++++++ .../shadereffects/qml/shadereffects/RadialWave.qml | 85 ++++++++++ .../qml/shadereffects/RadialWaveEffect.qml | 81 ++++++++++ .../shadereffects/qml/shadereffects/Water.qml | 60 +++++++ .../qml/shadereffects/WaterEffect.qml | 126 +++++++++++++++ .../qml/shadereffects/images/Curtain.jpg | Bin 0 -> 16112 bytes .../qml/shadereffects/images/DropShadow.jpg | Bin 0 -> 12975 bytes .../qml/shadereffects/images/Grayscale.jpg | Bin 0 -> 19048 bytes .../qml/shadereffects/images/ImageMask.jpg | Bin 0 -> 18751 bytes .../qml/shadereffects/images/RadialWave.jpg | Bin 0 -> 41406 bytes .../qml/shadereffects/images/Water.jpg | Bin 0 -> 17751 bytes .../qml/shadereffects/images/back.png | Bin 0 -> 370 bytes .../shadereffects/qml/shadereffects/images/bg.jpg | Bin 0 -> 10189 bytes .../qml/shadereffects/images/desaturate.jpg | Bin 0 -> 203942 bytes .../qml/shadereffects/images/drop_shadow.png | Bin 0 -> 219220 bytes .../qml/shadereffects/images/fabric.jpg | Bin 0 -> 163431 bytes .../qml/shadereffects/images/flower.png | Bin 0 -> 219220 bytes .../qml/shadereffects/images/image1.jpg | Bin 0 -> 115770 bytes .../qml/shadereffects/images/image2.jpg | Bin 0 -> 45837 bytes .../qml/shadereffects/images/qt-logo.png | Bin 0 -> 22746 bytes .../qml/shadereffects/images/shader_effects.jpg | Bin 0 -> 4906 bytes .../shadereffects/qml/shadereffects/images/sky.jpg | Bin 0 -> 36734 bytes .../qml/shadereffects/images/toolbar.png | Bin 0 -> 342 bytes .../qml/shadereffects/images/wave.jpg | Bin 0 -> 176681 bytes .../shadereffects/qml/shadereffects/main.qml | 160 +++++++++++++++++++ .../declarative/shadereffects/shadereffects.pro | 48 ++++-- .../shadereffects/shadereffects.qmlproject | 16 ++ 67 files changed, 1409 insertions(+), 1370 deletions(-) delete mode 100755 examples/declarative/shadereffects/qml/Curtain.qml delete mode 100755 examples/declarative/shadereffects/qml/CurtainEffect.qml delete mode 100755 examples/declarative/shadereffects/qml/DropShadow.qml delete mode 100755 examples/declarative/shadereffects/qml/DropShadowEffect.qml delete mode 100755 examples/declarative/shadereffects/qml/Grayscale.qml delete mode 100755 examples/declarative/shadereffects/qml/GrayscaleEffect.qml delete mode 100755 examples/declarative/shadereffects/qml/ImageMask.qml delete mode 100755 examples/declarative/shadereffects/qml/ImageMaskEffect.qml delete mode 100755 examples/declarative/shadereffects/qml/RadialWave.qml delete mode 100755 examples/declarative/shadereffects/qml/RadialWaveEffect.qml delete mode 100755 examples/declarative/shadereffects/qml/Water.qml delete mode 100755 examples/declarative/shadereffects/qml/WaterEffect.qml delete mode 100755 examples/declarative/shadereffects/qml/images/Curtain.jpg delete mode 100755 examples/declarative/shadereffects/qml/images/DropShadow.jpg delete mode 100755 examples/declarative/shadereffects/qml/images/Grayscale.jpg delete mode 100755 examples/declarative/shadereffects/qml/images/ImageMask.jpg delete mode 100755 examples/declarative/shadereffects/qml/images/RadialWave.jpg delete mode 100755 examples/declarative/shadereffects/qml/images/Water.jpg delete mode 100755 examples/declarative/shadereffects/qml/images/back.png delete mode 100755 examples/declarative/shadereffects/qml/images/bg.jpg delete mode 100755 examples/declarative/shadereffects/qml/images/desaturate.jpg delete mode 100755 examples/declarative/shadereffects/qml/images/drop_shadow.png delete mode 100755 examples/declarative/shadereffects/qml/images/fabric.jpg delete mode 100755 examples/declarative/shadereffects/qml/images/flower.png delete mode 100755 examples/declarative/shadereffects/qml/images/image1.jpg delete mode 100755 examples/declarative/shadereffects/qml/images/image2.jpg delete mode 100755 examples/declarative/shadereffects/qml/images/qt-logo.png delete mode 100755 examples/declarative/shadereffects/qml/images/shader_effects.jpg delete mode 100755 examples/declarative/shadereffects/qml/images/sky.jpg delete mode 100755 examples/declarative/shadereffects/qml/images/toolbar.png delete mode 100755 examples/declarative/shadereffects/qml/images/wave.jpg delete mode 100755 examples/declarative/shadereffects/qml/main.qml create mode 100644 examples/declarative/shadereffects/qml/shadereffects/Curtain.qml create mode 100644 examples/declarative/shadereffects/qml/shadereffects/CurtainEffect.qml create mode 100644 examples/declarative/shadereffects/qml/shadereffects/DropShadow.qml create mode 100644 examples/declarative/shadereffects/qml/shadereffects/DropShadowEffect.qml create mode 100644 examples/declarative/shadereffects/qml/shadereffects/Grayscale.qml create mode 100644 examples/declarative/shadereffects/qml/shadereffects/GrayscaleEffect.qml create mode 100644 examples/declarative/shadereffects/qml/shadereffects/ImageMask.qml create mode 100644 examples/declarative/shadereffects/qml/shadereffects/ImageMaskEffect.qml create mode 100644 examples/declarative/shadereffects/qml/shadereffects/RadialWave.qml create mode 100644 examples/declarative/shadereffects/qml/shadereffects/RadialWaveEffect.qml create mode 100644 examples/declarative/shadereffects/qml/shadereffects/Water.qml create mode 100644 examples/declarative/shadereffects/qml/shadereffects/WaterEffect.qml create mode 100644 examples/declarative/shadereffects/qml/shadereffects/images/Curtain.jpg create mode 100644 examples/declarative/shadereffects/qml/shadereffects/images/DropShadow.jpg create mode 100644 examples/declarative/shadereffects/qml/shadereffects/images/Grayscale.jpg create mode 100644 examples/declarative/shadereffects/qml/shadereffects/images/ImageMask.jpg create mode 100644 examples/declarative/shadereffects/qml/shadereffects/images/RadialWave.jpg create mode 100644 examples/declarative/shadereffects/qml/shadereffects/images/Water.jpg create mode 100644 examples/declarative/shadereffects/qml/shadereffects/images/back.png create mode 100644 examples/declarative/shadereffects/qml/shadereffects/images/bg.jpg create mode 100644 examples/declarative/shadereffects/qml/shadereffects/images/desaturate.jpg create mode 100644 examples/declarative/shadereffects/qml/shadereffects/images/drop_shadow.png create mode 100644 examples/declarative/shadereffects/qml/shadereffects/images/fabric.jpg create mode 100644 examples/declarative/shadereffects/qml/shadereffects/images/flower.png create mode 100644 examples/declarative/shadereffects/qml/shadereffects/images/image1.jpg create mode 100644 examples/declarative/shadereffects/qml/shadereffects/images/image2.jpg create mode 100644 examples/declarative/shadereffects/qml/shadereffects/images/qt-logo.png create mode 100644 examples/declarative/shadereffects/qml/shadereffects/images/shader_effects.jpg create mode 100644 examples/declarative/shadereffects/qml/shadereffects/images/sky.jpg create mode 100644 examples/declarative/shadereffects/qml/shadereffects/images/toolbar.png create mode 100644 examples/declarative/shadereffects/qml/shadereffects/images/wave.jpg create mode 100644 examples/declarative/shadereffects/qml/shadereffects/main.qml create mode 100644 examples/declarative/shadereffects/shadereffects.qmlproject diff --git a/examples/declarative/shadereffects/main.cpp b/examples/declarative/shadereffects/main.cpp index c284b99..e191bfa 100755 --- a/examples/declarative/shadereffects/main.cpp +++ b/examples/declarative/shadereffects/main.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ +#include "qmlapplicationviewer.h" #include #include #include @@ -53,7 +54,7 @@ int main(int argc, char *argv[]) #endif QApplication app(argc, argv); - QDeclarativeView view; + QmlApplicationViewer viewer; #ifndef SHADEREFFECTS_USE_OPENGL_GRAPHICSSYSTEM QGLFormat format = QGLFormat::defaultFormat(); @@ -61,16 +62,16 @@ int main(int argc, char *argv[]) format.setSwapInterval(1); QGLWidget* glWidget = new QGLWidget(format); glWidget->setAutoFillBackground(false); - view.setViewport(glWidget); + viewer.setViewport(glWidget); #endif - view.setViewportUpdateMode(QGraphicsView::FullViewportUpdate); - view.setAttribute(Qt::WA_OpaquePaintEvent); - view.setAttribute(Qt::WA_NoSystemBackground); - view.setSource(QUrl::fromLocalFile(QLatin1String("qml/main.qml"))); - QObject::connect(view.engine(), SIGNAL(quit()), &view, SLOT(close())); - - view.show(); + viewer.setViewportUpdateMode(QGraphicsView::FullViewportUpdate); + viewer.setAttribute(Qt::WA_OpaquePaintEvent); + viewer.setAttribute(Qt::WA_NoSystemBackground); + viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); + viewer.setMainQmlFile(QLatin1String("qml/shadereffects/main.qml")); + QObject::connect(viewer.engine(), SIGNAL(quit()), &viewer, SLOT(close())); + viewer.showExpanded(); return app.exec(); } diff --git a/examples/declarative/shadereffects/qml/Curtain.qml b/examples/declarative/shadereffects/qml/Curtain.qml deleted file mode 100755 index 03ac0e9..0000000 --- a/examples/declarative/shadereffects/qml/Curtain.qml +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import Qt.labs.shaders 1.0 - -Item { - id: main - anchors.fill: parent - - Rectangle{ - id: bg - anchors.fill: parent - color: "black" - } - - Image { - source: "images/qt-logo.png" - anchors.centerIn: parent - } - - Image { - id: fabric - anchors.fill: parent - source: "images/fabric.jpg" - fillMode: Image.Tile - } - - CurtainEffect { - id: curtain - anchors.fill: fabric - bottomWidth: topWidth - source: ShaderEffectSource { sourceItem: fabric; hideSource: true } - - Behavior on bottomWidth { - SpringAnimation { easing.type: Easing.OutElastic; velocity: 250; mass: 1.5; spring: 0.5; damping: 0.05} - } - - SequentialAnimation on topWidth { - id: topWidthAnim - loops: Animation.Infinite - - NumberAnimation { to: 360; duration: 1000 } - PauseAnimation { duration: 2000 } - NumberAnimation { to: 180; duration: 1000 } - PauseAnimation { duration: 2000 } - } - } - - MouseArea { - anchors.fill: parent - - onPressed: { - topWidthAnim.stop() - curtain.topWidth = mouseX; - } - - onReleased: { - topWidthAnim.restart() - } - - onPositionChanged: { - if (pressed) { - curtain.topWidth = mouseX; - } - } - } -} diff --git a/examples/declarative/shadereffects/qml/CurtainEffect.qml b/examples/declarative/shadereffects/qml/CurtainEffect.qml deleted file mode 100755 index c33cce4..0000000 --- a/examples/declarative/shadereffects/qml/CurtainEffect.qml +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import Qt.labs.shaders 1.0 - -ShaderEffectItem { - anchors.fill: parent - property variant source - meshResolution: Qt.size(50, 50) - - property real topWidth: width / 2 - property real bottomWidth: width / 2 - property real originalWidth: width - property real originalHeight: height - property real amplitude: 0.1 - - vertexShader: " - attribute highp vec4 qt_Vertex; - attribute highp vec2 qt_MultiTexCoord0; - uniform highp mat4 qt_ModelViewProjectionMatrix; - varying highp vec2 qt_TexCoord0; - varying lowp float shade; - - uniform highp float topWidth; - uniform highp float bottomWidth; - uniform highp float originalWidth; - uniform highp float originalHeight; - uniform highp float amplitude; - - void main() { - qt_TexCoord0 = qt_MultiTexCoord0; - - highp vec4 shift = vec4(0, 0, 0, 0); - shift.x = qt_Vertex.x * ((originalWidth - topWidth) + (topWidth - bottomWidth) * (qt_Vertex.y / originalHeight)) / originalWidth; - - shade = sin(21.9911486 * qt_Vertex.x / originalWidth); - shift.y = amplitude * (originalWidth - topWidth + (topWidth - bottomWidth) * (qt_Vertex.y / originalHeight)) * shade; - - gl_Position = qt_ModelViewProjectionMatrix * (qt_Vertex - shift); - - shade = 0.2 * (2.0 - shade ) * (1.0 - (bottomWidth + (topWidth - bottomWidth) * (1.0 - qt_Vertex.y / originalHeight)) / originalWidth); - } - " - - fragmentShader: " - uniform sampler2D source; - varying highp vec2 qt_TexCoord0; - varying lowp float shade; - void main() { - highp vec4 color = texture2D(source, qt_TexCoord0); - color.rgb *= 1.0 - shade; - gl_FragColor = color; - } - " -} - - - diff --git a/examples/declarative/shadereffects/qml/DropShadow.qml b/examples/declarative/shadereffects/qml/DropShadow.qml deleted file mode 100755 index 442fb38..0000000 --- a/examples/declarative/shadereffects/qml/DropShadow.qml +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Item { - id: main - anchors.fill: parent - - Image { - id: background - anchors.fill: parent - source: "images/bg.jpg" - } - - DropShadowEffect { - id: layer - - property real distance: 0.0 - - width: photo.width - height: photo.height - sourceItem: photo - color: "black" - blur: distance / 10.0 - opacity: 1 - distance / 50.0 - - Binding { - target: layer - property: "x" - value: -0.4 * layer.distance - when: !dragArea.pressed - } - Binding { - target: layer - property: "y" - value: 0.9 * layer.distance - when: !dragArea.pressed - } - - SequentialAnimation on distance { - id: animation - running: true - loops: Animation.Infinite - - NumberAnimation { to: 30; duration: 2000 } - PauseAnimation { duration: 500 } - NumberAnimation { to: 0; duration: 2000 } - PauseAnimation { duration: 500 } - } - } - - Image { - id: photo - anchors.fill: parent - source: "images/drop_shadow.png" - smooth: true - } - - MouseArea { - id: dragArea - anchors.fill: parent - - property int startX - property int startY - - onPressed: { - startX = mouseX - startY = mouseY - } - - onPositionChanged: { - layer.x += mouseX - startX - layer.y += mouseY - startY - startX = mouseX - startY = mouseY - } - } -} diff --git a/examples/declarative/shadereffects/qml/DropShadowEffect.qml b/examples/declarative/shadereffects/qml/DropShadowEffect.qml deleted file mode 100755 index 71b6ac9..0000000 --- a/examples/declarative/shadereffects/qml/DropShadowEffect.qml +++ /dev/null @@ -1,174 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import Qt.labs.shaders 1.0 - -Item { - id: main - property real blur: 0.0 - property alias color: shadowEffectWithHBlur.color - property alias sourceItem: source.sourceItem - - ShaderEffectSource { - id: source - smooth: true - hideSource: false - } - - ShaderEffectItem { - id: shadowEffectWithHBlur - anchors.fill: parent - - property color color: "grey" - property variant sourceTexture: source; - property real xStep: main.blur / main.width - - vertexShader:" - uniform highp mat4 qt_ModelViewProjectionMatrix; - attribute highp vec4 qt_Vertex; - attribute highp vec2 qt_MultiTexCoord0; - uniform highp float xStep; - varying highp vec2 qt_TexCoord0; - varying highp vec2 qt_TexCoord1; - varying highp vec2 qt_TexCoord2; - varying highp vec2 qt_TexCoord4; - varying highp vec2 qt_TexCoord5; - varying highp vec2 qt_TexCoord6; - - void main(void) - { - highp vec2 shift = vec2(xStep, 0.); - qt_TexCoord0 = qt_MultiTexCoord0 - 2.5 * shift; - qt_TexCoord1 = qt_MultiTexCoord0 - 1.5 * shift; - qt_TexCoord2 = qt_MultiTexCoord0 - 0.5 * shift; - qt_TexCoord4 = qt_MultiTexCoord0 + 0.5 * shift; - qt_TexCoord5 = qt_MultiTexCoord0 + 1.5 * shift; - qt_TexCoord6 = qt_MultiTexCoord0 + 2.5 * shift; - gl_Position = qt_ModelViewProjectionMatrix * qt_Vertex; - } - " - - fragmentShader:" - uniform highp vec4 color; - uniform lowp sampler2D sourceTexture; - varying highp vec2 qt_TexCoord0; - varying highp vec2 qt_TexCoord1; - varying highp vec2 qt_TexCoord2; - varying highp vec2 qt_TexCoord4; - varying highp vec2 qt_TexCoord5; - varying highp vec2 qt_TexCoord6; - - void main() { - highp vec4 sourceColor = (texture2D(sourceTexture, qt_TexCoord0) * 0.1 - + texture2D(sourceTexture, qt_TexCoord1) * 0.15 - + texture2D(sourceTexture, qt_TexCoord2) * 0.25 - + texture2D(sourceTexture, qt_TexCoord4) * 0.25 - + texture2D(sourceTexture, qt_TexCoord5) * 0.15 - + texture2D(sourceTexture, qt_TexCoord6) * 0.1); - gl_FragColor = mix(vec4(0), color, sourceColor.a); - } - " - } - - ShaderEffectSource { - id: hBlurredShadow - smooth: true - sourceItem: shadowEffectWithHBlur - hideSource: true - } - - ShaderEffectItem { - id: finalEffect - anchors.fill: parent - - property color color: "grey" - property variant sourceTexture: hBlurredShadow; - property real yStep: main.blur / main.height - - vertexShader:" - uniform highp mat4 qt_ModelViewProjectionMatrix; - attribute highp vec4 qt_Vertex; - attribute highp vec2 qt_MultiTexCoord0; - uniform highp float yStep; - varying highp vec2 qt_TexCoord0; - varying highp vec2 qt_TexCoord1; - varying highp vec2 qt_TexCoord2; - varying highp vec2 qt_TexCoord4; - varying highp vec2 qt_TexCoord5; - varying highp vec2 qt_TexCoord6; - - void main(void) - { - highp vec2 shift = vec2(0., yStep); - qt_TexCoord0 = qt_MultiTexCoord0 - 2.5 * shift; - qt_TexCoord1 = qt_MultiTexCoord0 - 1.5 * shift; - qt_TexCoord2 = qt_MultiTexCoord0 - 0.5 * shift; - qt_TexCoord4 = qt_MultiTexCoord0 + 0.5 * shift; - qt_TexCoord5 = qt_MultiTexCoord0 + 1.5 * shift; - qt_TexCoord6 = qt_MultiTexCoord0 + 2.5 * shift; - gl_Position = qt_ModelViewProjectionMatrix * qt_Vertex; - } - " - - fragmentShader:" - uniform highp vec4 color; - uniform lowp sampler2D sourceTexture; - uniform highp float qt_Opacity; - varying highp vec2 qt_TexCoord0; - varying highp vec2 qt_TexCoord1; - varying highp vec2 qt_TexCoord2; - varying highp vec2 qt_TexCoord4; - varying highp vec2 qt_TexCoord5; - varying highp vec2 qt_TexCoord6; - - void main() { - highp vec4 sourceColor = (texture2D(sourceTexture, qt_TexCoord0) * 0.1 - + texture2D(sourceTexture, qt_TexCoord1) * 0.15 - + texture2D(sourceTexture, qt_TexCoord2) * 0.25 - + texture2D(sourceTexture, qt_TexCoord4) * 0.25 - + texture2D(sourceTexture, qt_TexCoord5) * 0.15 - + texture2D(sourceTexture, qt_TexCoord6) * 0.1); - gl_FragColor = sourceColor * qt_Opacity; - } - " - } -} diff --git a/examples/declarative/shadereffects/qml/Grayscale.qml b/examples/declarative/shadereffects/qml/Grayscale.qml deleted file mode 100755 index 58c94fc..0000000 --- a/examples/declarative/shadereffects/qml/Grayscale.qml +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import Qt.labs.shaders 1.0 - -Item { - id: main - anchors.fill: parent - - GrayscaleEffect { - id: layer - anchors.fill: parent - - source: ShaderEffectSource { - sourceItem: Image { source: "images/desaturate.jpg" } - live: false - hideSource: true - } - - SequentialAnimation on ratio { - id: ratioAnimation - running: true - loops: Animation.Infinite - NumberAnimation { - easing.type: Easing.Linear - to: 0.0 - duration: 1500 - } - PauseAnimation { duration: 1000 } - NumberAnimation { - easing.type: Easing.Linear - to: 1.0 - duration: 1500 - } - PauseAnimation { duration: 1000 } - } - } -} diff --git a/examples/declarative/shadereffects/qml/GrayscaleEffect.qml b/examples/declarative/shadereffects/qml/GrayscaleEffect.qml deleted file mode 100755 index 0343893..0000000 --- a/examples/declarative/shadereffects/qml/GrayscaleEffect.qml +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import Qt.labs.shaders 1.0 - -ShaderEffectItem { - id: effect - property real ratio: 1.0 - property variant source: 0 - - fragmentShader: - " - varying highp vec2 qt_TexCoord0; - uniform sampler2D source; - uniform highp float ratio; - void main(void) - { - lowp vec4 textureColor = texture2D(source, qt_TexCoord0.st); - lowp float gray = dot(textureColor, vec4(0.299, 0.587, 0.114, 0.0)); - gl_FragColor = vec4(gray * ratio + textureColor.r * (1.0 - ratio), gray * ratio + textureColor.g * (1.0 - ratio), gray * ratio + textureColor.b * (1.0 - ratio), textureColor.a); - } - " -} diff --git a/examples/declarative/shadereffects/qml/ImageMask.qml b/examples/declarative/shadereffects/qml/ImageMask.qml deleted file mode 100755 index 068696e..0000000 --- a/examples/declarative/shadereffects/qml/ImageMask.qml +++ /dev/null @@ -1,143 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import Qt.labs.shaders 1.0 - -Item { - anchors.fill: parent - - Image { - id: bg - anchors.fill: parent - source: "images/image2.jpg" - } - - Item { - id: mask - anchors.fill: parent - - Text { - text: "Mask text" - font.pixelSize: 50 - font.bold: true - anchors.horizontalCenter: parent.horizontalCenter - - NumberAnimation on rotation { - running: true - loops: Animation.Infinite - from: 0 - to: 360 - duration: 3000 - } - - SequentialAnimation on y { - running: true - loops: Animation.Infinite - NumberAnimation { - to: main.height - duration: 3000 - } - NumberAnimation { - to: 0 - duration: 3000 - } - } - } - - Rectangle { - id: opaqueBox - width: 60 - height: parent.height - SequentialAnimation on x { - running: true - loops: Animation.Infinite - NumberAnimation { - to: main.width - duration: 2000 - easing.type: Easing.InOutCubic - } - NumberAnimation { - to: 0 - duration: 2000 - easing.type: Easing.InOutCubic - } - } - } - - Rectangle { - width: 100 - opacity: 0.5 - height: parent.height - SequentialAnimation on x { - PauseAnimation { duration: 100 } - - SequentialAnimation { - loops: Animation.Infinite - NumberAnimation { - to: main.width - duration: 2000 - easing.type: Easing.InOutCubic - } - NumberAnimation { - to: 0 - duration: 2000 - easing.type: Easing.InOutCubic - } - } - } - } - } - - ImageMaskEffect { - anchors.fill: parent - image: ShaderEffectSource { - sourceItem: Image { source: "images/image1.jpg" } - live: false - hideSource: true - } - mask: ShaderEffectSource { - sourceItem: mask - live: true - hideSource: true - } - } -} diff --git a/examples/declarative/shadereffects/qml/ImageMaskEffect.qml b/examples/declarative/shadereffects/qml/ImageMaskEffect.qml deleted file mode 100755 index e4dddf4..0000000 --- a/examples/declarative/shadereffects/qml/ImageMaskEffect.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import Qt.labs.shaders 1.0 - -ShaderEffectItem { - id: effect - property variant image: 0 - property variant mask: 0 - - fragmentShader: - " - varying highp vec2 qt_TexCoord0; - uniform sampler2D image; - uniform sampler2D mask; - void main(void) - { - gl_FragColor = texture2D(image, qt_TexCoord0.st) * (texture2D(mask, qt_TexCoord0.st).a); - } - " -} diff --git a/examples/declarative/shadereffects/qml/RadialWave.qml b/examples/declarative/shadereffects/qml/RadialWave.qml deleted file mode 100755 index 5aaac9e..0000000 --- a/examples/declarative/shadereffects/qml/RadialWave.qml +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import Qt.labs.shaders 1.0 - -Item { - id: main - anchors.fill: parent - - ShaderEffectSource { - id: thesource - sourceItem: Image { source: "images/wave.jpg" } - live: false - hideSource: true - } - - RadialWaveEffect { - id: layer - anchors.fill: parent; - source: thesource - - wave: 0.0 - waveOriginX: 0.5 - waveOriginY: 0.5 - waveWidth: 0.01 - - NumberAnimation on wave { - id: waveAnim - running: true - loops: Animation.Infinite - easing.type: "Linear" - from: 0.0000; to: 2.0000; - duration: 2500 - } - } - - MouseArea { - anchors.fill: parent - onPressed: { - waveAnim.stop() - layer.waveOriginX = mouseX / main.width - layer.waveOriginY = mouseY / main.height - waveAnim.start() - } - } -} diff --git a/examples/declarative/shadereffects/qml/RadialWaveEffect.qml b/examples/declarative/shadereffects/qml/RadialWaveEffect.qml deleted file mode 100755 index 82a15a8..0000000 --- a/examples/declarative/shadereffects/qml/RadialWaveEffect.qml +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import Qt.labs.shaders 1.0 - -ShaderEffectItem { - id: effect - - property real wave: 0.3 - property real waveOriginX: 0.5 - property real waveOriginY: 0.5 - property real waveWidth: 0.01 - property real aspectRatio: width/height - property variant source: 0 - - fragmentShader: - " - varying mediump vec2 qt_TexCoord0; - uniform sampler2D source; - uniform highp float wave; - uniform highp float waveWidth; - uniform highp float waveOriginX; - uniform highp float waveOriginY; - uniform highp float aspectRatio; - - void main(void) - { - mediump vec2 texCoord2 = qt_TexCoord0; - mediump vec2 origin = vec2(waveOriginX, (1.0 - waveOriginY) / aspectRatio); - - highp float fragmentDistance = distance(vec2(texCoord2.s, texCoord2.t / aspectRatio), origin); - highp float waveLength = waveWidth + fragmentDistance * 0.25; - - if ( fragmentDistance > wave && fragmentDistance < wave + waveLength) { - highp float distanceFromWaveEdge = min(abs(wave - fragmentDistance), abs(wave + waveLength - fragmentDistance)); - texCoord2 += sin(1.57075 * distanceFromWaveEdge / waveLength) * distanceFromWaveEdge * 0.08 / fragmentDistance; - } - - gl_FragColor = texture2D(source, texCoord2.st); - } - " -} diff --git a/examples/declarative/shadereffects/qml/Water.qml b/examples/declarative/shadereffects/qml/Water.qml deleted file mode 100755 index 8810161..0000000 --- a/examples/declarative/shadereffects/qml/Water.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import Qt.labs.shaders 1.0 - -Item { - anchors.fill: parent - - Image { - id: image - width: parent.width - height: parent.height * 0.65 - source: "images/sky.jpg" - smooth: true - } - WaterEffect { - sourceItem: image - intensity: 5 - height: parent.height - image.height - } -} diff --git a/examples/declarative/shadereffects/qml/WaterEffect.qml b/examples/declarative/shadereffects/qml/WaterEffect.qml deleted file mode 100755 index e2fee5c..0000000 --- a/examples/declarative/shadereffects/qml/WaterEffect.qml +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import Qt.labs.shaders 1.0 - -Item { - id: root - property alias sourceItem: effectsource.sourceItem - property real intensity: 1 - property bool waving: true - anchors.top: sourceItem.bottom - width: sourceItem.width - height: sourceItem.height - - ShaderEffectItem { - anchors.fill: parent - property variant source: effectsource - property real f: 0 - property real f2: 0 - property alias intensity: root.intensity - smooth: true - - ShaderEffectSource { - id: effectsource - hideSource: false - smooth: true - } - - fragmentShader: - " - varying highp vec2 qt_TexCoord0; - uniform sampler2D source; - uniform lowp float qt_Opacity; - uniform highp float f; - uniform highp float f2; - uniform highp float intensity; - - void main() { - const highp float twopi = 3.141592653589 * 2.0; - - highp float distanceFactorToPhase = pow(qt_TexCoord0.y + 0.5, 8.0) * 5.0; - highp float ofx = sin(f * twopi + distanceFactorToPhase) / 100.0; - highp float ofy = sin(f2 * twopi + distanceFactorToPhase * qt_TexCoord0.x) / 60.0; - - highp float intensityDampingFactor = (qt_TexCoord0.x + 0.1) * (qt_TexCoord0.y + 0.2); - highp float distanceFactor = (1.0 - qt_TexCoord0.y) * 4.0 * intensity * intensityDampingFactor; - - ofx *= distanceFactor; - ofy *= distanceFactor; - - highp float x = qt_TexCoord0.x + ofx; - highp float y = 1.0 - qt_TexCoord0.y + ofy; - - highp float fake = (sin((ofy + ofx) * twopi) + 0.5) * 0.05 * (1.2 - qt_TexCoord0.y) * intensity * intensityDampingFactor; - - highp vec4 pix = - texture2D(source, vec2(x, y)) * 0.6 + - texture2D(source, vec2(x-fake, y)) * 0.15 + - texture2D(source, vec2(x, y-fake)) * 0.15 + - texture2D(source, vec2(x+fake, y)) * 0.15 + - texture2D(source, vec2(x, y+fake)) * 0.15; - - highp float darken = 0.6 - (ofx - ofy) / 2.0; - pix.b *= 1.2 * darken; - pix.r *= 0.9 * darken; - pix.g *= darken; - - gl_FragColor = qt_Opacity * vec4(pix.r, pix.g, pix.b, 1.0); - } - " - - NumberAnimation on f { - running: root.waving - loops: Animation.Infinite - from: 0 - to: 1 - duration: 2410 - } - NumberAnimation on f2 { - running: root.waving - loops: Animation.Infinite - from: 0 - to: 1 - duration: 1754 - } - } -} diff --git a/examples/declarative/shadereffects/qml/images/Curtain.jpg b/examples/declarative/shadereffects/qml/images/Curtain.jpg deleted file mode 100755 index 40003cb..0000000 Binary files a/examples/declarative/shadereffects/qml/images/Curtain.jpg and /dev/null differ diff --git a/examples/declarative/shadereffects/qml/images/DropShadow.jpg b/examples/declarative/shadereffects/qml/images/DropShadow.jpg deleted file mode 100755 index c1e693a..0000000 Binary files a/examples/declarative/shadereffects/qml/images/DropShadow.jpg and /dev/null differ diff --git a/examples/declarative/shadereffects/qml/images/Grayscale.jpg b/examples/declarative/shadereffects/qml/images/Grayscale.jpg deleted file mode 100755 index c95cab4..0000000 Binary files a/examples/declarative/shadereffects/qml/images/Grayscale.jpg and /dev/null differ diff --git a/examples/declarative/shadereffects/qml/images/ImageMask.jpg b/examples/declarative/shadereffects/qml/images/ImageMask.jpg deleted file mode 100755 index 0da4c0d..0000000 Binary files a/examples/declarative/shadereffects/qml/images/ImageMask.jpg and /dev/null differ diff --git a/examples/declarative/shadereffects/qml/images/RadialWave.jpg b/examples/declarative/shadereffects/qml/images/RadialWave.jpg deleted file mode 100755 index fc51efc..0000000 Binary files a/examples/declarative/shadereffects/qml/images/RadialWave.jpg and /dev/null differ diff --git a/examples/declarative/shadereffects/qml/images/Water.jpg b/examples/declarative/shadereffects/qml/images/Water.jpg deleted file mode 100755 index 38615c1..0000000 Binary files a/examples/declarative/shadereffects/qml/images/Water.jpg and /dev/null differ diff --git a/examples/declarative/shadereffects/qml/images/back.png b/examples/declarative/shadereffects/qml/images/back.png deleted file mode 100755 index 5dd3d22..0000000 Binary files a/examples/declarative/shadereffects/qml/images/back.png and /dev/null differ diff --git a/examples/declarative/shadereffects/qml/images/bg.jpg b/examples/declarative/shadereffects/qml/images/bg.jpg deleted file mode 100755 index 4d22143..0000000 Binary files a/examples/declarative/shadereffects/qml/images/bg.jpg and /dev/null differ diff --git a/examples/declarative/shadereffects/qml/images/desaturate.jpg b/examples/declarative/shadereffects/qml/images/desaturate.jpg deleted file mode 100755 index e5e99bb..0000000 Binary files a/examples/declarative/shadereffects/qml/images/desaturate.jpg and /dev/null differ diff --git a/examples/declarative/shadereffects/qml/images/drop_shadow.png b/examples/declarative/shadereffects/qml/images/drop_shadow.png deleted file mode 100755 index 144c02d..0000000 Binary files a/examples/declarative/shadereffects/qml/images/drop_shadow.png and /dev/null differ diff --git a/examples/declarative/shadereffects/qml/images/fabric.jpg b/examples/declarative/shadereffects/qml/images/fabric.jpg deleted file mode 100755 index ab65409..0000000 Binary files a/examples/declarative/shadereffects/qml/images/fabric.jpg and /dev/null differ diff --git a/examples/declarative/shadereffects/qml/images/flower.png b/examples/declarative/shadereffects/qml/images/flower.png deleted file mode 100755 index 144c02d..0000000 Binary files a/examples/declarative/shadereffects/qml/images/flower.png and /dev/null differ diff --git a/examples/declarative/shadereffects/qml/images/image1.jpg b/examples/declarative/shadereffects/qml/images/image1.jpg deleted file mode 100755 index 3442e77..0000000 Binary files a/examples/declarative/shadereffects/qml/images/image1.jpg and /dev/null differ diff --git a/examples/declarative/shadereffects/qml/images/image2.jpg b/examples/declarative/shadereffects/qml/images/image2.jpg deleted file mode 100755 index 23e5c5c..0000000 Binary files a/examples/declarative/shadereffects/qml/images/image2.jpg and /dev/null differ diff --git a/examples/declarative/shadereffects/qml/images/qt-logo.png b/examples/declarative/shadereffects/qml/images/qt-logo.png deleted file mode 100755 index 41a304b..0000000 Binary files a/examples/declarative/shadereffects/qml/images/qt-logo.png and /dev/null differ diff --git a/examples/declarative/shadereffects/qml/images/shader_effects.jpg b/examples/declarative/shadereffects/qml/images/shader_effects.jpg deleted file mode 100755 index 19e8a39..0000000 Binary files a/examples/declarative/shadereffects/qml/images/shader_effects.jpg and /dev/null differ diff --git a/examples/declarative/shadereffects/qml/images/sky.jpg b/examples/declarative/shadereffects/qml/images/sky.jpg deleted file mode 100755 index 8fc19ed..0000000 Binary files a/examples/declarative/shadereffects/qml/images/sky.jpg and /dev/null differ diff --git a/examples/declarative/shadereffects/qml/images/toolbar.png b/examples/declarative/shadereffects/qml/images/toolbar.png deleted file mode 100755 index 773e3ea..0000000 Binary files a/examples/declarative/shadereffects/qml/images/toolbar.png and /dev/null differ diff --git a/examples/declarative/shadereffects/qml/images/wave.jpg b/examples/declarative/shadereffects/qml/images/wave.jpg deleted file mode 100755 index c8083bb..0000000 Binary files a/examples/declarative/shadereffects/qml/images/wave.jpg and /dev/null differ diff --git a/examples/declarative/shadereffects/qml/main.qml b/examples/declarative/shadereffects/qml/main.qml deleted file mode 100755 index f38424a..0000000 --- a/examples/declarative/shadereffects/qml/main.qml +++ /dev/null @@ -1,160 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import Qt.labs.shaders 1.0 - -Item { - id: main - width: 360 - height: 640 - - Rectangle { - anchors.fill: parent - color: "black" - } - - Image { - id: header - source: "images/shader_effects.jpg" - } - - ListModel { - id: demoModel - ListElement { name: "ImageMask" } - ListElement { name: "RadialWave" } - ListElement { name: "Water" } - ListElement { name: "Grayscale" } - ListElement { name: "DropShadow" } - ListElement { name: "Curtain" } - } - - Grid { - id: menuGrid - anchors.top: header.bottom - anchors.bottom: toolbar.top - width: parent.width - columns: 2 - Repeater { - model: demoModel - Item { - width: main.width / 2 - height: menuGrid.height / 3 - clip: true - Image { - width: parent.width - height: width - source: "images/" + name + ".jpg" - opacity: mouseArea.pressed ? 0.6 : 1.0 - } - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: { - demoLoader.source = name + ".qml" - main.state = "showDemo" - } - } - } - } - } - - Loader { - anchors.fill: parent - id: demoLoader - visible: false - Behavior on opacity { - NumberAnimation { duration: 300 } - } - } - - Image { - id: toolbar - source: "images/toolbar.png" - width: parent.width - anchors.bottom: parent.bottom - } - - Rectangle { - id: translucentToolbar - color: "black" - opacity: 0.3 - anchors.fill: toolbar - visible: !toolbar.visible - } - - Item { - height: toolbar.height - width: height - anchors.bottom: parent.bottom - - Image { - source: "images/back.png" - anchors.centerIn: parent - } - - MouseArea { - anchors.fill: parent - onClicked: { - if (main.state == "") Qt.quit(); else { - main.state = "" - demoLoader.source = "" - } - } - } - } - - states: State { - name: "showDemo" - PropertyChanges { - target: menuGrid - visible: false - } - PropertyChanges { - target: demoLoader - visible: true - } - PropertyChanges { - target: toolbar - visible: false - } - } -} diff --git a/examples/declarative/shadereffects/qml/shadereffects/Curtain.qml b/examples/declarative/shadereffects/qml/shadereffects/Curtain.qml new file mode 100644 index 0000000..03ac0e9 --- /dev/null +++ b/examples/declarative/shadereffects/qml/shadereffects/Curtain.qml @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Item { + id: main + anchors.fill: parent + + Rectangle{ + id: bg + anchors.fill: parent + color: "black" + } + + Image { + source: "images/qt-logo.png" + anchors.centerIn: parent + } + + Image { + id: fabric + anchors.fill: parent + source: "images/fabric.jpg" + fillMode: Image.Tile + } + + CurtainEffect { + id: curtain + anchors.fill: fabric + bottomWidth: topWidth + source: ShaderEffectSource { sourceItem: fabric; hideSource: true } + + Behavior on bottomWidth { + SpringAnimation { easing.type: Easing.OutElastic; velocity: 250; mass: 1.5; spring: 0.5; damping: 0.05} + } + + SequentialAnimation on topWidth { + id: topWidthAnim + loops: Animation.Infinite + + NumberAnimation { to: 360; duration: 1000 } + PauseAnimation { duration: 2000 } + NumberAnimation { to: 180; duration: 1000 } + PauseAnimation { duration: 2000 } + } + } + + MouseArea { + anchors.fill: parent + + onPressed: { + topWidthAnim.stop() + curtain.topWidth = mouseX; + } + + onReleased: { + topWidthAnim.restart() + } + + onPositionChanged: { + if (pressed) { + curtain.topWidth = mouseX; + } + } + } +} diff --git a/examples/declarative/shadereffects/qml/shadereffects/CurtainEffect.qml b/examples/declarative/shadereffects/qml/shadereffects/CurtainEffect.qml new file mode 100644 index 0000000..c33cce4 --- /dev/null +++ b/examples/declarative/shadereffects/qml/shadereffects/CurtainEffect.qml @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +ShaderEffectItem { + anchors.fill: parent + property variant source + meshResolution: Qt.size(50, 50) + + property real topWidth: width / 2 + property real bottomWidth: width / 2 + property real originalWidth: width + property real originalHeight: height + property real amplitude: 0.1 + + vertexShader: " + attribute highp vec4 qt_Vertex; + attribute highp vec2 qt_MultiTexCoord0; + uniform highp mat4 qt_ModelViewProjectionMatrix; + varying highp vec2 qt_TexCoord0; + varying lowp float shade; + + uniform highp float topWidth; + uniform highp float bottomWidth; + uniform highp float originalWidth; + uniform highp float originalHeight; + uniform highp float amplitude; + + void main() { + qt_TexCoord0 = qt_MultiTexCoord0; + + highp vec4 shift = vec4(0, 0, 0, 0); + shift.x = qt_Vertex.x * ((originalWidth - topWidth) + (topWidth - bottomWidth) * (qt_Vertex.y / originalHeight)) / originalWidth; + + shade = sin(21.9911486 * qt_Vertex.x / originalWidth); + shift.y = amplitude * (originalWidth - topWidth + (topWidth - bottomWidth) * (qt_Vertex.y / originalHeight)) * shade; + + gl_Position = qt_ModelViewProjectionMatrix * (qt_Vertex - shift); + + shade = 0.2 * (2.0 - shade ) * (1.0 - (bottomWidth + (topWidth - bottomWidth) * (1.0 - qt_Vertex.y / originalHeight)) / originalWidth); + } + " + + fragmentShader: " + uniform sampler2D source; + varying highp vec2 qt_TexCoord0; + varying lowp float shade; + void main() { + highp vec4 color = texture2D(source, qt_TexCoord0); + color.rgb *= 1.0 - shade; + gl_FragColor = color; + } + " +} + + + diff --git a/examples/declarative/shadereffects/qml/shadereffects/DropShadow.qml b/examples/declarative/shadereffects/qml/shadereffects/DropShadow.qml new file mode 100644 index 0000000..442fb38 --- /dev/null +++ b/examples/declarative/shadereffects/qml/shadereffects/DropShadow.qml @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 + +Item { + id: main + anchors.fill: parent + + Image { + id: background + anchors.fill: parent + source: "images/bg.jpg" + } + + DropShadowEffect { + id: layer + + property real distance: 0.0 + + width: photo.width + height: photo.height + sourceItem: photo + color: "black" + blur: distance / 10.0 + opacity: 1 - distance / 50.0 + + Binding { + target: layer + property: "x" + value: -0.4 * layer.distance + when: !dragArea.pressed + } + Binding { + target: layer + property: "y" + value: 0.9 * layer.distance + when: !dragArea.pressed + } + + SequentialAnimation on distance { + id: animation + running: true + loops: Animation.Infinite + + NumberAnimation { to: 30; duration: 2000 } + PauseAnimation { duration: 500 } + NumberAnimation { to: 0; duration: 2000 } + PauseAnimation { duration: 500 } + } + } + + Image { + id: photo + anchors.fill: parent + source: "images/drop_shadow.png" + smooth: true + } + + MouseArea { + id: dragArea + anchors.fill: parent + + property int startX + property int startY + + onPressed: { + startX = mouseX + startY = mouseY + } + + onPositionChanged: { + layer.x += mouseX - startX + layer.y += mouseY - startY + startX = mouseX + startY = mouseY + } + } +} diff --git a/examples/declarative/shadereffects/qml/shadereffects/DropShadowEffect.qml b/examples/declarative/shadereffects/qml/shadereffects/DropShadowEffect.qml new file mode 100644 index 0000000..71b6ac9 --- /dev/null +++ b/examples/declarative/shadereffects/qml/shadereffects/DropShadowEffect.qml @@ -0,0 +1,174 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Item { + id: main + property real blur: 0.0 + property alias color: shadowEffectWithHBlur.color + property alias sourceItem: source.sourceItem + + ShaderEffectSource { + id: source + smooth: true + hideSource: false + } + + ShaderEffectItem { + id: shadowEffectWithHBlur + anchors.fill: parent + + property color color: "grey" + property variant sourceTexture: source; + property real xStep: main.blur / main.width + + vertexShader:" + uniform highp mat4 qt_ModelViewProjectionMatrix; + attribute highp vec4 qt_Vertex; + attribute highp vec2 qt_MultiTexCoord0; + uniform highp float xStep; + varying highp vec2 qt_TexCoord0; + varying highp vec2 qt_TexCoord1; + varying highp vec2 qt_TexCoord2; + varying highp vec2 qt_TexCoord4; + varying highp vec2 qt_TexCoord5; + varying highp vec2 qt_TexCoord6; + + void main(void) + { + highp vec2 shift = vec2(xStep, 0.); + qt_TexCoord0 = qt_MultiTexCoord0 - 2.5 * shift; + qt_TexCoord1 = qt_MultiTexCoord0 - 1.5 * shift; + qt_TexCoord2 = qt_MultiTexCoord0 - 0.5 * shift; + qt_TexCoord4 = qt_MultiTexCoord0 + 0.5 * shift; + qt_TexCoord5 = qt_MultiTexCoord0 + 1.5 * shift; + qt_TexCoord6 = qt_MultiTexCoord0 + 2.5 * shift; + gl_Position = qt_ModelViewProjectionMatrix * qt_Vertex; + } + " + + fragmentShader:" + uniform highp vec4 color; + uniform lowp sampler2D sourceTexture; + varying highp vec2 qt_TexCoord0; + varying highp vec2 qt_TexCoord1; + varying highp vec2 qt_TexCoord2; + varying highp vec2 qt_TexCoord4; + varying highp vec2 qt_TexCoord5; + varying highp vec2 qt_TexCoord6; + + void main() { + highp vec4 sourceColor = (texture2D(sourceTexture, qt_TexCoord0) * 0.1 + + texture2D(sourceTexture, qt_TexCoord1) * 0.15 + + texture2D(sourceTexture, qt_TexCoord2) * 0.25 + + texture2D(sourceTexture, qt_TexCoord4) * 0.25 + + texture2D(sourceTexture, qt_TexCoord5) * 0.15 + + texture2D(sourceTexture, qt_TexCoord6) * 0.1); + gl_FragColor = mix(vec4(0), color, sourceColor.a); + } + " + } + + ShaderEffectSource { + id: hBlurredShadow + smooth: true + sourceItem: shadowEffectWithHBlur + hideSource: true + } + + ShaderEffectItem { + id: finalEffect + anchors.fill: parent + + property color color: "grey" + property variant sourceTexture: hBlurredShadow; + property real yStep: main.blur / main.height + + vertexShader:" + uniform highp mat4 qt_ModelViewProjectionMatrix; + attribute highp vec4 qt_Vertex; + attribute highp vec2 qt_MultiTexCoord0; + uniform highp float yStep; + varying highp vec2 qt_TexCoord0; + varying highp vec2 qt_TexCoord1; + varying highp vec2 qt_TexCoord2; + varying highp vec2 qt_TexCoord4; + varying highp vec2 qt_TexCoord5; + varying highp vec2 qt_TexCoord6; + + void main(void) + { + highp vec2 shift = vec2(0., yStep); + qt_TexCoord0 = qt_MultiTexCoord0 - 2.5 * shift; + qt_TexCoord1 = qt_MultiTexCoord0 - 1.5 * shift; + qt_TexCoord2 = qt_MultiTexCoord0 - 0.5 * shift; + qt_TexCoord4 = qt_MultiTexCoord0 + 0.5 * shift; + qt_TexCoord5 = qt_MultiTexCoord0 + 1.5 * shift; + qt_TexCoord6 = qt_MultiTexCoord0 + 2.5 * shift; + gl_Position = qt_ModelViewProjectionMatrix * qt_Vertex; + } + " + + fragmentShader:" + uniform highp vec4 color; + uniform lowp sampler2D sourceTexture; + uniform highp float qt_Opacity; + varying highp vec2 qt_TexCoord0; + varying highp vec2 qt_TexCoord1; + varying highp vec2 qt_TexCoord2; + varying highp vec2 qt_TexCoord4; + varying highp vec2 qt_TexCoord5; + varying highp vec2 qt_TexCoord6; + + void main() { + highp vec4 sourceColor = (texture2D(sourceTexture, qt_TexCoord0) * 0.1 + + texture2D(sourceTexture, qt_TexCoord1) * 0.15 + + texture2D(sourceTexture, qt_TexCoord2) * 0.25 + + texture2D(sourceTexture, qt_TexCoord4) * 0.25 + + texture2D(sourceTexture, qt_TexCoord5) * 0.15 + + texture2D(sourceTexture, qt_TexCoord6) * 0.1); + gl_FragColor = sourceColor * qt_Opacity; + } + " + } +} diff --git a/examples/declarative/shadereffects/qml/shadereffects/Grayscale.qml b/examples/declarative/shadereffects/qml/shadereffects/Grayscale.qml new file mode 100644 index 0000000..58c94fc --- /dev/null +++ b/examples/declarative/shadereffects/qml/shadereffects/Grayscale.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Item { + id: main + anchors.fill: parent + + GrayscaleEffect { + id: layer + anchors.fill: parent + + source: ShaderEffectSource { + sourceItem: Image { source: "images/desaturate.jpg" } + live: false + hideSource: true + } + + SequentialAnimation on ratio { + id: ratioAnimation + running: true + loops: Animation.Infinite + NumberAnimation { + easing.type: Easing.Linear + to: 0.0 + duration: 1500 + } + PauseAnimation { duration: 1000 } + NumberAnimation { + easing.type: Easing.Linear + to: 1.0 + duration: 1500 + } + PauseAnimation { duration: 1000 } + } + } +} diff --git a/examples/declarative/shadereffects/qml/shadereffects/GrayscaleEffect.qml b/examples/declarative/shadereffects/qml/shadereffects/GrayscaleEffect.qml new file mode 100644 index 0000000..0343893 --- /dev/null +++ b/examples/declarative/shadereffects/qml/shadereffects/GrayscaleEffect.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +ShaderEffectItem { + id: effect + property real ratio: 1.0 + property variant source: 0 + + fragmentShader: + " + varying highp vec2 qt_TexCoord0; + uniform sampler2D source; + uniform highp float ratio; + void main(void) + { + lowp vec4 textureColor = texture2D(source, qt_TexCoord0.st); + lowp float gray = dot(textureColor, vec4(0.299, 0.587, 0.114, 0.0)); + gl_FragColor = vec4(gray * ratio + textureColor.r * (1.0 - ratio), gray * ratio + textureColor.g * (1.0 - ratio), gray * ratio + textureColor.b * (1.0 - ratio), textureColor.a); + } + " +} diff --git a/examples/declarative/shadereffects/qml/shadereffects/ImageMask.qml b/examples/declarative/shadereffects/qml/shadereffects/ImageMask.qml new file mode 100644 index 0000000..068696e --- /dev/null +++ b/examples/declarative/shadereffects/qml/shadereffects/ImageMask.qml @@ -0,0 +1,143 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Item { + anchors.fill: parent + + Image { + id: bg + anchors.fill: parent + source: "images/image2.jpg" + } + + Item { + id: mask + anchors.fill: parent + + Text { + text: "Mask text" + font.pixelSize: 50 + font.bold: true + anchors.horizontalCenter: parent.horizontalCenter + + NumberAnimation on rotation { + running: true + loops: Animation.Infinite + from: 0 + to: 360 + duration: 3000 + } + + SequentialAnimation on y { + running: true + loops: Animation.Infinite + NumberAnimation { + to: main.height + duration: 3000 + } + NumberAnimation { + to: 0 + duration: 3000 + } + } + } + + Rectangle { + id: opaqueBox + width: 60 + height: parent.height + SequentialAnimation on x { + running: true + loops: Animation.Infinite + NumberAnimation { + to: main.width + duration: 2000 + easing.type: Easing.InOutCubic + } + NumberAnimation { + to: 0 + duration: 2000 + easing.type: Easing.InOutCubic + } + } + } + + Rectangle { + width: 100 + opacity: 0.5 + height: parent.height + SequentialAnimation on x { + PauseAnimation { duration: 100 } + + SequentialAnimation { + loops: Animation.Infinite + NumberAnimation { + to: main.width + duration: 2000 + easing.type: Easing.InOutCubic + } + NumberAnimation { + to: 0 + duration: 2000 + easing.type: Easing.InOutCubic + } + } + } + } + } + + ImageMaskEffect { + anchors.fill: parent + image: ShaderEffectSource { + sourceItem: Image { source: "images/image1.jpg" } + live: false + hideSource: true + } + mask: ShaderEffectSource { + sourceItem: mask + live: true + hideSource: true + } + } +} diff --git a/examples/declarative/shadereffects/qml/shadereffects/ImageMaskEffect.qml b/examples/declarative/shadereffects/qml/shadereffects/ImageMaskEffect.qml new file mode 100644 index 0000000..e4dddf4 --- /dev/null +++ b/examples/declarative/shadereffects/qml/shadereffects/ImageMaskEffect.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +ShaderEffectItem { + id: effect + property variant image: 0 + property variant mask: 0 + + fragmentShader: + " + varying highp vec2 qt_TexCoord0; + uniform sampler2D image; + uniform sampler2D mask; + void main(void) + { + gl_FragColor = texture2D(image, qt_TexCoord0.st) * (texture2D(mask, qt_TexCoord0.st).a); + } + " +} diff --git a/examples/declarative/shadereffects/qml/shadereffects/RadialWave.qml b/examples/declarative/shadereffects/qml/shadereffects/RadialWave.qml new file mode 100644 index 0000000..5aaac9e --- /dev/null +++ b/examples/declarative/shadereffects/qml/shadereffects/RadialWave.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Item { + id: main + anchors.fill: parent + + ShaderEffectSource { + id: thesource + sourceItem: Image { source: "images/wave.jpg" } + live: false + hideSource: true + } + + RadialWaveEffect { + id: layer + anchors.fill: parent; + source: thesource + + wave: 0.0 + waveOriginX: 0.5 + waveOriginY: 0.5 + waveWidth: 0.01 + + NumberAnimation on wave { + id: waveAnim + running: true + loops: Animation.Infinite + easing.type: "Linear" + from: 0.0000; to: 2.0000; + duration: 2500 + } + } + + MouseArea { + anchors.fill: parent + onPressed: { + waveAnim.stop() + layer.waveOriginX = mouseX / main.width + layer.waveOriginY = mouseY / main.height + waveAnim.start() + } + } +} diff --git a/examples/declarative/shadereffects/qml/shadereffects/RadialWaveEffect.qml b/examples/declarative/shadereffects/qml/shadereffects/RadialWaveEffect.qml new file mode 100644 index 0000000..82a15a8 --- /dev/null +++ b/examples/declarative/shadereffects/qml/shadereffects/RadialWaveEffect.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +ShaderEffectItem { + id: effect + + property real wave: 0.3 + property real waveOriginX: 0.5 + property real waveOriginY: 0.5 + property real waveWidth: 0.01 + property real aspectRatio: width/height + property variant source: 0 + + fragmentShader: + " + varying mediump vec2 qt_TexCoord0; + uniform sampler2D source; + uniform highp float wave; + uniform highp float waveWidth; + uniform highp float waveOriginX; + uniform highp float waveOriginY; + uniform highp float aspectRatio; + + void main(void) + { + mediump vec2 texCoord2 = qt_TexCoord0; + mediump vec2 origin = vec2(waveOriginX, (1.0 - waveOriginY) / aspectRatio); + + highp float fragmentDistance = distance(vec2(texCoord2.s, texCoord2.t / aspectRatio), origin); + highp float waveLength = waveWidth + fragmentDistance * 0.25; + + if ( fragmentDistance > wave && fragmentDistance < wave + waveLength) { + highp float distanceFromWaveEdge = min(abs(wave - fragmentDistance), abs(wave + waveLength - fragmentDistance)); + texCoord2 += sin(1.57075 * distanceFromWaveEdge / waveLength) * distanceFromWaveEdge * 0.08 / fragmentDistance; + } + + gl_FragColor = texture2D(source, texCoord2.st); + } + " +} diff --git a/examples/declarative/shadereffects/qml/shadereffects/Water.qml b/examples/declarative/shadereffects/qml/shadereffects/Water.qml new file mode 100644 index 0000000..8810161 --- /dev/null +++ b/examples/declarative/shadereffects/qml/shadereffects/Water.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Item { + anchors.fill: parent + + Image { + id: image + width: parent.width + height: parent.height * 0.65 + source: "images/sky.jpg" + smooth: true + } + WaterEffect { + sourceItem: image + intensity: 5 + height: parent.height - image.height + } +} diff --git a/examples/declarative/shadereffects/qml/shadereffects/WaterEffect.qml b/examples/declarative/shadereffects/qml/shadereffects/WaterEffect.qml new file mode 100644 index 0000000..e2fee5c --- /dev/null +++ b/examples/declarative/shadereffects/qml/shadereffects/WaterEffect.qml @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Item { + id: root + property alias sourceItem: effectsource.sourceItem + property real intensity: 1 + property bool waving: true + anchors.top: sourceItem.bottom + width: sourceItem.width + height: sourceItem.height + + ShaderEffectItem { + anchors.fill: parent + property variant source: effectsource + property real f: 0 + property real f2: 0 + property alias intensity: root.intensity + smooth: true + + ShaderEffectSource { + id: effectsource + hideSource: false + smooth: true + } + + fragmentShader: + " + varying highp vec2 qt_TexCoord0; + uniform sampler2D source; + uniform lowp float qt_Opacity; + uniform highp float f; + uniform highp float f2; + uniform highp float intensity; + + void main() { + const highp float twopi = 3.141592653589 * 2.0; + + highp float distanceFactorToPhase = pow(qt_TexCoord0.y + 0.5, 8.0) * 5.0; + highp float ofx = sin(f * twopi + distanceFactorToPhase) / 100.0; + highp float ofy = sin(f2 * twopi + distanceFactorToPhase * qt_TexCoord0.x) / 60.0; + + highp float intensityDampingFactor = (qt_TexCoord0.x + 0.1) * (qt_TexCoord0.y + 0.2); + highp float distanceFactor = (1.0 - qt_TexCoord0.y) * 4.0 * intensity * intensityDampingFactor; + + ofx *= distanceFactor; + ofy *= distanceFactor; + + highp float x = qt_TexCoord0.x + ofx; + highp float y = 1.0 - qt_TexCoord0.y + ofy; + + highp float fake = (sin((ofy + ofx) * twopi) + 0.5) * 0.05 * (1.2 - qt_TexCoord0.y) * intensity * intensityDampingFactor; + + highp vec4 pix = + texture2D(source, vec2(x, y)) * 0.6 + + texture2D(source, vec2(x-fake, y)) * 0.15 + + texture2D(source, vec2(x, y-fake)) * 0.15 + + texture2D(source, vec2(x+fake, y)) * 0.15 + + texture2D(source, vec2(x, y+fake)) * 0.15; + + highp float darken = 0.6 - (ofx - ofy) / 2.0; + pix.b *= 1.2 * darken; + pix.r *= 0.9 * darken; + pix.g *= darken; + + gl_FragColor = qt_Opacity * vec4(pix.r, pix.g, pix.b, 1.0); + } + " + + NumberAnimation on f { + running: root.waving + loops: Animation.Infinite + from: 0 + to: 1 + duration: 2410 + } + NumberAnimation on f2 { + running: root.waving + loops: Animation.Infinite + from: 0 + to: 1 + duration: 1754 + } + } +} diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/Curtain.jpg b/examples/declarative/shadereffects/qml/shadereffects/images/Curtain.jpg new file mode 100644 index 0000000..40003cb Binary files /dev/null and b/examples/declarative/shadereffects/qml/shadereffects/images/Curtain.jpg differ diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/DropShadow.jpg b/examples/declarative/shadereffects/qml/shadereffects/images/DropShadow.jpg new file mode 100644 index 0000000..c1e693a Binary files /dev/null and b/examples/declarative/shadereffects/qml/shadereffects/images/DropShadow.jpg differ diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/Grayscale.jpg b/examples/declarative/shadereffects/qml/shadereffects/images/Grayscale.jpg new file mode 100644 index 0000000..c95cab4 Binary files /dev/null and b/examples/declarative/shadereffects/qml/shadereffects/images/Grayscale.jpg differ diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/ImageMask.jpg b/examples/declarative/shadereffects/qml/shadereffects/images/ImageMask.jpg new file mode 100644 index 0000000..0da4c0d Binary files /dev/null and b/examples/declarative/shadereffects/qml/shadereffects/images/ImageMask.jpg differ diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/RadialWave.jpg b/examples/declarative/shadereffects/qml/shadereffects/images/RadialWave.jpg new file mode 100644 index 0000000..fc51efc Binary files /dev/null and b/examples/declarative/shadereffects/qml/shadereffects/images/RadialWave.jpg differ diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/Water.jpg b/examples/declarative/shadereffects/qml/shadereffects/images/Water.jpg new file mode 100644 index 0000000..38615c1 Binary files /dev/null and b/examples/declarative/shadereffects/qml/shadereffects/images/Water.jpg differ diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/back.png b/examples/declarative/shadereffects/qml/shadereffects/images/back.png new file mode 100644 index 0000000..5dd3d22 Binary files /dev/null and b/examples/declarative/shadereffects/qml/shadereffects/images/back.png differ diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/bg.jpg b/examples/declarative/shadereffects/qml/shadereffects/images/bg.jpg new file mode 100644 index 0000000..4d22143 Binary files /dev/null and b/examples/declarative/shadereffects/qml/shadereffects/images/bg.jpg differ diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/desaturate.jpg b/examples/declarative/shadereffects/qml/shadereffects/images/desaturate.jpg new file mode 100644 index 0000000..e5e99bb Binary files /dev/null and b/examples/declarative/shadereffects/qml/shadereffects/images/desaturate.jpg differ diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/drop_shadow.png b/examples/declarative/shadereffects/qml/shadereffects/images/drop_shadow.png new file mode 100644 index 0000000..144c02d Binary files /dev/null and b/examples/declarative/shadereffects/qml/shadereffects/images/drop_shadow.png differ diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/fabric.jpg b/examples/declarative/shadereffects/qml/shadereffects/images/fabric.jpg new file mode 100644 index 0000000..ab65409 Binary files /dev/null and b/examples/declarative/shadereffects/qml/shadereffects/images/fabric.jpg differ diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/flower.png b/examples/declarative/shadereffects/qml/shadereffects/images/flower.png new file mode 100644 index 0000000..144c02d Binary files /dev/null and b/examples/declarative/shadereffects/qml/shadereffects/images/flower.png differ diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/image1.jpg b/examples/declarative/shadereffects/qml/shadereffects/images/image1.jpg new file mode 100644 index 0000000..3442e77 Binary files /dev/null and b/examples/declarative/shadereffects/qml/shadereffects/images/image1.jpg differ diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/image2.jpg b/examples/declarative/shadereffects/qml/shadereffects/images/image2.jpg new file mode 100644 index 0000000..23e5c5c Binary files /dev/null and b/examples/declarative/shadereffects/qml/shadereffects/images/image2.jpg differ diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/qt-logo.png b/examples/declarative/shadereffects/qml/shadereffects/images/qt-logo.png new file mode 100644 index 0000000..41a304b Binary files /dev/null and b/examples/declarative/shadereffects/qml/shadereffects/images/qt-logo.png differ diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/shader_effects.jpg b/examples/declarative/shadereffects/qml/shadereffects/images/shader_effects.jpg new file mode 100644 index 0000000..19e8a39 Binary files /dev/null and b/examples/declarative/shadereffects/qml/shadereffects/images/shader_effects.jpg differ diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/sky.jpg b/examples/declarative/shadereffects/qml/shadereffects/images/sky.jpg new file mode 100644 index 0000000..8fc19ed Binary files /dev/null and b/examples/declarative/shadereffects/qml/shadereffects/images/sky.jpg differ diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/toolbar.png b/examples/declarative/shadereffects/qml/shadereffects/images/toolbar.png new file mode 100644 index 0000000..773e3ea Binary files /dev/null and b/examples/declarative/shadereffects/qml/shadereffects/images/toolbar.png differ diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/wave.jpg b/examples/declarative/shadereffects/qml/shadereffects/images/wave.jpg new file mode 100644 index 0000000..c8083bb Binary files /dev/null and b/examples/declarative/shadereffects/qml/shadereffects/images/wave.jpg differ diff --git a/examples/declarative/shadereffects/qml/shadereffects/main.qml b/examples/declarative/shadereffects/qml/shadereffects/main.qml new file mode 100644 index 0000000..f38424a --- /dev/null +++ b/examples/declarative/shadereffects/qml/shadereffects/main.qml @@ -0,0 +1,160 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Item { + id: main + width: 360 + height: 640 + + Rectangle { + anchors.fill: parent + color: "black" + } + + Image { + id: header + source: "images/shader_effects.jpg" + } + + ListModel { + id: demoModel + ListElement { name: "ImageMask" } + ListElement { name: "RadialWave" } + ListElement { name: "Water" } + ListElement { name: "Grayscale" } + ListElement { name: "DropShadow" } + ListElement { name: "Curtain" } + } + + Grid { + id: menuGrid + anchors.top: header.bottom + anchors.bottom: toolbar.top + width: parent.width + columns: 2 + Repeater { + model: demoModel + Item { + width: main.width / 2 + height: menuGrid.height / 3 + clip: true + Image { + width: parent.width + height: width + source: "images/" + name + ".jpg" + opacity: mouseArea.pressed ? 0.6 : 1.0 + } + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: { + demoLoader.source = name + ".qml" + main.state = "showDemo" + } + } + } + } + } + + Loader { + anchors.fill: parent + id: demoLoader + visible: false + Behavior on opacity { + NumberAnimation { duration: 300 } + } + } + + Image { + id: toolbar + source: "images/toolbar.png" + width: parent.width + anchors.bottom: parent.bottom + } + + Rectangle { + id: translucentToolbar + color: "black" + opacity: 0.3 + anchors.fill: toolbar + visible: !toolbar.visible + } + + Item { + height: toolbar.height + width: height + anchors.bottom: parent.bottom + + Image { + source: "images/back.png" + anchors.centerIn: parent + } + + MouseArea { + anchors.fill: parent + onClicked: { + if (main.state == "") Qt.quit(); else { + main.state = "" + demoLoader.source = "" + } + } + } + } + + states: State { + name: "showDemo" + PropertyChanges { + target: menuGrid + visible: false + } + PropertyChanges { + target: demoLoader + visible: true + } + PropertyChanges { + target: toolbar + visible: false + } + } +} diff --git a/examples/declarative/shadereffects/shadereffects.pro b/examples/declarative/shadereffects/shadereffects.pro index 1107887..23a951c 100755 --- a/examples/declarative/shadereffects/shadereffects.pro +++ b/examples/declarative/shadereffects/shadereffects.pro @@ -1,21 +1,43 @@ -TEMPLATE = app -TARGET = shadereffects -DEPENDPATH += . -INCLUDEPATH += . +# Add more folders to ship with the application, here +folder_01.source = qml/shadereffects +folder_01.target = qml +DEPLOYMENTFOLDERS = folder_01 + +# Additional import path used to resolve QML modules in Creator's code model +QML_IMPORT_PATH = + +symbian:TARGET.UID3 = 0xE1CB8EBB + +# Smart Installer package's UID +# This UID is from the protected range and therefore the package will +# fail to install if self-signed. By default qmake uses the unprotected +# range value if unprotected UID is defined for the application and +# 0x2002CCCF value if protected UID is given to the application +#symbian:DEPLOYMENT.installer_header = 0x2002CCCF + +# Allow network access on Symbian +symbian:TARGET.CAPABILITY += NetworkServices + +# If your application uses the Qt Mobility libraries, uncomment the following +# lines and add the respective components to the MOBILITY variable. +# CONFIG += mobility +# MOBILITY += + +# Speed up launching on MeeGo/Harmattan when using applauncherd daemon +# CONFIG += qdeclarative-boostable + +# Add dependency to Symbian components +# CONFIG += qt-components + QT += declarative opengl -# Input +# The .cpp file which was generated for your project. Feel free to hack it. SOURCES += main.cpp symbian { DEFINES += SHADEREFFECTS_USE_OPENGL_GRAPHICSSYSTEM } - -target.path = $$[QT_INSTALL_EXAMPLES]/declarative/shadereffects -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS shadereffects.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/shadereffects -qmlfiles.files = qml -qmlfiles.path = $$[QT_INSTALL_EXAMPLES]/declarative/shadereffects - -INSTALLS += target sources qmlfiles +# Please do not modify the following two lines. Required for deployment. +include(../../tools/qmlapplicationviewer/qmlapplicationviewer.pri) +qtcAddDeployment() diff --git a/examples/declarative/shadereffects/shadereffects.qmlproject b/examples/declarative/shadereffects/shadereffects.qmlproject new file mode 100644 index 0000000..112be81 --- /dev/null +++ b/examples/declarative/shadereffects/shadereffects.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "qml/shadereffects" + } + JavaScriptFiles { + directory: "qml/shadereffects" + } + ImageFiles { + directory: "qml/shadereffects" + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} \ No newline at end of file -- cgit v0.12