Guest User

Untitled

a guest
Apr 30th, 2013
98
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
  4. ** Contact: http://www.qt-project.org/legal
  5. **
  6. ** This file is part of the examples of the Qt Toolkit.
  7. **
  8. ** $QT_BEGIN_LICENSE:BSD$
  9. ** You may use this file under the terms of the BSD license as follows:
  10. **
  11. ** "Redistribution and use in source and binary forms, with or without
  12. ** modification, are permitted provided that the following conditions are
  13. ** met:
  14. ** * Redistributions of source code must retain the above copyright
  15. ** notice, this list of conditions and the following disclaimer.
  16. ** * Redistributions in binary form must reproduce the above copyright
  17. ** notice, this list of conditions and the following disclaimer in
  18. ** the documentation and/or other materials provided with the
  19. ** distribution.
  20. ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
  21. ** of its contributors may be used to endorse or promote products derived
  22. ** from this software without specific prior written permission.
  23. **
  24. **
  25. ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  26. ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  27. ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  28. ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  29. ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  30. ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  31. ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  32. ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  33. ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  34. ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  35. ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
  36. **
  37. ** $QT_END_LICENSE$
  38. **
  39. ****************************************************************************/
  40.  
  41. import QtQuick 2.0
  42.  
  43. import ViewportItems 1.0
  44.  
  45. Item {
  46. id:root;
  47. width: 1024
  48. height: 600
  49.  
  50. // The checkers background
  51. ShaderEffect {
  52. id: tileBackground
  53. anchors.fill: parent
  54.  
  55. property real tileSize: 16
  56. property color color1: Qt.rgba(0.9, 0.9, 0.9, 1);
  57. property color color2: Qt.rgba(0.85, 0.85, 0.85, 1);
  58.  
  59. property size pixelSize: Qt.size(width / tileSize, height / tileSize);
  60.  
  61. fragmentShader:
  62. "
  63. uniform lowp vec4 color1;
  64. uniform lowp vec4 color2;
  65. uniform highp vec2 pixelSize;
  66. varying highp vec2 qt_TexCoord0;
  67. void main() {
  68. highp vec2 tc = sign(sin(3.14152 * qt_TexCoord0 * pixelSize));
  69. if (tc.x != tc.y)
  70. gl_FragColor = color1;
  71. else
  72. gl_FragColor = color2;
  73. }
  74. "
  75. }
  76.  
  77. ShaderEffect {
  78. // width: 160
  79. // height: 160
  80.  
  81. anchors.fill: parent
  82.  
  83. property variant src: renderer
  84.  
  85. property real amplitude: 0.04 + 0.5
  86. property real frequency: 20
  87. property real time: 0
  88. NumberAnimation on time { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 600 }
  89. fragmentShader:
  90. "uniform lowp float qt_Opacity;" +
  91. "uniform highp float amplitude;" +
  92. "uniform highp float frequency;" +
  93. "uniform highp float time;" +
  94. "uniform sampler2D source;" +
  95. "varying highp vec2 qt_TexCoord0;" +
  96. "void main() {" +
  97. " highp vec2 p = sin(time + frequency * qt_TexCoord0);" +
  98. " gl_FragColor = texture2D(source, qt_TexCoord0 + amplitude * vec2(p.y, -p.x)) * qt_Opacity;" +
  99. "}"
  100. }
  101.  
  102. Image {
  103. id: butts;
  104. x: 300;
  105. y: 50;
  106. width: 300;
  107. height: width;
  108. source: "/home/preet/mrsnrub.jpg"
  109. }
  110.  
  111. Rectangle {
  112. id: labelFrame
  113. anchors.margins: -10
  114. radius: 5
  115. color: "white"
  116. border.color: "black"
  117. opacity: 0.8
  118. anchors.fill: label
  119.  
  120. // RotationAnimation on rotation {
  121. // from: 0; to: 360; duration: 4000; loops: Animation.Infinite;
  122. // }
  123. }
  124.  
  125. Text {
  126. id: label
  127. anchors.bottom: renderer.bottom
  128. anchors.left: renderer.left
  129. anchors.right: renderer.right
  130. anchors.margins: 20
  131. wrapMode: Text.WordWrap
  132. text: "The blue rectangle with the vintage 'Q' is an FBO, rendered by the application on the scene graph rendering thread. It is displayed using a QSGSimpleTextureNode."
  133. }
  134.  
  135.  
  136. }
RAW Paste Data