Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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