I like to see if mouseclick is in a rectangle area (in canvas). In C# i would do this.
var point = new Point(x, y);
var rectangles = new List<Rect>();
//rectangles.add(new Rect(x,y,h,w));
foreach(var rectangle in rectangles)
{
if(rectangle.Contains(point))
{
//do something
}
}
In Javascript I Tried this
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.rect(20,20,150,100);
if (ctx.isPointInPath(20,50))
{
//do something
};
But there are more rectangles in the context then in my list rectangles. Can somebody help me out?