I'd like to draw a line that connects two circles, but when the window is being re-sized, the distance between the two circles changes therefore the height of the line image should change accordingly. Here is what I have now but it only does it once when the page loads, but I want the image height to be dynamically changing as the window is being re-sized:
function getDistance(id1, id2){
distX = id1.offsetLeft - id2.offsetLeft;
distY = id1.offsetTop - id2.offsetTop;
distance = Math.sqrt(distX*distX + distY*distY);
return distance;
console.log(distance);
}
var myImage = new Image(50, 100);
myImage.src = 'images/line.png';
myImage.height = getDistance(circle1, circle2);
document.getElementById("line").appendChild(myImage);