📄 fdeeul2.prg
字号:
Execute(GetConfig(1));
autogr2config(x___):={if(AskUserYesNo("There is an error in your 2D graphics view configuration:"+chr(13)+x___+chr(13)+"Do you want to configure the 2D graphics view automatically?")==0,{abort(x___);},
{
axe1:=chr(34)+GetUserInput("Enter the expression displayed on the first axis:")+chr(34);
axe2:=chr(34)+GetUserInput("Enter the expression displayed on the second axis:")+chr(34);
min1:=GetUserInput("Enter the minimum value displayed on the first axis:");
max1:=GetUserInput("Enter the maximum value displayed on the first axis:");
min2:=GetUserInput("Enter the minimum value displayed on the second axis:");
max2:=GetUserInput("Enter the maximum value displayed on the second axis:");
draw:=0;
if(AskUserYesNo("Do you want to display the axes:"),
{draw:=draw||1;},{});
if(AskUserYesNo("Do you want to display the solution:"),
{draw:=draw||2;},{});
if(AskUserYesNo("Do you want to keep the aspect ratio:"),
{draw:=draw||4;},{});
SetConfig(computeall:="axe1:="+axe1+";"+chr(13)+chr(10)+
"axe2:="+axe2+";"+chr(13)+chr(10)+
"min1:="+min1+";"+chr(13)+chr(10)+
"max1:="+max1+";"+chr(13)+chr(10)+
"min2:="+min2+";"+chr(13)+chr(10)+
"max2:="+max2+";"+chr(13)+chr(10)+
"draw:="+numtos(draw)+";"+chr(13)+chr(10));
Abort("The setup is complete."+chr(13)+"Use File/Execute to start again."+chr(13)+chr(13)+computeall);
});
};
if(valid(draw)!=-1,{draw:=7;},{});
if(valid(axe1)!=-4,{autogr2config("You must define the variable axe1 as the text containing the expression to be displayed on the first axis.");},{});
if(valid(axe2)!=-4,{autogr2config("You must define the variable axe2 as the text containing the expression to be displayed on the second axis.");},{});
if((valid(min1)!=-1)&&(valid(min1)!=-2),{autogr2config("You must define the variable min1 as the minimal value to be displayed on the first axis.");},{});
if((valid(max1)!=-1)&&(valid(max1)!=-2),{autogr2config("You must define the variable max1 as the maximal value to be displayed on the first axis.");},{});
if((valid(min2)!=-1)&&(valid(min2)!=-2),{autogr2config("You must define the variable min2 as the minimal value to be displayed on the second axis.");},{});
if((valid(max2)!=-1)&&(valid(max2)!=-2),{autogr2config("You must define the variable max2 as the maximal value to be displayed on the second axis.");},{});
ChangeFont("Courier New",g_fs:=20,0);
g_ext:=7200.0/g_fs;
g_sx:=(max1-min1)/g_ext;
g_sy:=(max2-min2)/g_ext;
if(draw&&4,{g_s:=max(g_sx,g_sy);
WindowExt(min1,min2+g_s*g_ext,min1+g_s*g_ext,min2);},
{WindowExt(min1,max2,max1,min2);});
if(draw&&1,g_drawaxes,{});
if(draw&&8,g_drawdir:={
g_found:=0;
g_i1:=-1;
while({g_i1:=g_i1+1;valid(unknown[g_i1])==-4},
{if(unknown[g_i1]==strmid(axe1,0,strlen(unknown[g_i1])),{g_u:=g_i1;g_found:=1;g_dx1:=execute("{"+unknown[g_i1]+"'(t)}");},{});});
g_j1:=-1;g_i1:=g_u;
while({g_j1:=g_j1+1;valid(unknown[g_j1])==-4},
{if(unknown[g_j1]==strmid(axe2,0,strlen(unknown[g_j1])),{g_u:=g_j1;g_found:=g_found||2;g_dx2:=execute("{"+unknown[g_j1]+"'(t)}");},{});});
g_j1:=g_u;
if(g_found==3,{
UPDFrequency(16);
g_sav1:=execute(unknown[g_i1]);g_sav2:=execute(unknown[g_j1]);
if(valid(grid)!=-1,{grid:=20;},{});
if(valid(gridx)!=-1,{gridx:=grid;},{});
if(valid(gridy)!=-1,{gridy:=grid;},{});
g_sa:=(max1-min1)/(gridx+1.0);
g_u:=LONG(min1/g_sa)*g_sa;
g_sb:=(max2-min2)/(gridy+1.0);
t:=t0;
while({g_u<max1},{
execute(unknown[g_i1]+":=g_u;");
g_v:=LONG(min2/g_sb)*g_sb;
while({g_v<max2},{
execute(unknown[g_j1]+":=g_v;");
moveto(g_u,g_v);
g_i:=execute(g_dx1);g_j:=execute(g_dx2);
g_s:=pow(g_i*g_i+g_j*g_j,0.5)*5;
if(g_s>0.0001,{
FgrColor(0,0,255);
rlineto(2*g_sa*g_i/g_s,2*g_sb*g_j/g_s);
FgrColor(255,0,0);
rlineto(g_sa*g_i/g_s,g_sb*g_j/g_s);
},{});
g_v:=g_v+g_sb;
});
g_u:=g_u+g_sa;
});
FgrColor(0,0,0);
execute(unknown[g_i1]+":=g_sav1;"+unknown[g_j1]+":=g_sav2;");
UPDFrequency(6);
DisplayView(0);
},{});
},{});
tozero:=execute("{MoveTo("+axe1+","+axe2+");}");
if(draw&&2,{
execute(tozero);
OnUpdate(execute("{LineTo("+axe1+","+axe2+");}"));
},{});
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -