Last active
September 28, 2021 13:24
-
-
Save YonatanKra/6b3e85c685fc5e717c066bbe2bfcf7e0 to your computer and use it in GitHub Desktop.
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
function isCircleInPath(circleData, path) { | |
const ctx = document.createElement("canvas").getContext("2d"); | |
const radius = circleData.radius; | |
for ( | |
let x = circleData.x - radius; | |
x <= circleData.x + 2 * radius; | |
x += radius | |
) { | |
for ( | |
let y = circleData.y - radius; | |
y <= circleData.y + 2 * radius; | |
y += radius | |
) { | |
if (ctx.isPointInPath(path, x, y)) return true; | |
} | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment