jQuery/JavaScript Library for avatar creation? [cl

2019-02-14 09:00发布

问题:

Is anyone aware of a JavaScript or jQuery library that enables the creation of Pixelart avatars? I'm hoping for something with a Mr. Potatohead style face creation using components and resulting in a GIF.

If not, I guess I'll need to make one myself.

回答1:

You could try Blockies.

Its usage is pretty simple (from the README):

var icon = blockies.create({ // All options are optional
    seed: 'randstring', // seed used to generate icon data, default: random
    color: '#dfe', // to manually specify the icon color, default: random
    bgcolor: '#aaa', // choose a different background color, default: white
    size: 15, // width/height of the icon in blocks, default: 10
    scale: 3 // width/height of each block in pixels, default: 5
});

where icon is a canvas element.

You can't really plan what you're going to get, though: you just end up with a random icon unless you specify a seed to generate it from.