1 min read

Faces.JS: SVG Cartoon Faces Generator

Another JavaScript library for generating vector-based cartoon faces is Faces.JS.

Faces.JS

Each generated face is drawn as Scalable Vector Graphics (SVG), and is also represented by a small JavaScript object that you can store and redraw the same face later.

To install it from NPM, use the following command:

npm install --save facesjs

The minimal code required to generate a face is as follows:

import { display, generate } from "facesjs";
 
// Generate a random face
const face = generate();
 
// Display in a div with id "my-div-id"
display("my-div-id", face);

You also check out their source code on Github.