i need to draw lines between 2 element on html page
the results should be like this: http://img2.timg.co.il/forums/1_173873919.JPG
i wondered what the best way do this
- using canvas and html5
- using background image.
- make by ajax dynamic the image
i would like to know what the best way and if there is a simple demo on the web
thanks
Lots of ways to solve your need:
Here's one solution using an html canvas: http://jsfiddle.net/m1erickson/86f4C/
Example code (could be fully automated with jquery+css-classes):
There is a very simple way of achieving this with some Javascript and the HTML
canvas
tag.DEMO HERE showing how to draw the most complicated element on your example which has one field with lines branching to two other fields.
How it (basically) works is as follows.
Start the drawing function with:
Pass the desired coordinates to the function with:
Then execute the draw with:
There's some great tutorials HERE
use
<canvas>
if you want to use simple things like circles and images and stuff - for divs, you would want to look for alternatives like in Jquery or - like you said - javascript. For<canvas>
you could try this and thishere's a link to a gist that uses javascript (jquery) to draw a path (and redraw it in case of window resizing) between any 2 html elements.
demo