How to get coordinates of rectangle drawn on canvas on a JSP?

I want to get the coordinates of the four corners of a rectangle which is drawn by the user using canvas.

When the user click on the “submit coordinates” button , the variables x,y,h(height) and w(width) values should be passed to the Servlet to do some calculationsn so to get the coordinates.

Below are my my variables that stored inside the javascript:

var x = Math.min(ev._x,  tool.x0),
    y = Math.min(ev._y,  tool.y0),
    w = Math.abs(ev._x - tool.x0),
    h = Math.abs(ev._y - tool.y0); 

Now , I want to pass all the variables to my servlet where I want to do some calculations to get the coordinates of 4 corners:

top-left corner : (x , y)
top-right corner: (x+w , y)
bottom-left corner: (x , y+h)
bottom-right corner: (x+w , y+h)

What can I do in order to get all the coordinates values ? Thanks.


Source: jsp

Leave a Reply