参考:http://www.walterzorn.com/jsgraphics/jsgraphics_e.htm
=====================
<html>
<head>
    <title>利用 wz_jsgraphics.js 画线</title>
    <script src="wz_jsgraphics.js" type="text/javascript"></script>
<script language=javascript>

var IsDrawLine = "0";
//
var StartX = 0;
var StartY = 0;
var EndX = 0;
var EndY = 0;

var jgdiv1;

function fn_WantDrawLine()
{
    IsDrawLine = "1";
}

function fn_onmousedown()
{
    if(IsDrawLine=="1")
    {
        //起点
        StartX = event.x;
        StartY = event.y;
        document.all.Text1.value = StartX;
        document.all.Text2.value = StartY;
        //
        jgdiv1.drawLine(StartX,StartY,StartX,StartY);
        jgdiv1.paint();
    }
}

function fn_onmousemove()
{
    if(IsDrawLine=="1")
    {
        if(StartX!=0)
        {
            //终点
            EndX = event.x;
            EndY = event.y;
            document.all.Text3.value = EndX;
            document.all.Text4.value = EndY;
//            //
//            jgdiv1.drawLine(StartX,StartY,EndX,EndY);
//            jgdiv1.paint();
        }
    }
}

function fn_onmouseup()
{
    if(IsDrawLine=="1")
    {
        //画线
        jgdiv1.drawLine(StartX,StartY,EndX,EndY);
        jgdiv1.paint();
        //
        IsDrawLine = "0";
        document.all.Text1.value = "";
        document.all.Text2.value = "";
        document.all.Text3.value = "";
        document.all.Text4.value = "";
        StartX = 0;
        StartY = 0;
    }
}

document.onmousedown = fn_onmousedown;
document.onmousemove = fn_onmousemove;
document.onmouseup = fn_onmouseup;

</SCRIPT>

</head>
<body>
    <form );
            jgdiv1.setStroke(10);
        </script>
        </div>
    </form>
</body>
</html>

相关文章:

  • 2022-12-23
  • 2021-04-11
  • 2022-12-23
  • 2022-01-12
  • 2021-12-27
  • 2021-11-03
  • 2022-01-22
  • 2022-12-23
猜你喜欢
  • 2021-11-03
  • 2021-04-08
  • 2021-06-28
  • 2022-12-23
  • 2021-12-31
相关资源
相似解决方案