Skip to content

Instantly share code, notes, and snippets.

@tsvensen
Created May 1, 2013 16:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsvensen/5496522 to your computer and use it in GitHub Desktop.
Save tsvensen/5496522 to your computer and use it in GitHub Desktop.
Colorize svg images with javascript using the file/browser path (js): http://elbone.github.io/cdn/codepen/icon.svg#FF0000
Display the source blob
Display the rendered blob
Raw
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="128px" height="96px" viewBox="0 0 128 96" enable-background="new 0 0 128 96" xml:space="preserve">
<rect width="128" height="96"/>
<polygon fill="#FFFFFF" points="80,32.003 50,70 32,56 16,80 112,80 "/>
<circle fill="#FFFFFF" cx="28" cy="28" r="12"/>
<script>document.getElementsByTagName("rect")[0].setAttribute("fill", location.hash);</script>
</svg>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment