Advertisement
Home Open Editor ❯

HTML canvas isPointinPath() Method

Example

let c = document.getElementById("myCanvas");
let ctx = c.getContext("2d");

ctx.rect(25, 25, 75, 50);
if (ctx.isPointInPath(25, 50)) {
  ctx.stroke();
};

Try this code ❯

Meaning

The isPointinPath() method returns true if the specified point is in the current path, otherwise false.


Standard Syntax

JavaScript syntax:

context.isPointinPath(x,y);


Advertisement

Parameter Values

Parameter Description
x Specifies the x-coordinate to test
y Specifies the y-coordinate to test
Home Open Editor ❯
Advertisement