📄 basicgraphic.js
字号:
// 基本曲线
System.LoadUnit("Line");
function Beeline(p1,p2,c,w)
{
if(p1.X <= p2.X)
{
this.Start = p1;
this.End = p2;
}
else
{
this.Start = p2;
this.End = p1;
}
this.Color = c;
this.Width = w;
this.Line = new Line(c,w);
this.Line.uMax = this.End.X-this.Start.X;
this.Line.ExpX = this.Start.X + "+u";
this.Line.ExpY = this.Start.Y + "+(" + (this.End.Y-this.Start.Y)/(this.End.X-this.Start.X) + ")*u";
this.Draw = function()
{
if((this.Start.X == this.End.X) || (this.Start.Y == this.End.Y))
this.Line.DrawLine(new Rect(this.Start,(this.End.X-this.Start.X),(this.End.Y-this.Start.Y)));
else
this.Line.Draw();
}
}
function Rectangle(x,y,w,h,c,lw)
{
this.X = x;
this.Y = y;
this.Width = w;
this.Height = h;
this.LineColor = c;
this.LineWidth = lw;
this.TopLeft = function(){return new Point(x,y+h)};
this.TopRight = function(){return new Point(x+w,y+h)};
this.BottomLeft = function(){return new Point(x,y)};
this.BottomRight = function(){return new Point(x+w,y)};
this.Draw = function()
{
(new Beeline(this.TopLeft(),this.TopRight(),this.LineColor)).Draw();
(new Beeline(this.TopRight(),this.BottomRight(),this.LineColor)).Draw();
(new Beeline(this.BottomRight(),this.BottomLeft(),this.LineColor)).Draw();
(new Beeline(this.BottomLeft(),this.TopLeft(),this.LineColor)).Draw();
}
}
function Polygon(arrP,close,clr)
{
if(typeof(close)=="undefined")
this.Close = true;
else
this.Close = close;
this.Points = arrP;
this.Color = clr;
this.Draw = function()
{
var i;
for(i=0;i<this.Points.length-1;i++)
{
(new Beeline(this.Points[i],this.Points[i+1],this.Color)).Draw();
}
if(this.Close)
(new Beeline(this.Points[i],this.Points[0],this.Color)).Draw();
}
}
function Circle(cen,r,c,w)
{
this.Center = cen;
this.Radius = r;
this.Color = c;
this.Width = w;
this.Line = new Line(c,w);
this.Line.uMax = 360;
this.Line.ExpX = this.Center.X + "+" + this.Radius + "*Math.cos(u*Math.PI/180)";
this.Line.ExpY = this.Center.Y + "+" + this.Radius + "*Math.sin(u*Math.PI/180)";
this.Draw = function()
{
this.Line.Draw();
}
}
function Arc(cen,r,ang,sAng,c,close,w)
{
this.Center = cen;
this.Radius = r;
this.Angle = ang;
this.Color = c;
this.Width = w;
this.Close = close;
if(typeof(sAng)=="undefined")
this.StartAngle = 0;
else
this.StartAngle = sAng;
this.Circle = new Circle(cen,r,c,w);
this.Draw = function()
{
this.Circle.Line.uMin = this.StartAngle
this.Circle.Line.uMax = this.StartAngle+this.Angle;
this.Circle.Draw();
if(this.Close == true)
(new Polygon([new Point(this.Center.X+this.Radius*Math.cos(this.StartAngle*Math.PI/180),this.Center.Y+this.Radius*Math.sin(this.StartAngle*Math.PI/180)),this.Center,new Point(this.Center.X+this.Radius*Math.cos((this.StartAngle+this.Angle)*Math.PI/180),this.Center.Y+this.Radius*Math.sin((this.StartAngle+this.Angle)*Math.PI/180))],false,this.Color)).Draw();
}
}
function Text(p,text,size,clr)
{
if((typeof(size)=="undefined") || (size==""))
size = 12;
if(typeof(clr)=="undefined")
clr = "#000000";
this.Point = p;
this.Text = text;
this.Color = clr;
this.Size = size;
this.Draw = function()
{
var l = Physic2Screen(this.Point.X,"x");
var t = Physic2Screen(this.Point.Y,"y");
document.write("<span style=\"position:absolute;left:"+l+";top:"+t+";font-size:"+this.Size+"px;color:"+this.Color+";\">"+this.Text+"</span>");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -