# @emeraldpay/hashicon

> Hashicon - a visual representation of a hash value, as a hexagon

Latest version **0.5.2** (published 2022-02-08) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @emeraldpay/hashicon
pnpm add @emeraldpay/hashicon
yarn add @emeraldpay/hashicon
bun add @emeraldpay/hashicon
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.2 |
| Published | 2022-02-08 |
| First published | 2020-07-08 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 2 |
| Unpacked size | 35.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 201 |
| Author | Richard Schumann |
| Maintainers | splix |
| Keywords | hash, icon, avatar, identicon, generate, generator, visual, canvas |

## Links

- npm: https://www.npmjs.com/package/@emeraldpay/hashicon
- Repository: https://github.com/emeraldpay/hashicon
- Homepage: https://ETCDEVTeam.github.io/hashicon/examples/
- Issues: https://github.com/emeraldpay/hashicon/issues
- npm.io page: https://npm.io/package/@emeraldpay/hashicon

## Dependencies (2)

- [js-sha3](https://npm.io/package/js-sha3.md) ^0.8.0
- [@stablelib/blake2s](https://npm.io/package/@stablelib/blake2s.md) ^1.0.0

## Alternatives

- [@fortawesome/react-fontawesome](https://npm.io/package/@fortawesome/react-fontawesome.md) — 2.2M weekly downloads
- [roboto-fontface](https://npm.io/package/roboto-fontface.md) — 196.0K weekly downloads
- [@react-native-vector-icons/common](https://npm.io/package/@react-native-vector-icons/common.md) — 150.4K weekly downloads
- [@procore/core-icons](https://npm.io/package/@procore/core-icons.md) — 4.6K weekly downloads
- [@react-md/material-icons](https://npm.io/package/@react-md/material-icons.md) — 1.6K weekly downloads

## Recent versions

- 0.5.2 (latest) — 2022-02-08
- 0.5.1 — 2020-07-27
- 0.5.0 — 2020-07-27
- 0.4.0 — 2020-07-08

## README

Hashicon
==========

> Generates a beautiful representation of any hash.

Install
---

Install with: 
```shell
$ npm install @emeraldpay/hashicon --save
```   

Usage
---

Something that you want to represent visually. For example ID of an object on the screen.
```js
// 
const value = "9dddff8f-be81-4c27-80c8-099327865f3f";
```

Create a `hashicon` with default params:
```js
import { hashicon } from 'hashicon';

const icon = hashicon(value); // icon is a <canvas> element
const icon = hashicon(value, 80);  // size 80px
```

Or, pass custom [params](#params):
```js
const params = {...};
const icon = hashicon(value, params);
```

Finally, append the newly created `hashicon` to the HTML document:
```js
document.body.appendChild(icon);
```


Params
---
> See [default params](src/params.ts)

HashIcon's values are extracted from the hash, and controlled with the following parameters to manipulate the possible visual output:

```js
{

// hasher for the input value. "blake2" is default 
// can also be "keccak" (or "legacy"), at this case add dependency to "js-sha3" package
hasher: "blake2",

// size px (HiDPI/Retina aware)
size: 100,

// primary color range radius ( 0=red, 60=yellow, 120=green, ..., 360=red )
hue: { min: 0, max: 360 },

// saturation ( 0=grey, 100=colorfull )
saturation: { min: 70, max: 100 },

// lightness ( 0=extremlydark, 50=optimal, 100=extremlybright )
lightness: { min: 45, max: 65 },

// hue variation for individual triangles
variation: { min: 7, max: 14, enabled: true },

// color shift from primary hue to secondary hue ( the pattern )
shift: { min: 60, max: 300 },

// the pattern opacity
figurealpha: { min: .7, max: 1.2 }, // alpha

// simulate a 3d cube by different areas gets some more/less light applyed 
light:{ top:10, right:-8, left:-4, enabled: true},

// Allows a custom canvas to be used to render into
createCanvas: (width, height) => HTMLCanvasElement

}
```

---
_Source: https://npm.io/package/@emeraldpay/hashicon · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
