1.1.0 • Published 2 years ago

hexicon v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

HEXICON

Gem Version LICENSE

A JavaScript library for generating identicons.

npm.io

Usage

let hexicon = new Hexicon({
  type: 'square',
  level: 5,
  background: '#f2f2f2',
  random: {
    string: 'Hello'
  }
});
let html = hexicon.toSVG();

which outputs:

npm.io

Configurations

options

NameTypeDefaultDescription
typestringrequiredThe style of the pattern.
randomobject{}The data used for randomization. If empty, a random seed is used.
sizenumber512The height and width in pixels of the icon.
backgroundstringtransparentThe background color of the icon.
colorstring"normal"The color of the tiles. The value can be normal, dark, light, or a fixed html color.
minimumfloat0.0The minimum proportion of the tiles.

for type=square

NameTypeDefaultDescription
levelnumber5The number of rows and columns.
symmetricalbooltrueIf the shape is vertically symmetrical.

for type=hexagon

NameTypeDefaultDescription
levelnumber4The number of layers of the centered hexagonal lattice.
rotatedboolfalseIf true, changes the orientation of the shape.
symmetricalbooltrueIf the shape is vertically symmetrical.

for type=concentration

NameTypeDefaultDescription
levelnumber6The number of layers of the concentric polygons.
sidesnumber6The sides of the polygons.
rotatedboolfalseIf true, changes the orientation of the shape.
borderedboolfalseIf true, always shows the tiles on the outermost layer.
symmetricalbooltrueIf 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

npm.io

npm.io

npm.io

{
  "type": "square"
}
{
  "type": "square",
  "level": 6
}
{
  "type": "square",
  "symmetrical": "false"
}

npm.io

npm.io

npm.io

{
  "type": "hexagon"
}
{
  "type": "hexagon",
  "rotated": true
}
{
  "type": "hexagon",
  "level": 10
}

npm.io

npm.io

npm.io

{
  "type": "hexagon",
  "minimum": 0.4
}
{
  "type": "hexagon",
  "minimum": 0.6
}
{
  "type": "hexagon",
  "minimum": 0.8
}

npm.io

npm.io

npm.io

{
  "type": "ConcentrationGenerator",
  "sides": 5
}
{
  "type": "ConcentrationGenerator",
  "sides": 8
}
{
  "type": "ConcentrationGenerator",
  "bordered": true
}
1.1.0

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago