Generate Github-style Identicon Avatars With Squares – Squareicon

Category: Javascript | December 31, 2022
Author:mistic100
Views Total:190 views
Official Page:Go to website
Last Update:December 31, 2022
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>

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', 
}, (err, data) => {
  document.querySelector('img').src = data;
});

Customize the identicon with the following options.

squareicon({
  d: null,
  hasher: sha1,
  colors: 2,
  pixels: 8,
  size: 128,
  padding: 0,
  symmetry: 'none', // none, vertical, horizontal, central
  scheme: 'standard', // raw, standard, light, bright, dark
  background: 'transparent'
}

Changelog:

v2.0.0 (12/31/2022)

  • squareicon function now returns a Promise when not called with a callback
  • the default hash algorithm is now SHA1 and uses native implementations (md5 dependency is removed)

You Might Be Interested In:


Leave a Reply