87,909
社区成员
发帖
与我相关
我的任务
分享
//定义点的绝对坐标
function drawDot(x,y)
{
var dot = "<table border='0' cellspacing=0 cellpadding=0><tr><td style='position: absolute; left: "+(x)+"; top: "+(y)+";background-color:#ff66ff' width=2 height=2></td></tr></table>";
return dot;
}
//两点连线
function drawLine(x1,y1,x2,y2)
{
var index;
var line_length = Math.floor(Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
var theta = Math.atan((x2-x1)/(y2-y1));
var line = "<table border='0' cellspacing=0 cellpadding=0>";
if(((y2-y1)<0 && (x2-x1)>0) || ((y2-y1)<0 && (x2-x1)<0))
{
theta = Math.PI + theta;
}
var dx = Math.sin(theta);
var dy = Math.cos(theta);
for(index = 0;index < line_length;index++){
line += drawDot(x1 + index*dx,y1 + index*dy);
}
line += '<img id="picture" src="image/1.jpg">';
line += "<tr><td style='position: absolute; left: "+(x2)+"; top: "+(y2)+";background-color:#ff66ff'>";
line +="</td></tr></table>";
return line;
}
//定义点的绝对坐标
function drawDot(x,y)
{
var dot = "<table border='0' cellspacing=0 cellpadding=0><tr><td style='position: absolute; left: "+(x)+"; top: "+(y)+";background-color:#ff66ff' width=2 height=2></td></tr></table>";
return dot;
}
//两点连线
function drawLine(x1,y1,x2,y2)
{
var index;
var line_length = Math.floor(Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
var theta = Math.atan((x2-x1)/(y2-y1));
var line = "<table border='0' cellspacing=0 cellpadding=0>";
if(((y2-y1)<0 && (x2-x1)>0) || ((y2-y1)<0 && (x2-x1)<0))
{
theta = Math.PI + theta;
}
var dx = Math.sin(theta);
var dy = Math.cos(theta);
for(index = 0;index < line_length;index++){
line += drawDot(x1 + index*dx,y1 + index*dy);
}
line += '<img id="picture" style="position:absolute;left:' + index*dx + ';top:' + y1 + index*dy + '" src="image/1.jpg">';
line += "<tr><td style='position: absolute; left: "+(x2)+"; top: "+(y2)+";background-color:#ff66ff'>";
line +="</td></tr></table>";
return line;
}