Giter Site home page Giter Site logo

elixir-identicon's Introduction

Identicon Generator

About

This app creates a unique identicon based on an input string.

Users can have a unique identicon made for them if they do not upload a profile image (as seen on sites like github).

The identicon generator always creates the same identicon based on the same string. So images can be created on the fly and do not need to be stored.

Example

The Identicon generated for my name "Sam" is:

Sam Identicon

How

An identicon is a square 300x300px image made of 25 smaller squares on a 5x5 grid that is mirrored down the middle.

Identicon grid

Create a Hex

Each string passed to the function is turned into an MD5 hash and returned as an array of 16 numbers.

Pick a Color

The first three numbers in the array are used to define the RGD color value.

Generate grid

The first 15 numbers are used to determine true or false on whether a square will have colour in it for the first three columns in the square. We make five arrays of three numbers.

(we throw away the sixteenth number)

Mirror first two number of each array to turn it into a 5 number array that is the whole row.

Draw image

We make a pixel map with on a 300x300 px map and draw to an image


Running Locally

Install Erlang and Elixir - Instructions

Open Elixir shell - >> iex -S mix

Run main Identicon function with your desired string

iex> Identicon.main("my_string_here")

Identicons are generated and added to the '/identicons' folder as a png.


Install and use as a Package

If available in Hex, the package can be installed by adding identicon to your list of dependencies in mix.exs:

def deps do
  [
    {:identicon, "~> 0.1.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/identicon.


Thanks to Stephen Grider and his tutorial on Elixir and identicon creation!

elixir-identicon's People

Contributors

samjam48 avatar

Stargazers

Gergana ゲルガナ avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.