npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

randomface

v0.1.1

Published

Vector faces generator focused on uniqueness

Downloads

159

Readme

Randomface

Randomface is JS/TS package for generating vector face-like figures from SHA-256 hash.

About

Although various random face/avatar generators have existed for a long time, none of them provide genuine randomness in face generation. Many rely on pre-defined images of facial features combined with repetitive patterns, which diminishes the uniqueness and individuality of generated faces.

Randomface takes a different approach by keeping only the positions of facial features fixed while randomizing everything else. This results in a vast range of simple abstract facial expressions, making each face unique and easily distinguishable even in large groups.

And it is lightweight - it doesn't have any external dependencies and outputs a plain SVG. The only requirement is a SHA-256 hash for a face input, which should not be a problem to obtain on any modern platform.

Basic Usage

Install package from npm:

npm install randomface

To generate a random face - SHA-256 hash value is required for input. It should not be a problem to obtain it on any modern platform. If you use Randomface to generate users avatars - we suggest to use unique constant user identifier as a hash input (e.g. user id)

import { RandomfaceSVG } from 'randomface';

// In the browser, you can use the SubtleCrypto API to create a hash for the given value.
// In NodeJS you can use native "crypto" package. Other open source packages are available as well.
let hash = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855';

const myFace = RandomfaceSVG(hash);

// generated face contains full svg element and svg paths for each face part in case you want to style it and create svg manually

console.log(myFace.svg);
// <svg viewBox='0 0 100 100' {...} </svg>

console.log(myFace.paths.leftEye);
// M 1 11 C 1.8 7.2 {...} Z

console.log(myFace.paths.rightEye);
// M 97 2 C 98.6 2.4 {...} Z

console.log(myFace.paths.nose);
// M 55 40 C 56.2 36.8 {...} Z

console.log(myFace.paths.mouth);
// M 19 80 C 18.8 76 29 {...} Z