| 1 |
import QtQuick 2.0 |
| 2 |
|
| 3 |
Item { |
| 4 |
width: 320 |
| 5 |
height: 480 |
| 6 |
|
| 7 |
Text { |
| 8 |
id: text |
| 9 |
anchors.centerIn: parent |
| 10 |
font.pixelSize: 80 |
| 11 |
text: "Shaderz!" |
| 12 |
} |
| 13 |
|
| 14 |
ShaderEffectSource { |
| 15 |
id: source |
| 16 |
sourceItem: text |
| 17 |
sourceRect: Qt.rect(rect.x - text.x, rect.y - text.y, rect.width, rect.height) |
| 18 |
} |
| 19 |
|
| 20 |
ShaderEffect { |
| 21 |
anchors.fill: rect |
| 22 |
|
| 23 |
property variant source: source |
| 24 |
|
| 25 |
fragmentShader: "qrc:shaders/gradient.frag" |
| 26 |
} |
| 27 |
|
| 28 |
Rectangle { |
| 29 |
id: rect |
| 30 |
x: 100 |
| 31 |
y: 100 |
| 32 |
width: 100 |
| 33 |
height: 100 |
| 34 |
color: "transparent" |
| 35 |
border.width: 2 |
| 36 |
border.color: "red" |
| 37 |
MouseArea { |
| 38 |
anchors.fill: parent |
| 39 |
drag.target: parent |
| 40 |
drag.axis: Drag.XAndYAxis |
| 41 |
drag.minimumX: 0 |
| 42 |
drag.maximumX: parent.parent.width - width |
| 43 |
drag.minimumY: 0 |
| 44 |
drag.maximumY: parent.parent.height - height |
| 45 |
} |
| 46 |
} |
| 47 |
} |