IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

Glow QML Type

Generates a blurred and colorized image of the source and places it behind the original, giving impression that the source is glowing.

This type was introduced in QtGraphicalEffects 1.0.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

Glow QML Type

  • Import Statement: import Qt5Compat.GraphicalEffects

  • Since: QtGraphicalEffects 1.0

  • Inherits: Item

  • Group: Glow is part of qtgraphicaleffects-glow

Detailed Description

Source

Effect applied

Image non disponible
Image non disponible

Example

The following example shows how to apply the effect.

 
Sélectionnez
import QtQuick
import Qt5Compat.GraphicalEffects

Item {
    width: 300
    height: 300

    Rectangle {
        anchors.fill: parent
        color: "black"
    }

    Image {
        id: butterfly
        source: "images/butterfly.png"
        sourceSize: Qt.size(parent.width, parent.height)
        smooth: true
        visible: false
    }

    Glow {
        anchors.fill: butterfly
        radius: 8
        color: "white"
        source: butterfly
    }
}

Property Documentation

 

cached : bool

This property allows the effect output pixels to be cached in order to improve the rendering performance.

Every time the source or effect properties are changed, the pixels in the cache must be updated. Memory consumption is increased, because an extra buffer of memory is required for storing the effect output.

It is recommended to disable the cache when the source or the effect properties are animated.

By default, the property is set to false.

color : color

This property defines the RGBA color value which is used for the glow.

By default, the property is set to "white".

Output examples with different color values

   
Image non disponible
Image non disponible
Image non disponible

color: #ffffff

color: #00ff00

color: #aa00ff00

radius: 8

radius: 8

radius: 8

spread: 0.5

spread: 0.5

spread: 0.5

radius : real

Radius defines the softness of the glow. A larger radius causes the edges of the glow to appear more blurry.

The value ranges from 0.0 (no blur) to inf. By default, the property is set to 0.0 (no blur).

Output examples with different radius values

   
Image non disponible
Image non disponible
Image non disponible

radius: 0

radius: 6

radius: 12

color: #ffffff

color: #ffffff

color: #ffffff

spread: 0

spread: 0

spread: 0

source : variant

This property defines the source item that is going to be used as source for the generated glow.

It is not supported to let the effect include itself, for instance by setting source to the effect's parent.

spread : real

This property defines how large part of the glow color is strenghtened near the source edges.

The values range from 0.0 to 1.0. By default, the property is set to 0.5.

Output examples with different spread values

   
Image non disponible
Image non disponible
Image non disponible

spread: 0.0

spread: 0.5

spread: 1.0

radius: 8

radius: 8

radius: 8

color: #ffffff

color: #ffffff

color: #ffffff

transparentBorder : bool

This property determines whether or not the effect has a transparent border.

When set to true, the exterior of the item is padded with a 1 pixel wide transparent edge, making sampling outside the source texture use transparency instead of the edge pixels. Without this property, an image which has opaque edges will not get a blurred edge.

In the snippet below, the Rectangle on the left has transparent borders and has blurred edges, whereas the Rectangle on the right does not.

 
Sélectionnez
import QtQuick
import Qt5Compat.GraphicalEffects

Rectangle {
    width: 180
    height: 100

    Row {
        anchors.centerIn: parent
        spacing: 16

        Rectangle {
            id: normalRect
            width: 60
            height: 60
            color: "black"
            radius: 10
            layer.enabled: true
            layer.effect: Glow {
                samples: 15
                color: "blue"
                transparentBorder: false
            }
        }

        Rectangle {
            id: transparentBorderRect
            width: 60
            height: 60
            color: "black"
            radius: 10
            layer.enabled: true
            layer.effect: Glow {
                samples: 15
                color: "blue"
                transparentBorder: true
            }
        }
    }
}
Image non disponible

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+