本页内容

lineargradient2d QML Value Type

提供与 `QCanvasLinearGradient` 匹配的 `lineargradient2d` 类型。更多内容...

Import Statement: import QtCanvas2D
Since: Qt 6.12
Status: Technology preview

此类型处于技术预览阶段,可能会有变动。

方法

详细说明

此值类型由QtCanvas2D 导入提供。

另请参阅 QCanvasLinearGradient 。

方法文档

void addColorStop(real offset, string color)

在指定位置offset 的渐变中添加一个具有给定color 的颜色停点。0.0 表示渐变一端的偏移量,1.0 表示渐变另一端的偏移量。

例如:

const gradient = ctx.createLinearGradient(0, 0, 100, 100);
gradient.addColorStop(0.0, Qt.rgba(1, 0, 0, 1));
gradient.addColorStop(0.5, "#ff8040");
gradient.addColorStop(1.0, "red");

point endPosition()

返回线性渐变的终点。

另请参阅 setEndPosition()。

void setEndPosition(real x, real y)

将线性渐变的终点设置为 (x,y)。

另请参阅 endPosition()。

void setEndPosition(point end)

将线性渐变的终点设置为end 。

这是一个重载函数。

void setStartPosition(real x, real y)

将线性渐变的起始点设置为 (x,y)。

另请参阅 startPosition()。

void setStartPosition(point start)

将线性渐变的起始点设置为start 。

这是一个重载函数。

point startPosition()

返回线性渐变的起始点。

另请参阅 ` setStartPosition()`。

© 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.