Last active
August 29, 2015 13:57
-
-
Save charlycoste/9598406 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
document.onmousemove = function(e){ | |
var rect = document.getElementById('r'); | |
rect.setAttribute('x',e.clientX-(rect.getAttribute('width')/2)); | |
rect.setAttribute('y',e.clientY-(rect.getAttribute('height')/2)); | |
}; | |
document.onclick = function(e){ | |
var point = document.createElementNS("http://www.w3.org/2000/svg",'rect'); | |
var rect = document.getElementById('r'); | |
point.setAttribute('x', e.clientX-50); | |
point.setAttribute('y', e.clientY-50); | |
point.setAttribute('width', 100); | |
point.setAttribute('height', 100); | |
document.getElementById('root').appendChild(point); | |
} |
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
svg { | |
cursor: none; | |
} | |
rect { | |
fill:red; | |
stroke:black; | |
stroke-width:5; | |
opacity:0.5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment