Identicons v0.1.1 Identicon View Source

Documentation for Identicon.

Example

The folder generated_identicon/ must exist

iex>Identicon.main "test", 250, "generated_identicon/"
:ok

Link to this section Summary

Functions

Adds a grid to %Identicon.Image{} as a list of tuples with the values and the index

Extends the index of the grid to 50px squares as {{x_top_left, y_top_left}, {x_bot_right, y_bot_right}}

Uses a erlang image library to create a image with the rectangles from pixel_map

Removes odd numbers from the grid

Creates a hashed list from the input and returns the result as %Identicon.Image{hex: hex}

Main function to run the identicon

  • input Text to generate the pattern
  • size size of the image
  • directory path to the folder to put the image

Adds a mirror of the row to it self

Takes in the data struct %Identicon.Image{} and saves it in image

Saves the image to a file

Link to this section Functions

Adds a grid to %Identicon.Image{} as a list of tuples with the values and the index

Enum.map(&mirror_row/1) same as Enum.map(&mirror_row(&1))

Link to this function build_pixel_map(image, size) View Source

Extends the index of the grid to 50px squares as {{x_top_left, y_top_left}, {x_bot_right, y_bot_right}}

Uses a erlang image library to create a image with the rectangles from pixel_map

Removes odd numbers from the grid

Creates a hashed list from the input and returns the result as %Identicon.Image{hex: hex}

Link to this function main(input, size \\ 250, directory \\ "") View Source

Main function to run the identicon

  • input Text to generate the pattern
  • size size of the image
  • directory path to the folder to put the image

Adds a mirror of the row to it self

Takes in the data struct %Identicon.Image{} and saves it in image

Then atribues to r, g, b the values of the first 3 items in the hex: [] on the list and leaves the rest

%Identicon.Image{hex: [r, g, b | _]} = image

Never change a variable, only create a new one with diferent values

%Identicon.Image{image | color: {r, g, b}}
Link to this function save_image(image, input, directory) View Source

Saves the image to a file