Draw a representation of a Minecraft skin using JavaScript
ISC License
Work-in-progress code to draw a representation of a Minecraft skin using JavaScript.
Minecraft-Avatars is licensed under the ISC license, see COPYING.
Run make
to generate a minified version of the script using UglifyJS.
Load jQuery before minecraft-avatars.
Given someElement
, run
$(someElement).minecraftAvatar({ player: 'PlayerName' });
to render the avatar inside someElement
. The element will be emptied first.
You can alternatively pass the player name as a data attribute:
<span class="m" data-player="PlayerName">☺</span>
<span class="m" data-player="AnotherPlayer">☺</span>
$('.m').minecraftAvatar();
See the demo stylesheet for hints about how to scale the avatars using CSS.
The following callbacks are available:
$(someElement).minecraftAvatar({
onCreate: function (canvas) { },
onLoad: function (canvas) { },
onError: function () { }
});
onCreate
is called immediately after the canvas element has been added to the page.
onLoad
is called after the skin has been loaded and rendered successfully.
onError
is called upon failure to load the skin.
hasAlpha
function controls whether head accessories are rendered and it returns a constant false
at the moment.