0.0.10 • Published 1 year ago

af-initials-avatar v0.0.10

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Generating an avatar based on a name

npm i af-initials-avatar
import * as fs from 'fs';
import * as path from 'path';
import { generate, getInitials } from 'af-initials-avatar';

let name = 'Benny Any Cony Doo';
let img = generate(name, {
  width: 200,
  palette: ['#0d7554', '#a40e0e', '#0621b9'],
  maxLetters: 2,
  fontProportion: 0.5,
  fontOptions: { family: 'Arial' },
});
fs.writeFileSync(path.resolve('output', `${Date.now()}_${getInitials(2)(name)}.png`), img);

name = '?';
img = generate(name, {
  width: 200,
  palette: ['#25d095'],
  maxLetters: 2,
  fontProportion: 0.6,
  fontOptions: { family: 'Arial', weight: 'bold' },
});
fs.writeFileSync(path.resolve('output', `${Date.now()}_Q.png`), img);

name = 'Any Benny Cony Doo';
img = generate('Any Benny Cony Doo', {
  width: 200,
  palette: ['#25d095', '#ff7373', '#6c8eff'],
  maxLetters: 2,
  fontProportion: 0.8,
  fontOptions: {
    pathToFont: path.resolve(process.cwd(), 'node_modules/af-initials-avatar/src/fonts', 'HarmonyOS_Sans_Regular.ttf'),
    family: 'HarmonyOS Sans',
  },
});
fs.writeFileSync(path.resolve('output', `${Date.now()}_${getInitials(2)(name)}.png`), img);

BA.png

AB.png

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago