- Qt 6.12
- Qt Canvas Painter
- QtCanvas2D
- radialgradient2d
- Qt Canvas Painter | Commercial or GPLv3

# radialgradient2d QML Value Type

Provides radialgradient2d type matching to QCanvasRadialGradient. More...

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

This type is in technology preview and is subject to change.

## Methods

- void addColorStop(real offset, string color)
- point centerPosition()
- point innerCenterPosition()
- real innerRadius()
- point outerCenterPosition()
- real outerRadius()
- void setCenterPosition(real x, real y)
- void setCenterPosition(point center)
- void setInnerCenterPosition(real x, real y)
- void setInnerCenterPosition(point center)
- void setInnerRadius(real radius)
- void setOuterCenterPosition(real x, real y)
- void setOuterCenterPosition(point center)
- void setOuterRadius(real radius)

## Detailed Description

This value type is provided by the QtCanvas2D import.

See also QCanvasRadialGradient.

## Method Documentation

### void addColorStop(real offset, string color)

Adds a color stop with the given color to the gradient at the given offset. 0.0 is the offset at one end of the gradient, 1.0 is the offset at the other end.

For example:

     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()

Returns the center point of radial gradient. This is the same as outerCenterPosition().

See also setCenterPosition().

### point innerCenterPosition()

Returns the inner center point of radial gradient.

See also setInnerCenterPosition().

### real innerRadius()

Returns the inner radius of radial gradient.

See also setInnerRadius().

### point outerCenterPosition()

Returns the outer center point of radial gradient.

See also setOuterCenterPosition().

### real outerRadius()

Returns the outer radius of radial gradient.

See also setOuterRadius().

### void setCenterPosition(real x, real y)

Sets the both center points of radial gradient to ( x, y). So after calling this, the gradient is symmetric (inner and outer positions are the same).

See also centerPosition().

### void setCenterPosition(point center)

Sets the both center points of radial gradient to center. So after calling this, the gradient is symmetric (inner and outer positions are the same).

This is an overloaded function.

### void setInnerCenterPosition(real x, real y)

Sets the inner center point of radial gradient to ( x, y).

See also innerCenterPosition().

### void setInnerCenterPosition(point center)

Sets the inner center point of radial gradient to center.

This is an overloaded function.

### void setInnerRadius(real radius)

Sets the inner radius of radial gradient to radius. Start color will be drawn at this radius from inner center position. The default inner radius is `0.0` meaning that gradient starts directly from inner center position.

See also innerRadius().

### void setOuterCenterPosition(real x, real y)

Sets the outer center point of radial gradient to ( x, y).

See also outerCenterPosition().

### void setOuterCenterPosition(point center)

Sets the outer center point of radial gradient to center.

This is an overloaded function.

### void setOuterRadius(real radius)

Sets the outer radius of radial gradient to radius. End color will be drawn at this radius from outer center position.

See also outerRadius().