navatar
v1.0.4
Published
<object data="https://navatar-demo.herokuapp.com/avatar/try-it!.svg"></object>
Downloads
7
Readme
#Navatar, the Node.js Avatar Generator
Generate visually-pleasing, unique avatars using Node.js
Key Features
- Easily add randomly generated avatars to your existing Express application using the built-in middleware
- Generate fast SVG images that look good at any size
Notes
- For production performance, it is recommended that you cache generated images as PNGs using your exisitng file server
- No support for PNG files yet (you can optionally read the SVG from the route and convert into a PNG using
svg2png
- this process works but is slow)
How it works
Navatar uses built-in algorithms to create cellular automata, a la Stephen Wolfram's "A New Kind of Science", which heavily influenced this project. When the MiddleWare is invoked, an SVG is randomly generated based on the key provided, and sent to the user.
Usage
- First, install via NPM
npm install --save navatar
- Then, add as
express
MiddleWare...
const { getNavatarMiddleware } = require('navatar');
const express = require(`express`);
const app = new express();
app.use('/avatar/:key.svg',getNavatarMiddleware());
app.listen(666);
Now, your /avatar
route will serve up SVGs!
Options
Custom width and height
Pass width and height as query paramaters to modify the size of the generated glyph. (It is recommended to use the same value for width and height.)
//example
http://localhost/avatar/this-rocks.svg?height=150&width=150
Coming Soon!
- Support for additional tree-generation algorithms
- Better color palette support
- PNG support (one day!)