本页内容

radialgradient2d QML Value Type

提供与QCanvasRadialGradient 相匹配的radialgradient2d类型。更多内容...

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

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

方法

详细说明

此值类型由QtCanvas2D 导入提供。

另请参阅 QCanvasRadialGradient 。

方法文档

void addColorStop(real offset, string color)

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

例如:

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

point centerPosition()

返回径向渐变的中心点。这与outerCenterPosition() 相同。

另请参阅 setCenterPosition()。

point innerCenterPosition()

返回径向渐变的内中心点。

另请参阅 setInnerCenterPosition()。

real innerRadius()

返回径向渐变的内半径。

另请参阅 setInnerRadius()。

point outerCenterPosition()

返回径向渐变的外侧中心点。

另请参阅 setOuterCenterPosition()。

real outerRadius()

返回径向渐变的外半径。

另请参阅 setOuterRadius()。

void setCenterPosition(real x, real y)

将径向渐变的两个中心点分别设置为 (x,y)。因此,调用此方法后,渐变将呈对称分布(内圈和外圈的位置相同)。

另请参阅 centerPosition()。

void setCenterPosition(point center)

将径向渐变的两个中心点均设置为center 。因此调用此函数后,渐变将呈对称分布(内侧和外侧的位置相同)。

这是一个重载函数。

void setInnerCenterPosition(real x, real y)

将径向渐变的内中心点设置为 (x,y)。

另请参阅 innerCenterPosition()。

void setInnerCenterPosition(point center)

将径向渐变的内中心点设置为center 。

这是一个重载函数。

void setInnerRadius(real radius)

将径向渐变的内半径设置为radius 。起始颜色将从内中心位置向外,以该半径为半径绘制。默认内半径为0.0 ,这意味着渐变直接从内中心位置开始。

另请参阅 innerRadius()。

void setOuterCenterPosition(real x, real y)

将径向渐变的外侧中心点设置为 (x,y)。

另请参阅 outerCenterPosition()。

void setOuterCenterPosition(point center)

将径向渐变的外侧中心点设置为center 。

这是一个重载函数。

void setOuterRadius(real radius)

将径向渐变的外半径设置为radius 。结束色将从外侧中心位置起,以该半径为半径绘制。

另请参阅 outerRadius()。

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