Skip to content

Instantly share code, notes, and snippets.

@Shchvova
Created November 11, 2012 21:00
Show Gist options
  • Save Shchvova/4056243 to your computer and use it in GitHub Desktop.
Save Shchvova/4056243 to your computer and use it in GitHub Desktop.
{
"libraries": [],
"mode": "javascript",
"layout": "sketchpad mode",
"resolution": "480 x 320"
}
<svg height=310 width="480">
</svg>
var img = new Image();
img.src = 'http://i.imgur.com/C3gJY.png';
img.onload = function(e) {
console.log(e.srcElement.src);
var s = document.createElementNS('http://www.w3.org/2000/svg','image');
s.setAttributeNS(null,'height', img.width);
s.setAttributeNS(null,'width', img.height);
s.setAttributeNS('http://www.w3.org/1999/xlink',
'href',this.src);
s.setAttributeNS(null,'x','0');
s.setAttributeNS(null,'y','0');
s.setAttributeNS(null, 'visibility', 'visible');
$('svg').append(s)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment