class Gradient extends BaseComponent

Defines how to implement a background gradient fade effect.

Learn more: Content aware padding

Methods

__construct(string $type = null, int $numberOfColors = null, string $direction = null)

Gradient constructor.

type(string $type)

Sets the type of gradient fade.

numberOfColors(int $numberOfColors)

Sets the number of predominant colors to use (2 or 4).

direction(string $direction)

Sets the direction of fade.

__toString()

Serializes to string.

jsonSerialize()

Serializes to json.

Details

__construct(string $type = null, int $numberOfColors = null, string $direction = null)

Gradient constructor.

Parameters

Name Type Description
$type string
$numberOfColors int
$direction string

Gradient type(string $type)

Sets the type of gradient fade.

Parameters

Name Type Description
$type string The type of gradient fade.

Return Value

Gradient

Gradient numberOfColors(int $numberOfColors)

Sets the number of predominant colors to use (2 or 4).

Parameters

Name Type Description
$numberOfColors int The number of predominant colors to use (2 or 4).

Return Value

Gradient

Gradient direction(string $direction)

Sets the direction of fade.

Parameters

Name Type Description
$direction string The direction of fade. Use the constants defined in the GradientDirection class.

Return Value

Gradient

See also

GradientDirection

string __toString()

Serializes to string.

Return Value

string

mixed jsonSerialize()

Serializes to json.

Return Value

mixed

Constants

PREDOMINANT_GRADIENT

Base the gradient fade effect on the predominant colors in the image.

PREDOMINANT_GRADIENT_CONTRAST

Base the effect on the colors that contrast the predominant colors in the image.

BORDER_GRADIENT

Base the gradient fade effect on the predominant colors in the border pixels of the image.

BORDER_GRADIENT_CONTRAST

Base the effect on the colors that contrast the predominant colors in the border pixels of the image.