summaryrefslogtreecommitdiffstats
path: root/basicsuite/Graphical Effects/Checkers.qml
blob: 9ebdcff3bb8d67dac0fd39fe647efea18d59a592 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import QtQuick 2.0


// The checkers background
ShaderEffect {

    property real tileSize: 16
    property color color1: Qt.rgba(0.7, 0.7, 0.7, 1);
    property color color2: Qt.rgba(0.6, 0.6, 0.6, 1);

    property size _pixelSize: Qt.size(Math.PI * width / tileSize, Math.PI * height / tileSize);

    fragmentShader:
        "
        uniform lowp vec4 color1;
        uniform lowp vec4 color2;
        uniform lowp float qt_Opacity;
        uniform highp vec2 _pixelSize;
        varying highp vec2 qt_TexCoord0;
        void main() {
            highp vec2 tc = sign(sin(qt_TexCoord0 * _pixelSize));
            if (tc.x != tc.y)
                gl_FragColor = color1 * qt_Opacity;
            else
                gl_FragColor = color2 * qt_Opacity;
        }
        "
}