Generate Github-style Identicon Avatars With Squares – Squareicon

Category: Javascript | December 4, 2019
Author: mistic100
Views Total: 690
Official Page: Go to website
Last Update: December 4, 2019
License: MIT

Preview:

Generate Github-style Identicon Avatars With Squares – Squareicon

Description:

Yet another avatar generator that generates Github-like identicons using squares to representing hash values.

Works both on browser and node.js.

See also:

How to use it:

Install and download the package.

# NPM
$ npm install squareicon --save

Import the main JavaScript file into the document.

<script src="browser.js"></script>

Include the randomcolor library for color schemes.

<script src="https://cdn.jsdelivr.net/npm/[email protected]/randomColor.min.js"></script>

Include the spark-md5 library for the fast md5 implementation.

<script src="https://cdn.jsdelivr.net/npm/[email protected]/spark-md5.min.js"></script>

Create an empty img tag to hold the identicon.

<img id="squareicon"></div>

Generate a basic identicon from an ID you provide.

squareicon({
  id: 'cssscript', 
  hasher: SparkMD5.hash
}, (err, data) => {
  document.querySelector('img').src = data;
});

Customize the identicon with the following options.

squareicon({
  d: null,
  hasher: md5,
  colors: 2,
  pixels: 8,
  size: 128,
  padding: 0,
  symmetry: 'none',
  scheme: 'standard',
  background: 'transparent'
}

Changelog:

12/04/2019

  • v1.0.3

You Might Be Interested In:


Leave a Reply