469,929 Members | 1,399 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,929 developers. It's quick & easy.

getting image coordinates

hello i am new to PHP i have a linegraph created using GD function in PHP. Now what i need is when i roll the mouse over the graph i want to draw a straight line and want to display the image coordinates of plots in my graph which intersects this straight line i got stuck up in my project because of this issue please help me thanks in advance

rekhamanoj
May 19 '08 #1
3 2037
TheServant
1,168 Expert 1GB
I am pretty sure you will need to use AJAX or javascript for that. I haven't used the GD a lot, but I think once you have requested the page the image is set, so you can't draw lines. Definately for displaying live coordinates you should use AJAX or javascript. Wait for others to confirm this before you give up though. Do you have any AJAX or javascript experience?
May 19 '08 #2
Atli
5,058 Expert 4TB
PHP will only work server-side, so no client-side actions will ever trigger any PHP code. Unless that action is to send a fresh HTTP request, obviously.

That can be achieved by using AJAX, but it won't be easy.
You may be better of looking into Javascript solutions to this.
May 19 '08 #3
hsriat
1,654 Expert 1GB
hello i am new to PHP i have a linegraph created using GD function in PHP. Now what i need is when i roll the mouse over the graph i want to draw a straight line and want to display the image coordinates of plots in my graph which intersects this straight line i got stuck up in my project because of this issue please help me thanks in advance

rekhamanoj
Its a rather tough job than what you would have expected.
I can though suggest you an algorithm.
  • Keep the img inside a div with no other element along with it. just img in that div and give style="position:absolute;top:100px;left:100px;padd ing:0px;border-width:0px;" to the div.
  • onmousedown of this div, turn a flag var imageClicked = true;
  • onmousemove of the body, if imageClicked==true keep getting the mouse coordinates (you may get many functions for that on google) and keep creating div elements and append them to the body, with style="position:absolute;width:1px;height:1px;back ground-color:black;" and with JavaScript, make its left and top equal to the x and y coordinates of cursor respectively. This will give a line drawing view. Also keep saving the coordinates in an array. You would need to send this array to PHP to change the actual image. To display the coordinates, display them in any span or div by innerHTML
  • onmouseup of the body, turn that imageClicked=false; and call an Ajax function to post array of coordinates to PHP
  • Subtract 100 (same as you had given left and top to the div containing image) from the coordinates posted by Ajax and draw them on the image by GD.

Not properly explained, but hope you can make out.

Regards
May 19 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Csaba Gabor | last post: by
15 posts views Thread by Tony Gahlinger | last post: by
1 post views Thread by Asaf Dan | last post: by
1 post views Thread by Janani via DotNetMonster.com | last post: by
4 posts views Thread by Tomasz Bak | last post: by
3 posts views Thread by jackiepatti | last post: by
2 posts views Thread by nvinhphu | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.