View Source Avatador (avatador v0.1.0)

Avatador

Link to this section Summary

Functions

Create an avatar from a Map of options. Returns a ~s() SVG.

Create an identicon from a Map of options. Returns a ~s() for SVG or a base64 encoded PNG.

Link to this section Functions

Link to this function

avatar(assigns \\ %{})

View Source (since 0.1.0)

Create an avatar from a Map of options. Returns a ~s() SVG.

examples

Examples

# An avatar with background of "#962ED" and name "John Doe"
iex> Avatador.avatar(%{background: "96C2ED", name: "John Doe"})

# An avatar with a random background, name "John Doe", and width of "50px"
iex> Avatador.avatar(%{name: "John Doe", width: "50"})

arguments

Arguments

  • :background The background color of the avatar, without the hash (#) e.g. 000000.
  • :color The text color of the avatar, without the hash (#) e.g. FFFFFF.
  • :name The name/username/email of the entity you want the avatar's initials to represent.
  • :is_rounded True or false, should avater be rounded? If true and no rounded value it assumes the width/height (fully rounded).
  • :rounded The px value of rounding, leave blank or 0 for no rounding.
  • :width The height of the avatar in pixels. If not provided assumes width=height or default value.
  • :height The width of the avatar in pixels. If not provided assumes width=height or default value.
  • :font_size The font size in pixels.
  • :font_family The name of the font family.
  • :caps Capitalization of the initials. 1 for uppercase, 2 for lowercase, 3 for leaving as provided.
  • :bold True or false, should text be bold?

defaults

Defaults

%{
  background: "#000000",
  color: "#FFFFFF",
  name: "",
  is_rounded: false,
  rounded: 0.0,
  width: 500.0,
  height: 500.0,
  font_size: 250.0,
  font_family: "Montserrat",
  caps: 1,
  bold: true,
}
Link to this function

identicon(assigns \\ %{})

View Source (since 0.1.0)

Create an identicon from a Map of options. Returns a ~s() for SVG or a base64 encoded PNG.

examples

Examples

# An identicon with background of "#962ED" and name "John Doe"
iex> Avatador.identicon(%{background: "96C2ED", name: "John Doe"})

# An identicon in PNG with a random background, name "John Doe", and width of "50px"
iex> Avatador.identicon(%{format: "PNG", background: "96C2ED", name: "John Doe", width: "50"})

arguments

Arguments

  • :format SVG or PNG output.
  • :background The background color of the avatar, without the hash (#) e.g. 000000.
  • :color The text color of the avatar, without the hash (#) e.g. FFFFFF.
  • :name The name/username/email of the entity you want the avatar's initials to represent.
  • :is_rounded True or false, should avater be rounded? If true and no rounded value it assumes the width/height (fully rounded).
  • :rounded The px value of rounding, leave blank or 0 for no rounding.
  • :width The height of the avatar in pixels. If not provided assumes width=height or default value.
  • :height The width of the avatar in pixels. If not provided assumes width=height or default value.

defaults

Defaults

%{
  format: "SVG",
  background: "#000000",
  color: "#FFFFFF",
  name: "",
  is_rounded: false,
  rounded: 0.0,
  width: 500.0,
  height: 500.0,
}