function creatediv(id, ax,ay, bx,by, size, opacity, color) {
var length = Math.hypot(by-ay, bx-ax),
deg = Math.atan2(by-ay, bx-ax) * 180 / Math.PI,
newdiv = document.createElement('div'),
css = {
width: length + "px",
height: (size||2) + "px",
left: ax + "px",
top: ay + "px",
background: color || "red",
opacity: opacity || 1,
transformOrigin: "left 50%",
transform: "rotate("+ deg +"deg)",
position: "absolute"
};
for(var s in css) newdiv.style[s] = css[s];
document.body.appendChild(newdiv);
}
creatediv("a", 0,30, 10,10);
creatediv("b", 10,10, 60,80, 5, 0.3, "#0bf");
creatediv("c", 60,80, 70,50);
creatediv("d", 70,50, 150,90, null, null, "gold");