Skip to content

Instantly share code, notes, and snippets.

@taivare
Created March 29, 2016 16:02
Show Gist options
  • Save taivare/d55d569bc5bfd52c0c0a to your computer and use it in GitHub Desktop.
Save taivare/d55d569bc5bfd52c0c0a to your computer and use it in GitHub Desktop.
Tributary inlet
{"editor_editor":{"coffee":false,"vim":false,"emacs":false,"width":579,"height":508,"hide":false},"endpoint":"","description":"Tributary inlet","display":"svg","public":true,"require":[],"fileconfigs":{"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"inlet.svg":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"ajax-caching":true}
var svg = d3.select("svg");
svg.append("rect")
.attr({
width: 200,
height: 200,
x: 100,
y: 100,
fill: "#1A9224",
})
svg.append("image")
.attr({
width: 200,
height: 200,
"xlink:href": "https://twimg0-a.akamaihd.net/profile_images/2560186719/7f57h85fjrqelks62v75.jpeg",
x: 325,
y: 100
})
function cerealize(node) {
var svgxml = (new XMLSerializer()).serializeToString(node);
if($.browser.webkit){
svgxml = svgxml.replace(/ xlink/g, ' xmlns:xlink');
svgxml = svgxml.replace(/ href/g, ' xlink:href');
}
return svgxml;
}
//usage:
var exp = cerealize(svg.node());
console.log(exp);
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment