I have a canvas which display a picture that The user has uploaded.What I want to do is to ask the client to give me the width and height between two points that he/she has selected on canvas in cm .For example,The client click on top left on canvas and then select top right .after that he/she should enter the width between those two selected points. How should I do that?
Sorry for my bad English.
Thanks
Just get the coordinates of your two points.
Let us assume the first point is called A
and the second point is called B
. So their coordinates would be:
A = (xa, ya)
B = (xb, xb)
So the horizontal distance between A
and B
would be, |xa-xb|
1 . And the vertical distance between them would be |ya-yb|
1 .
If we draw a rectangle using A
and B
as diagonally opposite points of it, that rectangle's width would be |xa-xb|
, and it's height would be |ya-yb|
.
||
represents "Absolute Value". See http://en.wikipedia.org/wiki/Absolute_value .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.