Initials engine
Name: initials. Output: SVG. Renders the user's initials over a colored shape.
The initials and color are derived from the name when set, otherwise from the seed. The background and foreground are two lightness variants of the same hue, which is derived from the hash of the name/seed.
Avatar::engine('initials')
->name('John Doe')
->size(256)
->shape('circle')
->fontWeight('bold')
->generate();
Declining
The engine returns null (declines, triggering the fallback chain) when there
are no usable initials — an empty name/seed, or one that yields only 0.
Initials are the first character of each space-separated word, uppercased, and UTF-8 aware.
Options
| Option | Method | Type | Default |
|---|---|---|---|
| Shape | shape() | string | circle |
| Foreground lightness | foregroundLightness() | float | 0.35 |
| Background lightness | backgroundLightness() | float | 0.8 |
| Font size | fontSize() | int | computed from size and initials |
| Font weight | fontWeight() | string | normal |
shape accepts circle, square, or hexagon. The font family is
Segoe UI, Helvetica, sans-serif.
A rotation option (degrees) is read for the hexagon shape; it is not exposed by
a dedicated builder method but is read from the option bag if set.
When fontSize is not supplied, it scales with the avatar size and the number of
initials.