line.js

来自「ASPSQL企业网络管理系统」· JavaScript 代码 · 共 77 行

JS
77
字号
//基本图形元素
System.LoadUnit("Graphics");
function Point(x,y)
{
	this.X = x;
	this.Y = y;
}
function Rect(p,w,h)
{
	this.Base = p;
	this.Width = w;
	this.Height = h;
}
function Line(c,w,t)
{
	if((typeof(c)=="undefined") || (c == ""))
		this.Color = "#000000";
	else
		this.Color = c;
	if((typeof(w)=="undefined") || (w == ""))
		this.Width = 1;
	else
		this.Width = w;
	if((typeof(t)=="undefined") || (t == ""))
		this.Type = "solid";
	else
		this.Type = t;
	this.ExpX = "";
	this.ExpY = "";
	this.uMin = 0;
	this.uMax = 0;
	this.DrawLine = function(r,z)
	{
		if((typeof(z)=="undefined")/* || (z=="")*/)
			z = 1;
		var t,l,w,h;
		w = r.Width;
		h = r.Height;
		l = Math.min(r.Base.X,r.Base.X + w);
		t = Math.max(r.Base.Y,r.Base.Y + h);
		if(w<0)
			w = -w;
		else if(w == 0)
			w = 1;
		if(h<0)
			h = -h;
		else if(h == 0)
			h = 1;
		l = Physic2Screen(l,"x");
		t = Physic2Screen(t,"y");
		w = Physic2Screen(w,"len");
		h = Physic2Screen(h,"len");
		document.write("<img width=\""+w+"\" height=\""+h+"\" style=\"background-color:"+this.Color+";position:absolute;z-index:"+z+";top:"+t+"px;left:"+l+"px\">");
	}
	this.Draw = function()
	{
		var u,m,w,h,oldX,oldY;
		u = this.uMin;
		oldX = eval(this.ExpX);
		oldY = eval(this.ExpY);
		for(u=this.uMin;u<=this.uMax;u++)
		{
			this.X = eval(this.ExpX);
			this.Y = eval(this.ExpY);
			w = this.X - oldX;
			h = this.Y - oldY;
			m = Math.min(Math.abs(w),Math.abs(h));
			if(m >= this.Width)
			{
				this.DrawLine(new Rect(new Point(oldX,oldY),w,h));
				oldX = this.X;
				oldY = this.Y;
			}
		}
		this.DrawLine(new Rect(new Point(oldX,oldY),w,h));
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?