try an actual wobblywindows effect
it still has some serious problems: -animation not smooth -the deformation is linear, the applet appears broken -unfortunately the ShaderEffect must be a lot bigger thanthe thing it deforms because it looks clipped now
This commit is contained in:
parent
46b83aaced
commit
086d3e1e8f
@ -84,6 +84,13 @@ Item {
|
||||
}
|
||||
}
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
|
||||
property real dx: 0
|
||||
property real dy: 0
|
||||
property real startX
|
||||
property real startY
|
||||
|
||||
anchors.fill: parent
|
||||
drag.target: frameParent
|
||||
onClicked: {
|
||||
@ -91,6 +98,39 @@ Item {
|
||||
frameParent.height = s
|
||||
frameParent.width = s
|
||||
}
|
||||
onPressed: {
|
||||
speedSampleTimer.running = true
|
||||
mouseArea.startX = mouse.x
|
||||
mouseArea.startY = mouse.y
|
||||
speedSampleTimer.lastFrameParentX = frameParent.x
|
||||
speedSampleTimer.lastFrameParentY = frameParent.y
|
||||
}
|
||||
onPositionChanged: {
|
||||
//mouseArea.dx = mouse.x - mouseArea.startX
|
||||
//mouseArea.dy = mouse.y - mouseArea.startY
|
||||
dxAnim.running = false
|
||||
dyAnim.running = false
|
||||
}
|
||||
onReleased: {
|
||||
speedSampleTimer.running = false
|
||||
dxAnim.running = true
|
||||
dyAnim.running = true
|
||||
}
|
||||
Timer {
|
||||
id: speedSampleTimer
|
||||
interval: 40
|
||||
repeat: true
|
||||
property real lastFrameParentX
|
||||
property real lastFrameParentY
|
||||
onTriggered: {
|
||||
mouseArea.dx = frameParent.x - lastFrameParentX
|
||||
mouseArea.dy = frameParent.y - lastFrameParentY
|
||||
lastFrameParentX = frameParent.x
|
||||
lastFrameParentY = frameParent.y
|
||||
dxAnim.running = true
|
||||
dyAnim.running = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
@ -130,23 +170,33 @@ Item {
|
||||
sourceItem: frame
|
||||
}
|
||||
|
||||
property int fadeDuration: 250
|
||||
property real amplitude: busyIndicator.visible ? 0.04 * 0.2 : 0
|
||||
property real frequency: 20
|
||||
property int fadeDuration: 150
|
||||
property real time: 0
|
||||
NumberAnimation on time { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 600 }
|
||||
Behavior on amplitude { NumberAnimation { duration: wobbleShader.fadeDuration } }
|
||||
property real dx: mouseArea.dx
|
||||
property real dy: mouseArea.dy
|
||||
property real startX: mouseArea.startX/mouseArea.width
|
||||
property real startY: mouseArea.startY/mouseArea.height
|
||||
|
||||
NumberAnimation on dx { id: dxAnim; to: 0; duration: 350; easing.type: Easing.OutElastic }
|
||||
NumberAnimation on dy { id: dyAnim; to: 0; duration: 350; easing.type: Easing.OutElastic }
|
||||
//! [fragment]
|
||||
fragmentShader: {
|
||||
"uniform lowp float qt_Opacity;" +
|
||||
"uniform highp float amplitude;" +
|
||||
"uniform highp float frequency;" +
|
||||
"uniform highp float time;" +
|
||||
"uniform highp float dx;" +
|
||||
"uniform highp float dy;" +
|
||||
"uniform highp float startX;" +
|
||||
"uniform highp float startY;" +
|
||||
"uniform sampler2D source;" +
|
||||
"varying highp vec2 qt_TexCoord0;" +
|
||||
"void main() {" +
|
||||
" highp vec2 p = sin(time + frequency * qt_TexCoord0);" +
|
||||
" gl_FragColor = texture2D(source, qt_TexCoord0 + amplitude * vec2(p.y, -p.x)) * qt_Opacity;" +
|
||||
|
||||
"highp float wave_x = qt_TexCoord0.x - dx*0.0025" +
|
||||
" * (1/(1+abs(qt_TexCoord0.x-(startX))))" +
|
||||
" * (1/(1+abs(qt_TexCoord0.y-(startY))));" +
|
||||
"highp float wave_y = qt_TexCoord0.y - dy*0.0025" +
|
||||
" * 1/(1+abs(qt_TexCoord0.x-(startX)))" +
|
||||
" * 1/(1+abs(qt_TexCoord0.y-(startY)));" +
|
||||
"gl_FragColor = texture2D(source, vec2(wave_x, wave_y));" +
|
||||
"}"
|
||||
}
|
||||
//! [fragment]
|
||||
|
Loading…
x
Reference in New Issue
Block a user