https://github.com/waseigo/identicon_svg
An Elixir library to generate identicons in SVG format, so that they can be inlined in HTML.
https://github.com/waseigo/identicon_svg
identicon svg
Last synced: 3 months ago
JSON representation
An Elixir library to generate identicons in SVG format, so that they can be inlined in HTML.
- Host: GitHub
- URL: https://github.com/waseigo/identicon_svg
- Owner: waseigo
- License: apache-2.0
- Created: 2023-03-14T10:35:25.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2025-03-17T05:15:39.000Z (7 months ago)
- Last Synced: 2025-05-20T13:49:03.921Z (5 months ago)
- Topics: identicon, svg
- Language: Elixir
- Homepage: https://hex.pm/packages/identicon_svg
- Size: 133 KB
- Stars: 17
- Watchers: 1
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# IdenticonSvg
An Elixir library to generate identicons in SVG format, so they can be inlined in HTML.
[Demo](https://obidenticon.overbring.com/)
## Features
- Github-style square identicon sizes from 4x4 to 10x10. The hashing function is automatically chosen based on the requested size. The foreground color choice is automatic based on the hash.
- Optional (integer) padding.
- Optional background color, manually defined or automatically set as basic or split complementary.
- Transparent background (also on the padding) if no background color specified.
- Optionally non-100% opacity.
- Small SVG file size makes it great for inlining in HTML.
- No external dependencies.## Installation
The package is [available in Hex](https://hex.pm/packages/identicon_svg) and can be installed by adding `identicon_svg` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:identicon_svg, "~> 0.9.4"}
]
end
```## Recent changes
### New since v0.9.0
- _(Since v0.9.4)_ Set the squircle curvature factor with the `:squircle_curvature` keyword option to a float to crop the identicon to a squircle.
- _(Since v0.9.3)_ The mask id is now randomly generated to avoid clashes between multiple SVG identicons on the same page.
- Setting `padding` to a positive integer sets the padding to the identicon to that value. If `bg_color` is non-nil, it will also be applied to the padding area with the with the default (1.0) or requested `opacity`, which is also applied on the foreground and the background.
- The size of the generated SVG code is greatly reduced.### New since v0.8.0
Setting `bg_color` to one of the following 3 atom values sets the color of the background squares to the corresponding RGB-complementary color of the automatically-defined foreground color, with the default (1.0) or requested `opacity`:
- `:basic`: the complementary color, i.e. the opposite color of `fg_color` on the color wheel.
- `:split1`: the first adjacent tertiary color of the complement of `fg_color` on the color wheel.
- `:split2`: the second adjacent tertiary color of the complement of `fg_color` on the color wheel.## Configuration
No configuration required.
## Documentation
The docs can be found at .
There's also a [discussion thread on elixirforum.com](https://elixirforum.com/t/identiconsvg-generates-identicons-in-svg-format-so-they-can-be-inlined-in-html/54557/1).
## TODO (maybe, one day)
- [x] Implement core functionality
- [x] Publish on hex.pm
- [x] Add background color functionality (split-complementary for automatic color-matching)
- [x] Add padding
- [x] Reduce generated SVG file size
- [ ] Implement testing functions
- [ ] Set up CI## Donate
Has this library been useful for your project?
[](https://ko-fi.com/V7V119L07A)