Generate Random Cartoon Avatars With JS And SVG – faces.js

Category: Javascript , Recommended | March 18, 2021
Author: dumbmatter
Views Total: 225 views
Official Page: Go to website
Last Update: March 18, 2021
License: Apache 2.0

Preview:

Generate Random Cartoon Avatars With JS And SVG – faces.js

Description:

faces.js is a standalone JavaScript library used for generating random, SVG-based, vector shaped cartoon faces for user avatars.

How to use it:

1. Install and import.

# Yarn
$ yarn add facesjs

# NPM
$ npm i facesjs
import * as faces from "facesjs";

2. OR Download and place the JavaScript file faces.js at the bottom of the webpage.

<script src="faces.js"></script>

3. Generate a random cartoon avatar inside a given container.

<div id="example"></div>
const face = generate();
display("example", face);

4. Get the cartoon avatar as a JS object.

var face = faces.generate("example");
console.log(face);

5. Customize the color of the avatar.

const face = generate({
      body: { color: "yellow" }
});
// or
faces.display("example", face, { 
  body: { color: "yellow" } 
});

6. Specify the race: white, black, asian, or brown.

const face = generate({
      null, 
      {race: "white"}
});

Changelog:

v3.4.0 (03/18/2021)

  • Added some additional jersey options for football and basketball

You Might Be Interested In:


Leave a Reply