Introduction

edit

Meziantou.Framework.Avatar generates avatars: small SVG images that show the initials of a name on a colored background. Use them for the users, teams or projects that have no picture.

A round avatar with the initials JD A round avatar with the initials JP A round avatar with the initials OB A round avatar with the Japanese characters 山田

What you can do with it

  • Generate an avatar from a name, as an SVG string you embed in a page or save as a file. See Getting started.
  • Change its appearance: the shape, the size and the palette of colors. See Appearance.
  • Control the initials: the library picks one or two graphemes from the name, or uses the text you give. See Initials.
  • Make it accessible: announce the full name, or hide a decorative avatar from screen readers. See Accessibility.
  • Rely on stable colors: the same name always gets the same color, for a given palette. See Stable colors.

Principles

  • Deterministic. The output depends only on the name and the options: no randomness, no state.
  • Text only. The result is an SVG string. Rendering it to pixels is the job of the browser, or of whatever displays it. The initials are drawn with the bold monospace font of the viewer.
  • Safe with untrusted names. The output is always well-formed XML, whatever the name contains.

Namespace

The types are in the Meziantou.Framework namespace:

TypeContains
AvatarGeneratorThe CreateSvg methods
AvatarOptionsThe shape, the size, the palette, the initials and the accessibility options
AvatarShapeRound, Square and RoundedSquare
AvatarColorPairA background color and a foreground color

Next steps