Warning, /webapps/qmlonline/qml/examples/shadereffect.qml is written in an unsupported language. File is not indexed.

0001 import QtQuick 2.7
0002 import QtQuick.Controls 2.3
0003 
0004 Rectangle {
0005     color: "red"
0006     anchors.fill: parent
0007 
0008     ShaderEffect {
0009         Image {
0010             id: profilePic
0011             source: "https://farm8.staticflickr.com/7861/46451042134_cb4cefce18_b.jpg"
0012             visible: false
0013         }
0014 
0015         property variant src: profilePic
0016         width: 400
0017         height: width
0018         anchors.centerIn: parent
0019 
0020         vertexShader: "
0021             uniform highp mat4 qt_Matrix;
0022             attribute highp vec4 qt_Vertex;
0023             attribute highp vec2 qt_MultiTexCoord0;
0024             varying highp vec2 coord;
0025             void main() {
0026                 coord = qt_MultiTexCoord0;
0027                 gl_Position = qt_Matrix * qt_Vertex;
0028             }
0029         "
0030         fragmentShader: "
0031             #ifdef GL_ES
0032                 precision mediump float;
0033             #endif
0034 
0035             varying highp vec2 coord;
0036             uniform sampler2D src;
0037             uniform lowp float qt_Opacity;
0038             void main() {
0039                 float d = distance(coord, vec2(0.5, 0.5));
0040                 if(d > 0.5) {
0041                     gl_FragColor = vec4(0, 0, 0, 0) * qt_Opacity;
0042                     return;
0043                 }
0044                 lowp vec4 tex = texture2D(src, coord);
0045                 gl_FragColor = vec4(tex.rgb, tex.a) * qt_Opacity;
0046             }
0047         "
0048     }
0049 }