Читайте также: |
|
{$R *.dfm}
Procedure FonDraw;
Begin
Form1.Image1.Canvas.FillRect(Rect(0,0,Form1.Image1.Width,Form1.Image1.Height));
End;
Procedure DrawAxes;
Begin
k:=Form1.TrackBar1.Position;
Form1.Image1.Canvas.Pen.Color:=colAx;
Form1.Image1.Canvas.MoveTo(0,Trunc(Form1.Image1.Height/2));
Form1.Image1.Canvas.LineTo(Form1.Image1.Width,Trunc(Form1.Image1.Height/2));
Form1.Image1.Canvas.MoveTo(Trunc(Form1.Image1.Width/2),0);
Form1.Image1.Canvas.LineTo(Trunc(Form1.Image1.Width/2),Form1.Image1.Height);
Form1.Image1.Canvas.Pen.Color:=clSilver;
x:=Trunc(Form1.Image1.Width/2);
while x<Form1.Image1.Width do
Begin
x:=x+k;
Form1.Image1.Canvas.MoveTo(x,0);
Form1.Image1.Canvas.LineTo(x,Form1.Image1.Height);
End;
x:=Trunc(Form1.Image1.Width/2);
while x>0 do
Begin
x:=x-k;
Form1.Image1.Canvas.MoveTo(x,0);
Form1.Image1.Canvas.LineTo(x,Form1.Image1.Height);
End;
y:=Trunc(Form1.Image1.Height/2);
while y<Form1.Image1.Height do
Begin
y:=y+k;
Form1.Image1.Canvas.MoveTo(0,y);
Form1.Image1.Canvas.LineTo(Form1.Image1.Width,y);
End;
y:=Trunc(Form1.Image1.Height/2);
while y>0 do
Begin
y:=y-k;
Form1.Image1.Canvas.MoveTo(0,y);
Form1.Image1.Canvas.LineTo(Form1.Image1.Width,y);
End;
End;
Function fy1(fx:integer):real;
Begin
fy1:=(sqr(fx)-1)/(sqr(sqr(fx))+1)
End;
Function fy2(fx:integer):real;
Begin
fy2:=-sqr(sqr(fx))*fx+2*sqr(fx)*fx-1;
End;
Function fy1D(fxD:real):real;
Begin
fy1D:=(sqr(fxD)-1)/(sqr(sqr(fxD))+1)
End;
Function fy2D(fxD:real):real;
Begin
fy2D:=-sqr(sqr(fxD))*fxD+2*sqr(fxD)*fxD-1;
End;
Procedure Grafic(pg:integer);
Begin
if pg=1 then
Begin
FonDraw;
DrawAxes
End
else if pg=2 then
Begin
Form1.Image1.Canvas.Pen.Color:=colGr1;
rx:=0;
ry:=Trunc(fy1(rx));
x:=Trunc(Form1.Image1.Width/2)+k*rx;
y:=Trunc(Form1.Image1.Height/2)-k*ry;
Form1.Image1.Canvas.MoveTo(x,y);
while x<Form1.Image1.Width do
Begin
rx:=rx+1;
ry:=Trunc(fy1(rx));
x:=Trunc(Form1.Image1.Width/2)+k*rx;
y:=Trunc(Form1.Image1.Height/2)-k*ry;
Form1.Image1.Canvas.LineTo(x,y);
End;
rx:=0;
ry:=Trunc(fy1(rx));
x:=Trunc(Form1.Image1.Width/2)+k*rx;
y:=Trunc(Form1.Image1.Height/2)-k*ry;
Form1.Image1.Canvas.MoveTo(x,y);
while x>0 do
Begin
rx:=rx-1;
ry:=Trunc(fy1(rx));
x:=Trunc(Form1.Image1.Width/2)+k*rx;
y:=Trunc(Form1.Image1.Height/2)-k*ry;
Form1.Image1.Canvas.LineTo(x,y);
End
End
else if pg=3 then
Begin
Form1.Image1.Canvas.Pen.Color:=colGr2;
rx:=0;
ry:=Trunc(fy2(rx));
x:=Trunc(Form1.Image1.Width/2)+k*rx;
y:=Trunc(Form1.Image1.Height/2)-k*ry;
Form1.Image1.Canvas.MoveTo(x,y);
while x<Form1.Image1.Width do
Begin
rx:=rx+1;
ry:=Trunc(fy2(rx));
x:=Trunc(Form1.Image1.Width/2)+k*rx;
y:=Trunc(Form1.Image1.Height/2)-k*ry;
Form1.Image1.Canvas.LineTo(x,y);
End;
rx:=0;
ry:=Trunc(fy2(rx));
x:=Trunc(Form1.Image1.Width/2)+k*rx;
y:=Trunc(Form1.Image1.Height/2)-k*ry;
Form1.Image1.Canvas.MoveTo(x,y);
while x>0 do
Begin
rx:=rx-1;
ry:=Trunc(fy2(rx));
x:=Trunc(Form1.Image1.Width/2)+k*rx;
y:=Trunc(Form1.Image1.Height/2)-k*ry;
Form1.Image1.Canvas.LineTo(x,y);
End
End
End;
Procedure func;
Begin
if Form1.RadioButton1.Checked then f:=1
else if Form1.RadioButton2.Checked then f:=2
else if Form1.RadioButton3.Checked then f:=3
else if Form1.RadioButton4.Checked then f:=4;
Case f of
Grafic(1);
Grafic(2);
Grafic(3);
Begin
Grafic(2);
Grafic(3)
End
End;
End;
Procedure GraficD(pgD:integer);
Var dx,dy,krok:real;
Begin
if pgD=2 then
Begin
Form1.Image1.Canvas.Pen.Color:=colGr1;
krok:=1/(10*kd);
dx:=0;
x:=Trunc(Form1.Image1.Width/2);
dy:=fy1D(dx);
y:=Trunc(Form1.Image1.Height/2-dy*(kd*10));
Form1.Image1.Canvas.MoveTo(x,y);
while x<Form1.Image1.Width do
Begin
dx:=dx+krok;
x:=x+1;
dy:=fy1D(dx);
y:=Trunc(Form1.Image1.Height/2-dy*(kd*10));
Form1.Image1.Canvas.LineTo(x,y);
End;
dx:=0;
x:=Trunc(Form1.Image1.Width/2);
dy:=fy1D(dx);
y:=Trunc(Form1.Image1.Height/2-dy*(kd*10));
Form1.Image1.Canvas.MoveTo(x,y);
while x>0 do
Begin
dx:=dx-krok;
x:=x-1;
dy:=fy1D(dx);
y:=Trunc(Form1.Image1.Height/2-dy*(kd*10));
Дата добавления: 2015-10-30; просмотров: 92 | Нарушение авторских прав
<== предыдущая страница | | | следующая страница ==> |
Namespace openGL_1 | | | Form1.Image1.Canvas.LineTo(x,y); |