Created
April 22, 2014 17:40
-
-
Save abstrctn/11188031 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var s=document.createElement('script'); | |
s.setAttribute('src','http://code.jquery.com/jquery.js'); | |
document.getElementsByTagName('body')[0].appendChild(s); | |
setTimeout(function() { | |
svg = $("svg[width=690]")[0]; | |
var svgNS = svg.namespaceURI; | |
var bg = document.createElementNS(svgNS, 'pattern'); | |
bg.setAttribute('id', 'derek'); | |
bg.setAttribute('x', 10); | |
bg.setAttribute('y', 10); | |
bg.setAttribute('patternUnits', 'userSpaceOnUse'); | |
bg.setAttribute('height', 19); | |
bg.setAttribute('width', 19); | |
var image = document.createElementNS("http://www.w3.org/2000/svg", "image"); | |
image.setAttribute('x', 0); | |
image.setAttribute('y', 0); | |
image.setAttribute('width', 19); | |
image.setAttribute('height', 19); | |
image.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "http://graphics8.nytimes.com/packages/images/nytint/projects/upshot/derek-willis.jpg"); | |
bg.appendChild(image); | |
var defs = svg.insertBefore( document.createElementNS(svgNS,'defs'), svg.firstChild); | |
defs.appendChild(bg); | |
var circles = $(svg).find("circle"); | |
for (i=0; i<circles.length; i++) { | |
var circle = circles[i]; | |
circle.setAttribute('style', ''); | |
circle.setAttribute('fill', "url(#derek)"); | |
} | |
}, 500); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment