hashicon-react-native
v0.0.7
Published
React Native Hashicon - React Native component for a visual representation of a hash value, as a hexagon
Downloads
2
Maintainers
Readme
React Native Hashicon
Generates a beautiful representation of any string value.
The React Native implementation of Hashicon by @emeraldpay.
Install with:
$ npm install react-native-hashicon --save
And use the component:
import { Hashicon } from 'react-native-hashicon';
// something that you want to represent visually. For example ID of an object on the screen.
const value = "9dddff8f-be81-4c27-80c8-099327865f3f";
// Example of a Hashicon
<Hashicon value={value}/>
// Same icon with 80px in size
<Hashicon value={value} size={89}/>
Params
See default params
HashIcon's values are extracted from the hash, and controlled with the following parameters to manipulate the possible visual output:
{
// 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
}