Created
November 4, 2021 14:32
-
-
Save arnoson/34c24424ab3e4bae65690a8e814d9102 to your computer and use it in GitHub Desktop.
Create a dash array with holes in it
This file contains 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
const path = new Path.Circle({ | |
radius: 200, | |
strokeColor: 'blue', | |
center: view.center, | |
strokeCap: 'round', | |
strokeWidth: 3 | |
}) | |
const gap = 50 | |
const offsets = [] | |
const updateDashes = () => { | |
const dashes = [] | |
let lastOffset = 0 | |
for (const offset of offsets) { | |
dashes.push(offset - lastOffset - gap / 2) | |
dashes.push(gap) | |
lastOffset = offset + gap / 2 | |
} | |
dashes.push(path.length) | |
path.dashArray = dashes | |
} | |
function onMouseDown(event) { | |
const point = path.getNearestPoint(event.point) | |
const offset = path.getOffsetOf(point) | |
offsets.push(offset) | |
updateDashes() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment