okam / avatars

Pixel-Art Avatar Generator by Identifier in JavaScript for Browsers and NodeJS

Home Page:https://avatars.dicebear.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DiceBear Avatars

license npm Bower

Pixel-Art Avatar Generator by Identifier in JavaScript for Browsers and NodeJS.
Test in your Browser: https://avatars.dicebear.com/

Use the HTTP-API

GET https://avatars.dicebear.com/v1/:spriteSet/:seed/:size.png
:spriteSet => male|female
:seed => string|number
:size => 20 - 200 (px)

Examples

Image URL
http://avatars.dicebear.com/v1/male/john-doe/100.png
http://avatars.dicebear.com/v1/male/john-doe/60.png
http://avatars.dicebear.com/v1/female/jane-doe/100.png
http://avatars.dicebear.com/v1/female/jane-doe/60.png

Host your own API-Server

Check out our OpenSource API-Server

Use the library

Installation

Using bower

bower install dicebear-avatars

Using npm

npm install @dicebear/avatars

Use a CDN

Without Dependencies
<script type="text/javascript" src="https://rawgit.com/DiceBear/avatars/master/dist/avatars.min.js"></script>
With dependencies
<script type="text/javascript" src="https://rawgit.com/DiceBear/avatars/master/dist/avatars.pack.min.js"></script>

Download archive

Dependencies

DiceBear Avatars requires async, chance and one-color. Load this libraries from a CDN, from bower or use the avatars.pack.min.js bundled within this Repository.

Create an avatar

Male avatar

var avatars = var Avatars(Avatars.SPRITE_SETS.male);
var seed = 'custom-seed';

avatars.create(seed, { size: 200 }, function(err, canvas) {
  // canvas.toDataURL()
});

Female avatar

var avatars = var Avatars(Avatars.SPRITE_SETS.female);
var seed = 'custom-seed';

avatars.create(seed, { size: 200 }, function(err, canvas) {
  // canvas.toDataURL()
});

Options

  • size: number
  • order: sprite order as array

Create your own sprite sets

1. Step - Create your sprite images

See examples: https://github.com/DiceBear/avatars/tree/master/assets/male

Sprite parts must be arranged horizontally. The library will detect the dimensions automatically.

2. Step - Create your sprite set object

See examples: https://github.com/DiceBear/avatars/tree/master/src/spriteSets


Inspired by 8biticon

About

Pixel-Art Avatar Generator by Identifier in JavaScript for Browsers and NodeJS

https://avatars.dicebear.com/

License:MIT License


Languages

Language:TypeScript 50.1%Language:JavaScript 49.9%