Created
December 14, 2018 11:31
-
-
Save alicethewhale/527546af9046b463274c7838c44c3d25 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
let startX = 0; | |
let startY = 0; | |
const mainTree = document.querySelector(".main-tree"); | |
function startTinsel(e) { | |
if (decSelector.value === "tinsel") { | |
startX = e.clientX - 58; | |
startY = e.clientY - 82; | |
} | |
} | |
function endTinsel(e) { | |
if (decSelector.value === "tinsel") { | |
const tinsel = document.createElementNS("http://www.w3.org/2000/svg", 'path'); | |
let endX = e.clientX - 58; | |
let endY = e.clientY - 82; | |
tinsel.classList.add("tinsel"); | |
tinsel.setAttribute("d", `M ${startX},${startY} C ${startX},${startY+18} ${endX},${endY+18} ${endX},${endY} `); | |
mainTree.appendChild(tinsel); | |
} | |
} | |
triangles.forEach(triangle => triangle.addEventListener('mousedown', startTinsel)); | |
triangles.forEach(triangle => triangle.addEventListener('mouseup', endTinsel)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment