Skip to content

Latest commit

 

History

History
62 lines (42 loc) · 1.29 KB

README.md

File metadata and controls

62 lines (42 loc) · 1.29 KB

Nanoidenticons

A small library for generating identicons, based on Blockies.

Preview

Demo page

Browser

import { createIcon } from '@keerifox/nanoidenticons';

var icon = createIcon({
    seed: 'nano_1234...', // seed used to generate icon data, default: random
    scale: 16 // width/height of each block in pixels, default: 4
});

document.body.appendChild(icon); // icon is a canvas element

In the above example the icon will be 8x8 blocks, and each block will be 16x16 pixels. The icon canvas will be 128x128 pixels.

Node

import { createCanvas } from 'canvas'; 
import { renderIcon } from '@keerifox/nanoidenticons';

const canvas = createCanvas(128, 128);

var icon = renderIcon(
    {
        seed: 'nano_1234...', // seed used to generate icon data, default: random
        scale: 16 // width/height of each block in pixels, default: 4
    },
    canvas
);

Notes

The defaults of scale 4 generate 32x32 pixel icons. Below are some standard sizes that work well.

  • 32x32 {scale: 4}
  • 64x64 {scale: 8}
  • 128x128 {scale: 16}

Build

npm run build

License

WTFPL