Wt: Wt::WGradient Class Reference

Wt 4.10.4

Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
Wt::WGradient Class Reference
Painting system

A linear or radial gradient. More...

`#include <Wt/WGradient.h>`

## Classes
class | ColorStop
| A gradient color stop. More...

## Public Member Functions
| WGradient ()
| Default constructor.
GradientStyle | style () const
| Returns the gradient style.
bool | isEmpty () const
| Returns whether the gradient is empty.
void | setLinearGradient (double x0, double y0, double x1, double y1)
| Configures a linear gradient.
void | setRadialGradient (double cx, double cy, double r, double fx, double fy)
| Configures a radial gradient.
void | addColorStop (double position, const WColor &color)
| Adds a color stop.
void | addColorStop (const ColorStop &colorstop)
| Adds a color stop.
void | clearColorStops ()
| Removes all color stops.
const std::vector< ColorStop > & | colorstops () const
| Returns the color stops.
const WLineF & | linearGradientVector () const
| Returns the line positioning the linear gradient.
const WPointF & | radialCenterPoint () const
| Returns the center of a radial gradient.
const WPointF & | radialFocalPoint () const
| Returns the focal point of a radial gradient.
double | radialRadius () const
| Returns the radius of a radial gradient.
bool | operator== (const WGradient &other) const
| Comparison operator.
bool | operator!= (const WGradient &other) const
| Comparison operator.

## Detailed Description

A linear or radial gradient.

See also
  WPen::setGradient(), WBrush::setGradient()

## Constructor & Destructor Documentation

## ◆ WGradient()

Wt::WGradient::WGradient | ( |  | ) |

Default constructor.

Creates an empty linear gradient from (0,0) to (1,1) (without color stops).

See also
  isEmpty()

## Member Function Documentation

## ◆ addColorStop() [1/2]

void Wt::WGradient::addColorStop | ( | const ColorStop & | colorstop | ) |

Adds a color stop.

Adds a color stop.

## ◆ addColorStop() [2/2]

void Wt::WGradient::addColorStop | ( | double | position,
|  | const WColor & | color )

Adds a color stop.

For a linear gradient, the position is relative to the position on the line (from 0 to 1 corresponding to p0 to p1).

For a radial gradient, the position indicates the distance from the center (from 0 to 1 corresponding to center to radius).

## ◆ clearColorStops()

void Wt::WGradient::clearColorStops | ( |  | ) |

Removes all color stops.

See also
  addColorStop()

## ◆ colorstops()

const std::vector< ColorStop > & Wt::WGradient::colorstops | ( |  | ) | const

Returns the color stops.

See also
  addColorStop()

## ◆ isEmpty()

bool Wt::WGradient::isEmpty | ( |  | ) | const

Returns whether the gradient is empty.

A gradient is empty if no color stops are defined.

## ◆ linearGradientVector()

const WLineF & Wt::WGradient::linearGradientVector | ( |  | ) | const

Returns the line positioning the linear gradient.

This returns the line set in setLinearGradient().

## ◆ radialCenterPoint()

const WPointF & Wt::WGradient::radialCenterPoint | ( |  | ) | const

Returns the center of a radial gradient.

This returns the center point set in setRadialGradient().

## ◆ radialFocalPoint()

const WPointF & Wt::WGradient::radialFocalPoint | ( |  | ) | const

Returns the focal point of a radial gradient.

This returns the focal point set in setRadialGradient().

## ◆ radialRadius()

double Wt::WGradient::radialRadius | ( |  | ) | const

Returns the radius of a radial gradient.

This returns the radius set in setRadialGradient().

## ◆ setLinearGradient()

void Wt::WGradient::setLinearGradient | ( | double | x0,
|  | double | y0,
|  | double | x1,
|  | double | y1 )

Configures a linear gradient.

The coordinates describe a line which provides an origin and orientation of the gradient in user-space coordinates.

## ◆ setRadialGradient()

void Wt::WGradient::setRadialGradient | ( | double | cx,
|  | double | cy,
|  | double | r,
|  | double | fx,
|  | double | fy )

Configures a radial gradient.

A radial gradient is described by a center, a radial and a focus point. All coordinates are user-space coordinates.

## ◆ style()

GradientStyle Wt::WGradient::style | ( |  | ) | const

Returns the gradient style.

See also
  setLinearGradient(), setRadialGradient()