xream / avataaars

Avataaars as a API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Original React library was developed by Fang-Pen Lin, based on a Sketch library designed by Pablo Stanley.

This is a rewrite of Fang-Pen Lin's work but as a API, this allow it to be used for things like:

  • Serverless function.
  • Generating an avatar from your terminal.
  • Use it inside any web framework.

Being a rewrite we removed, added and renamed stuff so this is not compatible with things like https://getavataaars.com

Usage

npm install re-avataaars --save
import avatar, { clotheColors } from 're-avataaars'

// this outputs a svg xml string
const svg = avatar({
  topType: 'long-hair-curly',
  clothType: 'shirt-v-neck',
  clotheColor: clotheColors.pastelOrange
});

// you can add it directly to DOM (browser)
document.getElementById('foo').innerHTML = svg;

// save it to a file (nodejs)
require('fs').writeFileSync('avatar.svg', svg);

You can use the piece function to show individual pieces of an avatar.

import { piece, clotheColors } from 're-avataaars'

const svg = piece('clothe', {
  clothType: 'graphics',
  clotheColor: '#000000',
  clotheGraphic: 'pizza'
}, { size: '268' });

Check the examples folder if you want to see more ways to use this module.

About

Avataaars as a API

License:MIT License


Languages

Language:JavaScript 100.0%