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
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')
| Name | Type | Default |
|---|---|---|
$angle |
float | 0 |
$stops |
ColorInterface|GradientStop|string|null | - |
distributePositions
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.
| Name | Type | Default |
|---|---|---|
$positions |
array | - |
linear
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')
| Name | Type | Default |
|---|---|---|
$angle |
float | 180 |
$stops |
ColorInterface|GradientStop|string|null | - |
radial
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')
| Name | Type | Default |
|---|---|---|
$stops |
ColorInterface|GradientStop|string|null | - |