Install jazzicon via npm
masterInstall the jazzicon package as a dependency using npm.
npm install jazzicon -Srepository·master·Indexed 42 days ago
https://github.com/danfinlay/jazziconA library for generating colorful, collage-style identicons based on integer seeds. It provides functions like jazzicon() and generateIdenticon() to create deterministic, 80s-inspired SVG visual representations as DOM elements.
Install the jazzicon package as a dependency using npm.
npm install jazzicon -STo run the included example project, install the beefy package globally and then execute the sample command via npm.
npm i -g beefy
npm run sampleThe jazzicon function generates a colorful, collage-style identicon as a DOM element. It requires two arguments:
diameter (Number): The pixel diameter of the generated icon.seed (Integer): A JavaScript integer used to seed the shape of the icon.The function returns a DOM element that can be appended directly to the document.
var jazzicon = require('jazzicon')
// Generate an icon with 100px diameter and a random seed
var el = jazzicon(100, Math.round(Math.random() * 10000000))
// Use the returned DOM element
document.body.appendChild(el)The generateIdenticon function creates a DOM element containing an SVG identicon. The visual output is determined by a diameter and a seed integer. The function uses a Mersenne Twister PRNG seeded with your input to ensure that the same seed always produces the same visual pattern.
Parameters:
diameter (Number): The width and height of the resulting SVG in pixels.seed (Integer): An integer used to seed the random number generator, ensuring deterministic output.Returns:
HTMLElement: A container element (generated via paperGen) containing the constructed <svg> and its shape elements.const generateIdenticon = require('jazzicon');
// Generate a 100px identicon using seed 12345
const identicon = generateIdenticon(100, 12345);
// Append it to the document
document.body.appendChild(identicon);