hexicon
v1.1.0
Published
A JavaScript library for generating identicons.
Downloads
12
Readme
HEXICON
A JavaScript library for generating identicons.
![]()
Usage
let hexicon = new Hexicon({
type: 'square',
level: 5,
background: '#f2f2f2',
random: {
string: 'Hello'
}
});
let html = hexicon.toSVG();which outputs:
Configurations
options
| Name | Type | Default | Description |
| - | - | - | - |
| type | string | required | The style of the pattern. |
| random | object | {} | The data used for randomization. If empty, a random seed is used. |
| size | number | 512 | The height and width in pixels of the icon. |
| background | string | transparent | The background color of the icon. |
| color | string | "normal" | The color of the tiles. The value can be normal, dark, light, or a fixed html color. |
| minimum | float | 0.0 | The minimum proportion of the tiles. |
for type=square
| Name | Type | Default | Description |
| - | - | - | - |
| level | number | 5 | The number of rows and columns. |
| symmetrical | bool | true | If the shape is vertically symmetrical. |
for type=hexagon
| Name | Type | Default | Description |
| - | - | - | - |
| level | number | 4 | The number of layers of the centered hexagonal lattice. |
| rotated | bool | false | If true, changes the orientation of the shape. |
| symmetrical | bool | true | If the shape is vertically symmetrical. |
for type=concentration
| Name | Type | Default | Description |
| - | - | - | - |
| level | number | 6 | The number of layers of the concentric polygons. |
| sides | number | 6 | The sides of the polygons. |
| rotated | bool | false | If true, changes the orientation of the shape. |
| bordered | bool | false | If true, always shows the tiles on the outermost layer. |
| symmetrical | bool | true | If the shape is vertically symmetrical. |
options.random
Use only one of the following at a time.
| Name | Type | Example |
| - | - | - |
| string | string | "foobar" |
| bytes | Array | [0x66, 0x6f, 0x6f, 0x62, 0x61, 0x72] |
| hex | string | "666F6F626172" |
| seed | number | 249808880 |
Examples
{
"type": "square"
}{
"type": "square",
"level": 6
}{
"type": "square",
"symmetrical": "false"
}{
"type": "hexagon"
}{
"type": "hexagon",
"rotated": true
}{
"type": "hexagon",
"level": 10
}{
"type": "hexagon",
"minimum": 0.4
}{
"type": "hexagon",
"minimum": 0.6
}{
"type": "hexagon",
"minimum": 0.8
}{
"type": "ConcentrationGenerator",
"sides": 5
}{
"type": "ConcentrationGenerator",
"sides": 8
}{
"type": "ConcentrationGenerator",
"bordered": true
}