laurentpayot / minidenticons-elm / Minidenticons

This library contains the main identicon function as well as a bonus simpleHash function.

SVG identicon

identicon : Basics.Int -> Basics.Int -> String -> Html msg

Generate the SVG identicon.

The identicon function will return a SVG element generated from its username string argument. The saturation and lightness arguments have to be percentages, i.e integers between 0 and 100.

For instance for the username "alienHead66", with a saturation of 75% and a lightness of 50%:

identicon 75 50 "alienHead66"

You will get the following identicon (without the border):

"alienHead66" identicon - Note that the picture above is resized. By default identicons will take all the space available.

Play with the demo to find a combination of saturation and lightness that matches your website theme colors: light, dark, pastel or whatever 😎

Minidenticons light Minidenticons dark Minidenticons pastel

Bonus

simpleHash : String -> Basics.Int

Hash function used by Minidenticons. Based on the FNV1a hash algorithm, modified for signed 32 bit integers. Always return a positive integer.

simpleHash "alienHead66" -- 39870209603664160