unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 =
class(TForm)
edtEingabe: TEdit;
lblFX: TLabel;
lbl_X: TLabel;
btn_Zeichne: TButton;
Image1: TImage;
edt_Bx: TEdit;
lbl_bx: TLabel;
edt_C: TEdit;
lbl_C: TLabel;
Label2: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
edtFx: TEdit;
edt_X: TEdit;
edt_B: TEdit;
edt_Cx: TEdit;
btn_Zeichne1: TButton;
btn_neu: TButton;
btn_close: TButton;
Label1: TLabel;
Label3: TLabel;
procedure FormCreate(Sender: TObject);
procedure btn_ZeichneClick(Sender: TObject);
procedure btn_Zeichne1Click(Sender: TObject);
procedure btn_closeClick(Sender: TObject);
procedure btn_neuClick(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
a,b,c: Real;
implementation
{$R *.dfm}
procedure TForm1.btn_closeClick(Sender: TObject);
begin
Form1.Close;
end;
procedure TForm1.btn_ZeichneClick(Sender: TObject);
var
i,j:Integer;
x,y: Real;
begin
a:= StrToFloat(edtEingabe.Text);
b:= StrToFloat(edt_Bx.Text);
c:= StrToFloat(edt_C.Text);
i:=20;
while i<660
do
begin
i:=i+1;
x:=(i-450)/50;
//50, da Koordinatensystem in 50er Schritten erstellt ist
y:=a*sqr(x)+b*x+c;
j:=round((450-y*50));
//450 Grenze von X-Achse
Image1.Canvas.Pixels[i,j]:=clblue;
//zeichnen
end;
end;
procedure TForm1.btn_neuClick(Sender: TObject);
begin
Image1.Canvas.Rectangle(0,0,width,height);
FormCreate(Sender);
begin
edtEingabe.Text:='
';
edt_Bx.Text:='
';
edt_C.Text:='
';
edtFx.Text:='
';
edt_X.Text:='
';
edt_B.Text:='
';
edt_Cx.Text:='
';
end;
end;
procedure TForm1.btn_Zeichne1Click(Sender: TObject);
var
i,j:Integer;
x,y: Real;
begin
a:= StrToFloat(edt_X.Text);
b:= StrToFloat(edt_B.Text);
c:= StrToFloat(edt_Cx.Text);
i:=20;
while i<660
do
begin
i:=i+1;
x:=(i-450)/50;
//50, da Koordinatensystem in 50er Schritten erstellt ist
y:=a*sqr(x+b)+c;
j:=round((450-y*50));
//450 Grenze von X-Achse
Image1.Canvas.Pixels[i,j]:=clred;
//zeichnen
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
i,j,k:Integer;
begin
with Image1.Canvas
do
begin //X-Achse
MoveTo(1125,450);
//Graph
LineTo(20,450);
for i:= -8
to 13
do
begin
Image1.Canvas.TextOut(450+50*i,455,IntToStr(i));
//Beschriftung
MoveTo(450+50*i,445);
//Striche von Beschriftung
LineTo(450+50*i,455);
begin //Y-Achse
MoveTo(450,20);
//Graph
LineTo(450,660);
for j := -8
to -1
do
begin
Image1.Canvas.TextOut(455,450+50*j,IntToStr(-j));
//Beschriftung
MoveTo(445,450+50*j);
//Striche von Beschriftung
LineTo(455,450+50*j);
for k := 1
to 4
do
begin
Image1.Canvas.TextOut(455,450+50*k,IntToStr(-k));
//Beschriftung
MoveTo(445,450+50*k);
//Striche von Beschriftung
LineTo(455,450+50*k);
end;
end;
end;
end;
end;
end;
end.