请问是否可以再html用语句点到点画线?

xiwanghope 2003-06-23 04:52:14
请问可以实现吗?

如果可以最好能给个函数!谢谢
...全文
65 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiwanghope 2003-06-23
  • 打赏
  • 举报
回复
so cool~~

结账,thanks
emu 2003-06-23
  • 打赏
  • 举报
回复
<BODY>
<div id=div1></div>

<SCRIPT LANGUAGE="JavaScript">
<!--
div1.innerHTML = drawLine(100,100,500,300,"red");


document.writeln("<style>");
document.writeln(".emuW{position:absolute;font-size:1px;width:1}");
document.writeln(".emuH{position:absolute;font-size:1px;height:1}");
document.writeln(".emuWH{position:absolute;font-size:1px;width:1;height:1}");
document.writeln("A{text-decoration:none;color:#FF66FF}");
document.writeln("</style>");
function drawLine(x0,y0,x1,y1,color){
x0 = Math.round(x0);
x1 = Math.round(x1);
y0 = Math.round(y0);
y1 = Math.round(y1);
var rs = "";
if (y0 == y1){ //»­ºáÏß
if (x0>x1){var t=x0;x0=x1;x1=t}
rs = "<img border=0 class=emuH style='top:"+y0+";left:"+x0+";background-color:"+color+"; width:"+Math.abs(x1-x0)+"'/>";
}
else if (x0 == x1){ //»­ÊúÏß
if (y0>y1){var t=y0;y0=y1;y1=t}
rs = "<img border=0 class=emuW style='top:"+y0+";left:"+x0+";background-color:"+color+";height:"+Math.abs(y1-y0)+"'/>";
}
else{
var lx = x1-x0;
var ly = y1-y0;
if (Math.abs(lx)>Math.abs(ly)){
if (ly<0){
var t=x0;x0=x1;x1=t;
t=y0;y0=y1;y1=t;
lx = -lx;
ly = -ly;
}
var dx = lx/ly;
rs = new Array(ly);
for (var i=0;i<ly;i++){
var left,width;
if (dx>0){
left = Math.round(i*dx);
width = Math.round((i+1)*dx)-left;
left += x0;
if (width+left>x1) width = x1-left;
}else{
left = Math.round((i+1)*dx);
width = Math.round((i)*dx)-left;
left += x0;
if (left<x1) {
width = width+left-x1;
left=x1;
}
}
rs[i] = "<img border=0 class=emuH style='top:"+(y0+i)+";left:"+left+";width:"+width+";background-color:"+color+"'/>";
}
}else{
if (lx<0){
var t=x0;x0=x1;x1=t;
t=y0;y0=y1;y1=t;
lx = -lx;
ly = -ly;
}
var dy = ly/lx;
rs = new Array(lx);
for (var i=0;i<lx;i++){
var top,height;
if (dy>0){
top = Math.round(i*dy);
height = Math.round((i+1)*dy)-top;
top += y0;
if (height+top>y1) height = y1-top;
}else{
top = Math.round((i+1)*dy);
height = Math.round((i)*dy)-top;
top += y0;
if (top<y1) {
height = height+top-y1;
top=y1;
}
}
rs[i] = "<img border=0 class=emuW style='top:"+top+";left:"+(x0+i)+";height:"+height+";background-color:"+color+"'/>";
}
}
rs = rs.join("");
}
return rs
}

//-->
</SCRIPT>
</BODY>

呵呵,晕了没?

div1.innerHTML = drawLine(100,100,500,300,"red");这一句可以改坐标和颜色。
xiwanghope 2003-06-23
  • 打赏
  • 举报
回复
那请问有程序吗?

希望能给我一个!

neowing@163.com
zgczsf 2003-06-23
  • 打赏
  • 举报
回复
好像得用Script来实现
zgczsf 2003-06-23
  • 打赏
  • 举报
回复
好像得用Script来实现

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧