Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kkweon/identicon-generator-in-elixir

Identicon Generator in Elixir
https://github.com/kkweon/identicon-generator-in-elixir

Last synced: 24 days ago
JSON representation

Identicon Generator in Elixir

Awesome Lists containing this project

README

        

* Identicon

Identicon generator example in Elixir

- Identicon :: An Identicon is a visual representation of a hash value, usually of an IP address, that serves to identify a user of a computer system as a form of avatar while protecting the users' privacy. The original Identicon was a 9-block graphic, and the representation has been extended to other graphic forms by third parties.

* Run

- Install dependencies
#+BEGIN_SRC bash
mix deps.get
#+END_SRC

- Go to REPL
#+BEGIN_SRC bash
iex -S mix
#+END_SRC

- Run the command
#+BEGIN_SRC bash
iex> Identicon.main "Hello World"
#+END_SRC

The identicon of Hello World

[[assets/Hello World.png]]

* How it works

Let's say there is one string input such as username.

#+BEGIN_SRC elixir
def main(input) do
input
|> hash_input
|> pick_color
|> build_grid
|> filter_odd_squares
|> build_pixel_map
|> draw_image
|> save_image(input)
end
#+END_SRC