UniformAnimator QML Type

The UniformAnimator type animates a uniform of a ShaderEffect . 更多...

import 語句: import QtQuick
繼承:

Animator

特性

詳細描述

Animator types are different from normal Animation types. When using an Animator, the animation can be run in the render thread and the property value will jump to the end when the animation is complete.

The value of the QML property defining the uniform is updated after the animation has finished.

The following snippet shows how to use a UniformAnimator together with a ShaderEffect 項。

ShaderEffect {
    id: shader
    width: 50
    height: 50
    property variant t;
    UniformAnimator {
        target: shader
        uniform: "t"
        from: 0
        to: 1
        duration: 1000
        running: true
    }
    fragmentShader: "qrc:shader.frag.qsb"
}
					

It is also possible to use the on keyword to tie the UniformAnimator directly to a uniform of a ShaderEffect 實例。

ShaderEffect {
    width: 50
    height: 50
    property variant t;
    UniformAnimator on t {
        from: 0
        to: 1
        duration: 1000
    }
    fragmentShader: "qrc:shader.frag.qsb"
}
					

另請參閱 ShaderEffect and ShaderEffectSource .

特性文檔編製

uniform : string

This property holds the name of the uniform to animate.

The value of the uniform must correspond to both a property on the target ShaderEffect and must be a uniform of type float in the fragment or vertex shader.