Created
March 5, 2015 20:19
-
-
Save 8bitDesigner/a50ffd7d49cf7da604fa to your computer and use it in GitHub Desktop.
Generating sized favicons from SVG
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
canvas32 = $('<canvas width=32 height=32>') | |
canvas16 = $('<canvas width=16 height=16>') | |
img = $('<img src="http://hampton.dev/assets/fs-logo-icon.svg">') | |
img.on('load', function() { | |
console.log('loaded') | |
ctx32 = canvas32[0].getContext('2d') | |
ctx32.drawImage(img[0], -4, 5, 39, 18) | |
$('body').append("<img src='"+canvas32[0].toDataURL("image/png")+"'>") | |
ctx16 = canvas16[0].getContext('2d') | |
ctx16.drawImage(img[0], -2, 3, 20, 9) | |
$('body').append("<img src='"+canvas16[0].toDataURL("image/png")+"'>") | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment