Skip to content

Instantly share code, notes, and snippets.

@elrrrrrrr
Created November 13, 2014 12:02
Show Gist options
  • Save elrrrrrrr/a9209a66b43dace5b408 to your computer and use it in GitHub Desktop.
Save elrrrrrrr/a9209a66b43dace5b408 to your computer and use it in GitHub Desktop.
SVG-circle-image
var circle = paper.circle(size/4, size/4, 40);
var uuid = Raphael.createUUID();
var pattern = document.createElementNS("http://www.w3.org/2000/svg", "pattern");
var backgroundImage = paper.image("../css/tx.png", 0, 0, 1, 1);
pattern.setAttribute("id", uuid);
pattern.setAttribute("x", 0);
pattern.setAttribute("y", 0);
pattern.setAttribute("height", 1);
pattern.setAttribute("width", 1);
pattern.setAttribute("patternContentUnits", "objectBoundingBox");
pattern.appendChild(backgroundImage.node);
paper.defs.appendChild(pattern);
circle.node.setAttribute("fill", "url(#" + pattern.id + ")");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment