本页内容

HueSaturation QML Type

在HSL色彩空间中更改源项的颜色。更多...

Import Statement: import Qt5Compat.GraphicalEffects
Since: QtGraphicalEffects 1.0
Inherits:

Item

属性

详细说明

“色相饱和度”(HueSaturation)与“色相饱和度”(Colorize )效果类似,但对色相和饱和度属性值的处理方式不同。“色相饱和度”效果始终会调整原始值的色相、饱和度和明度,而非直接设置这些属性值。

来源已应用的效果

叶子上的黑甲虫

调整了色相和饱和度的甲虫

示例

以下示例演示了如何应用该效果。

import QtQuick
import Qt5Compat.GraphicalEffects

Item {
    width: 300
    height: 300

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

    HueSaturation {
        anchors.fill: bug
        source: bug
        hue: -0.3
        saturation: 0.5
        lightness: -0.1
    }
}

属性文档

cached : bool

此属性允许将效果输出的像素缓存起来,以提高渲染性能。

每次更改源或效果属性时,缓存中的像素都必须进行更新。由于需要额外的内存缓冲区来存储效果输出,因此内存消耗会增加。

当源或效果属性进行动画处理时,建议禁用缓存。

默认情况下,该属性设置为false 。

hue : real

此属性定义了要添加到源色相值上的色相值。

该值的取值范围为-1.0(降低)到1.0(提高)。默认情况下,该属性设置为0.0 (保持不变)。

不同色相值的输出示例

色相向左偏移的甲虫

原色甲壳虫

色相向右偏移的甲虫

色相:-0.3 色相:0.0 色相:0.3simplified_chinese (Mainland)
saturation: 0saturation: 0saturation: 0
lightness: 0lightness: 0lightness: 0

lightness : real

此属性定义了要加到源饱和度值上的明度值。

该值范围为 -1.0(降低)到 1.0(提高)。默认情况下,该属性设置为0.0 (无变化)。

不同明度值的输出示例

甲虫变暗了

甲壳虫,原汁原味的轻盈感

甲壳虫车身轻量化

明度:-0.5 明度:0.0 明度:0.5
hue: 0hue: 0hue: 0
saturation: 0saturation: 0saturation: 0

saturation : real

此属性定义了要加到源饱和度值上的饱和度值。

该值范围为 -1.0(降低)到 1.0(提高)。默认情况下,该属性设置为0.0 (保持不变)。

不同饱和度值的输出示例

甲壳虫的色彩大多被去饱和处理了

甲虫(原始饱和度)

饱和度增强的甲虫

饱和度:-0.8 saturation: 0.0 饱和度:1.0
hue: 0hue: 0hue: 0
lightness: 0lightness: 0lightness: 0

source : variant

此属性定义了为该效果提供源像素的源项目。

注意: 不支持让效果包含自身,例如将“源”设置为该效果的父级。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.