EffectMagnify.qml Example File
multimedia/video/qmlvideofx/qml/qmlvideofx/EffectMagnify.qml
import QtQuick 2.1
import QtQuick.Window 2.1
Effect {
id: root
divider: false
parameters: ListModel {
ListElement {
name: "Radius"
value: 0.5
}
ListElement {
name: "Diffraction"
value: 0.5
}
onDataChanged: updateParameters()
}
function updateParameters()
{
radius = parameters.get(0).value * 100;
diffractionIndex = parameters.get(1).value;
}
property real posX: -1
property real posY: -1
property real pixDens: Screen.pixelDensity
QtObject {
id: d
property real oldTargetWidth: root.targetWidth
property real oldTargetHeight: root.targetHeight
}
property real radius: 0.5 * 100
property real diffractionIndex: 0.5
onTargetWidthChanged: {
if (posX == -1)
posX = targetWidth / 2
else if (d.oldTargetWidth != 0)
posX *= (targetWidth / d.oldTargetWidth)
d.oldTargetWidth = targetWidth
}
onTargetHeightChanged: {
if (posY == -1)
posY = targetHeight / 2
else if (d.oldTargetHeight != 0)
posY *= (targetHeight / d.oldTargetHeight)
d.oldTargetHeight = targetHeight
}
fragmentShaderFilename: "magnify.fsh"
MouseArea {
anchors.fill: parent
onPositionChanged: { root.posX = mouse.x; root.posY = root.targetHeight - mouse.y }
}
}