랭킹으로 돌아가기

multiavatar/Multiavatar

JavaScriptmultiavatar.com

Multicultural Avatar Generator in JavaScript

avatar-generatoravatar-makeravatar
스타 성장
스타
1.9k
포크
181
주간 성장
이슈
7
5001k1.5k
2020년 11월2022년 9월2024년 8월2026년 7월
아티팩트npmnpm install multiavatar
README

Multiavatar

Multiavatar is a multicultural avatar maker.

Multiavatar represents people from multiple races, multiple cultures, multiple age groups, multiple worldviews and walks of life.

In total, it is possible to generate 12,230,590,464 unique avatars.

Installation and usage

Include the script and pass any string to the 'multiavatar' function. It will return the SVG code for the avatar.

Using npm:

npm i @multiavatar/multiavatar

CommonJS:

const multiavatar = require('@multiavatar/multiavatar')
let svgCode = multiavatar('Binx Bond')

ES Module:

import multiavatar from '@multiavatar/multiavatar/esm'
let svgCode = multiavatar('Binx Bond')

Using the script tag:

<script src="multiavatar.min.js"></script>

<script>
  var avatarId = 'Binx Bond';
  var svgCode = multiavatar(avatarId);
</script>

Include from CDN:

<script src="https://cdn.jsdelivr.net/npm/@multiavatar/multiavatar/multiavatar.min.js"></script>

Info

The initial unique 48 (16x3) avatar characters are designed to work as the source from which all 12 billion avatars are generated.

You can find them in the svg folder. These initial characters can be edited with a vector drawing program, such as Inkscape. They are in grayscale, since the color is applied later by the script, and grayscale is better for shapes design.

Every avatar consists of 6 parts:

  • Environment
  • Clothes
  • Head
  • Mouth
  • Eyes
  • Top

Also, there are different versions of different parts. In some final avatars, additional parts are hidden with transparency (none for the color) to create different shapes by re-using the same code. Also, each avatar has 3 unique color themes that are defined in the script. In total, there are: 16 characters x 3 versions/themes = 48 initial unique avatars. You can see them all by opening the svg/index.html file in your browser.

To create new avatars, the Multiavatar script mixes different parts of different avatars, and different color themes.

The total number of unique avatars: 48^6 = 12,230,590,464

One of the main Multiavatar functions is to work as an identicon. Every unique avatar can be identified by the unique string of characters, associated with the avatar.

The string of characters is also the input for the Multiavatar script, which converts the provided string into a 6 double-digit numbers (range 00-47), each representing an individual part of the final avatar.

000000000000 - this string of numbers represents the very first avatar + its A theme. You can also read it like this: 00 00 00 00 00 00.

474747474747 - this is the 12,230,590,464th avatar (or the 16th initial avatar + its "C" color theme).

More info can be found in the multiavatar.js file comments.

Development

Multiavatar is coded in vanilla JavaScript. Only a single library (SHA-256) is used, integrated into the script. The initial character designs in SVG are also integrated into the script. So there is a single dependency-free JavaScript file that has everything in it (minified 68 KB).

To test different parts manually, you can uncomment them in the code.

Also, the Multiavatar script accepts the following three paramenters: string, sansEnv, ver.

string - The text string that will be converted into the avatar. This parameter is required, the other two are optional.

sansEnv - If this is true, the script returns the final avatar without the circle background (environment part).

ver - Pass an object to force a specific initial version, for example: multiavatar('test', false, {'part': '01', 'theme': 'A'});

While the algorithm generates 12 billion unique avatars, some parts (eyes, mouth) are still similar, so it means that currently there are less than 12 billion unique avatars. It is trivial to make all avatars unique by slightly changing the color, but visually that would not make a difference. That's why instead of forcing a formal solution, some parts are left unfinished intentionally.

The design of shapes, and the multicultural balance of avatars are also open for further polishing, optimization, creative ideas and improvements.

Design

The final SVG files are saved (Inkscape 1.0 as "Optimized SVG") with the _final suffix in the svg folder.

After editing the SVG files with a vector program, overwrite the existing _final.svg files with your new versions. Then run the _build.php script to automatically update the multiavatar-dev.js script with the new SVG code from your _final.svg files.

API

To get an avatar as SVG code, add the avatar's ID to the URL:

https://api.multiavatar.com/Binx Bond

JavaScript API call example to get SVG code:

let avatarId = 'Binx Bond'
fetch('https://api.multiavatar.com/'
+JSON.stringify(avatarId))
  .then(res => res.text())
  .then(svg => console.log(svg))

To get an avatar as SVG file, add .svg to the end of the URL:

https://api.multiavatar.com/Binx Bond.svg

To get an avatar as PNG file, add .png to the end of the URL:

https://api.multiavatar.com/Binx Bond.png

License

You can use Multiavatar for free, as long as the conditions described in the LICENSE are followed.

Screenshots

More info

For additional information and extended functionality, visit the multiavatar.com web-app.

The app is based on static html for the home page, and on Laravel 8 + Vue.js for extended functionality, including the web store.

The product mockup generator for the Merch Maker is based on the ImageMagick library.

관련 저장소
boringdesigners/boring-avatars

Boring avatars is an open source React library that generates custom, SVG-based avatars from any username and color palette.

TypeScriptnpmMIT Licensereactjavascript
boringavatars.com
6.3k212
minivision-ai/photo2cartoon

人像卡通化探索项目 (photo-to-cartoon translation project)

PythonPyPIMIT Licensecartoondeep-learning
4k766
Codennnn/vue-color-avatar

An online avatar generator just for fun | 一个纯前端实现的头像生成网站

VueMIT Licensevue3vite
vue-color-avatar.leoku.dev
3.8k488
fangpenlin/avataaars-generator

Simple generator React app for avataaars

TypeScriptnpmMIT Licensereactavatar
getavataaars.com
3k387
nusu/avvvatars

Beautifully crafted unique avatar placeholder for your next react project

TypeScriptnpmMIT Licensereactplaceholder-avatars
avvvatars.com
2k87
YuliangXiu/ICON

[CVPR'22] ICON: Implicit Clothed humans Obtained from Normals

PythonPyPIOtherimplicit-functionsvirtual-humans
icon.is.tue.mpg.de
1.7k220
dapi-labs/react-nice-avatar

react library for generating avatar

TypeScriptnpmMIT Licensereactreact-avatar
nice-avatar.wwayne.com
1.3k122
Francis-Rings/StableAvatar

We present StableAvatar, the first end-to-end video diffusion transformer, which synthesizes infinite-length high-quality audio-driven avatar videos without any post-processing, conditioned on a reference image and audio.

PythonPyPIMIT Licenseaigcavatar-generator
1.2k113
YuliangXiu/ECON

[CVPR'23, Highlight] ECON: Explicit Clothed humans Optimized via Normal integration

PythonPyPIOther3d-reconstructionavatar-generator
xiuyuliang.cn/econ
1.2k115