Skip to main content

Gradient engine

Name: gradient. Output: SVG. Fills a shape with a gradient whose colors are derived from the seed.

Avatar::engine('gradient')
->seed('user@example.com')
->size(256)
->shape('circle')
->gradientType('diagonal')
->colorStops(3)
->generate();

Options​

OptionMethodTypeDefault
Shapeshape()stringcircle
Gradient typegradientType()stringhorizontal
Color stopscolorStops()int3

shape accepts circle, square, or hexagon.

Gradient types​

ValueResult
horizontalLeft-to-right linear gradient (default).
verticalTop-to-bottom linear gradient.
diagonalCorner-to-corner linear gradient.
radialRadial gradient from the center.
wavyLinear gradient with interleaved mid-stops.
marbleLayered, blurred "marble" composition.

The number of color stops is set by colorStops. Colors fan out from the seed's base hue across the requested number of stops.

Marble variant​

When gradientType is marble, the engine renders two overlapping blurred shapes inside a masked frame. Two additional options are read from the option bag for this mode:

  • A rotation value affects the hexagon mask shape.
  • A marbleBlur integer controls the Gaussian blur amount (default 7).

The mask corners follow the shape option (circle, square, or hexagon).