Path2D example
by Shashank D
HTML
<!-- Learn about this code on MDN: https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Drawing_shapes -->
<html>
<body onload="draw();">
<canvas id="canvas" width="130" height="100"></canvas>
</body>
</html>
JavaScript
function draw() {
var canvas = document.getElementById('canvas');
if (canvas.getContext){
var ctx = canvas.getContext('2d');
// var rectangle = new Path2D();
// rectangle.rect(10, 10, 50, 50);
var circle = new Path2D();
circle.moveTo(125, 35);
circle.arc(100, 35, 25, 0, 2 * Math.PI);
// ctx.stroke(rectangle);
ctx.fill(circle);
console.log(ctx.isPointInPath(circle, 100, 35));
}
}