Gradient

Facade for creating gradients with a clean API.

Provides static factory methods for convenient gradient creation.
Supports both direct construction and builder pattern.

Methods

conic

static
public static function conic(float $angle, ColorInterface|GradientStop|string|null $stops): ConicGradient|GradientBuilder

Create a conic gradient.

Can be used in two ways:
1. Direct: Gradient::conic(0, '#ff0000', '#0000ff')
2. Builder: Gradient::conic()->from('#ff0000')->to('#0000ff')

Parameters
NameTypeDefault
$angle float 0
$stops ColorInterface|GradientStop|string|null -
public static function distributePositions(array $positions): array

Resolve the positions of stops that were given without one.

Explicit positions are kept as-is. Stops without a position are spread evenly between the
surrounding explicit positions: from 0 before the first explicit position, up to 1 after the
last one, and evenly across the whole gradient when no position is explicit at all.

Parameters
NameTypeDefault
$positions array -

linear

static
public static function linear(float $angle, ColorInterface|GradientStop|string|null $stops): LinearGradient|GradientBuilder

Create a linear gradient.

Can be used in two ways:
1. Direct: Gradient::linear(180, '#ff0000', '#0000ff')
2. Builder: Gradient::linear()->from('#ff0000')->to('#0000ff')

Parameters
NameTypeDefault
$angle float 180
$stops ColorInterface|GradientStop|string|null -

radial

static
public static function radial(ColorInterface|GradientStop|string|null $stops): RadialGradient|GradientBuilder

Create a radial gradient.

Can be used in two ways:
1. Direct: Gradient::radial('#ff0000', '#0000ff')
2. Builder: Gradient::radial()->circle()->from('#ff0000')->to('#0000ff')

Parameters
NameTypeDefault
$stops ColorInterface|GradientStop|string|null -