0.0.4 • Published 3 years ago

@kodoti/koditar v0.0.4

Weekly downloads
2
License
ISC
Repository
github
Last release
3 years ago

KODITAR

Create an avatar image by taking the initials of a person's name or whatever.

How to install?

npm install @kodoti/koditar

Example

window.onload = () => {
    const image = document.createElement('img');

    // the library create a base64 image
    image.src = Koditar.render('Eduardo Rodríguez Patiño');

    document.body.append(image);
};

Live Example

https://jsfiddle.net/erodriguezp105/dxhgrv6n/1/

⚠️Note

The avatar can't recognize between the first and the last name, take care about that.

👉 This means that the script will only take the first letter of each word passed.

InputOutput
Eduardo Rodríguez PatiñoER
Juan Jose Gonzales MirandaJJ
Alberto Miguel Javier Perez LozanoAM
EduardoE
AXAX
AA

The result will be one or two letters in uppercase.

Customize your avatar

You can customize your avatar adding extra properties to the second parameter of the function:

Parameter nameDefaultexplain
size300Width and height reference.
bgColor'#eee'Background color reference.
color'#222'Color of the font.
fontFamily'Calibri'Font family which will be used.
fontSize100Reference to font-weight property.

Usage

Koditar.render('Eduardo Rodríguez Patiño', {
    size = 300,
    bgColor = '#eee',
    color = '#222'
});

Other examples

Direct link

To avoid use webpack, gulp or something similar.

Just press right click here and download it (it always will be the latest version).