How can I find the area of the triangle on the html canvas?
So I have a rectangle drawn. When the user clicks anywhere on the canvas I want the area of the top two corner points of the square and the coordinates of the mouse click to be determined. I've googled the formula for the area of a triangle and checked it many times and am sure its right. It's just not working. I'll know I'll have it right when the area of the triangle is smaller numerically than that of the square, when the user clicks inside the square. The only problem is that it actually comes out much greater, and I'm not sure how to proceed from here. I think the issue might be how I'm finding the mouse coordinates in the first place, but I'm not sure what to do. If anyone has any insight into this, that would be very much appreciated. Code below: https://code.sololearn.com/WI39ZX9lXXxE/#