Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nkoepke/Identicon
JavaScript variant of GitHub Identicons
https://github.com/nkoepke/Identicon
identicon identicon-avatar identicon-generator identicon-github identicon-library identicon-svgs identicons javascript js profile profile-image profile-picture svg
Last synced: 21 days ago
JSON representation
JavaScript variant of GitHub Identicons
- Host: GitHub
- URL: https://github.com/nkoepke/Identicon
- Owner: nkoepke
- License: mit
- Created: 2023-03-08T14:21:54.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-24T10:01:23.000Z (3 months ago)
- Last Synced: 2024-08-24T11:21:38.769Z (3 months ago)
- Topics: identicon, identicon-avatar, identicon-generator, identicon-github, identicon-library, identicon-svgs, identicons, javascript, js, profile, profile-image, profile-picture, svg
- Language: JavaScript
- Homepage:
- Size: 15.6 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![Identicon](https://github.com/nkoepke/Identicon/blob/main/images/Identicon.png?raw=true)
# Identicon
JavaScript variant of GitHub Identicons[![GitHub latest commit](https://badgen.net/github/last-commit/nkoepke/Identicon/main)](https://GitHub.com/nkoepke/Identicon/commit/)
[![made-with-javascript](https://img.shields.io/badge/Made%20with-JavaScript-1f425f.svg?logo=javascript)](https://www.javascript.com)## Identicon class
class `Identicon` (options [optional] `object`)
### Options (Constructor)
* color `string` [optional]
* backgroundColor `string` [optional]
* seed `string` [optional] (String of any length to set a specific color for `color`. For example the seed "Test" will always set the color to green.)
You don't have to set the colors in the constructor. You can always change them by setting the attributes after the initialization of the object.
### Attributes
* `grid`
* Internal representation of the icon as a two dimensional array.* `color`
* Color of the icon as a css color. Default `green`.* `backgroundColor`
* Color of the icon as a css color. Default `transparent`.### Methods
* `render()`
* Icon as SVG string.* `randomize()`
* Sets new random pattern to `grid`. Returns the `render()` Method.## Examlpe
```js
const Identicon = require('./src/identicon.js');
let image = new Identicon({color: "purple", backgroundColor: "white"});
console.log(image.render());
```For web browser usage, use as commonJS module or remove ```module.exports = Identicon;``` from the JS file and use it like a regular class.
Then use
```js
let image = new Identicon();
console.log(image.render());// Set new color and new random image
image.color = "#e61c1c";
icon.randomize();
console.log(image.render());
```