Помогите исправить, почему не работает? Не отображаются графики.
Код:
Form1: TForm1;
Rect:TRect;
left,right: integer;
Num: extended;
s: string;
XScale,YScale: single;
col: TColor;
implementation
{$R *.dfm}
procedure Tform1.GraphPaint;
var xc,yc,w,a,h,i:integer;
x1,y2: real;
mx,my,x,y1,t:real;
begin
clearing;
Img1.Canvas.Pen.Width:= 1;
xc:=Img1.Width div 2;
yc:= Img1.Height div 2;
w:=xc*2;
h:=yc*2;
mx:=(w-50)/se1.value;
my:=(h-40)/se1.value;
with Img1.Canvas do
begin
Brush.Color:=clWhite;
Pen.Color:=clblack;
Pen.Width:=2;
MoveTo(0,yc); //оси
LineTo(w,yc);
MoveTo(xc,0);
LineTo(xc,h);
textout(w-20,yc-20,'X');
textout(xc+20,20,'Y');
textout(xc+10,yc+10,'0');
for i:=1 to se1.value do begin
Pen.Style:=psDot;
Pen.Width:=1; //сетка
MoveTo(xc+round(i*mx),yc-h);LineTo(xc+round(i*mx),yc+h);
MoveTo(xc-round(i*mx),yc-h); LineTo(xc-round(i*mx),yc+h);
MoveTo(xc+h,yc-round(i*my)); LineTo(xc-h,yc-round(i*my));
MoveTo(xc+h,yc+round(i*my)); LineTo(xc-h,yc+round(i*my));
Pen.Style:=psSolid;
if se1.value<=10 then begin
MoveTo(xc+round(i*mx),yc-3); LineTo(xc+round(i*mx),yc+3); //разметка
MoveTo(xc-round(i*mx),yc-3); LineTo(xc-round(i*mx),yc+3);
textout(xc+round(i*mx),yc+10,Inttostr(i));
textout(xc-round(i*mx),yc+10,Inttostr(-i));
MoveTo(xc+3,yc-round(i*my)); LineTo(xc-3,yc-round(i*my)); //разметка
MoveTo(xc+3,yc+round(i*my)); LineTo(xc-3,yc+round(i*my));
textout(xc-30,yc-round(i*my),Inttostr(i));
textout(xc-30,yc+round(i*my),Inttostr(-1*i));
end;
if (se1.value>=11) and (se1.value<=20) then begin
MoveTo(xc+round(i*mx),yc-3); LineTo(xc+round(i*mx),yc+3); //разметка
MoveTo(xc-round(i*mx),yc-3); LineTo(xc-round(i*mx),yc+3);
textout(xc+round(i*mx),yc+10,Inttostr(i*2));
textout(xc-round(i*mx),yc+10,Inttostr(-i*2));
MoveTo(xc+3,yc-round(i*my)); LineTo(xc-3,yc-round(i*my)); //разметка
MoveTo(xc+3,yc+round(i*my)); LineTo(xc-3,yc+round(i*my));
textout(xc-30,yc-round(i*my),Inttostr(i*2));
textout(xc-30,yc+round(i*my),Inttostr(-1*i*2));
end;
if se1.value>=21 then begin
MoveTo(xc+round(i*mx),yc-3); LineTo(xc+round(i*mx),yc+3); //разметка
MoveTo(xc-round(i*mx),yc-3); LineTo(xc-round(i*mx),yc+3);
textout(xc+round(i*mx),yc+10,Inttostr(i*5));
textout(xc-round(i*mx),yc+10,Inttostr(-i*5));
MoveTo(xc+3,yc-round(i*my)); LineTo(xc-3,yc-round(i*my)); //разметка
MoveTo(xc+3,yc+round(i*my)); LineTo(xc-3,yc+round(i*my));
textout(xc-30,yc-round(i*my),Inttostr(i*5));
textout(xc-30,yc+round(i*my),Inttostr(-1*i*5));
end; end;
x:=se1.value*5;
a:=se2.value;
while x<=se1.value*5 do
begin
if se1.value<=10 then begin //график
y1:=ln(x);
pixels[xc+round(x*mx),yc-round(y1*my)]:=clred;
x1:=a*cos(x)+a*x*sin(x);
y2:=a*sin(x)-a*x*cos(x);
pixels[xc+round(x1*mx),yc-round(y2*my)]:=clgreen;
x:=x+0.004;
end;
if (se1.value>=11) and (se1.value<=20) then begin //график
y1:=ln(x);
pixels[xc+round(0.5*x*mx),yc-round(y1*my)]:=clred;
x1:=a*cos(x)+a*x*sin(x);
y2:=a*sin(x)-a*x*cos(x);
pixels[xc+round(0.5*x1*mx),yc-round(y2*my)]:=clgreen;
x:=x+0.004;
end;
if se1.value>=21 then begin //график
y1:=ln(x);
pixels[xc+round(0.2*x*mx),yc-round(y1*my)]:=clred;
x1:=a*cos(x)+a*x*sin(x);
y2:=a*sin(x)-a*x*cos(x);
pixels[xc+round(0.2*x1*mx),yc-round(y2*my)]:=clgreen;
x:=x+0.004;
end;
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
GraphPaint;
end;
procedure TForm1.clearing;
begin
Rect.Left:=0;
Rect.Top:=0;
Rect.Right:=Img1.Width;
Rect.Bottom:=Img1.Height;
Img1.Canvas.Brush.Color:=clWhite;
Img1.Canvas.FillRect(Rect);
end;
procedure TForm1.se1Change(Sender: TObject);
begin
GraphPaint;
end;
procedure TForm1.FormMouseWheelUp(Sender: TObject; Shift: TShiftState;
MousePos: TPoint; var Handled: Boolean);
begin
se1.Value:=se1.Value-1;
end;
procedure TForm1.FormMouseWheelDown(Sender: TObject; Shift: TShiftState;
MousePos: TPoint; var Handled: Boolean);
begin
se1.Value:=se1.Value+1;
end;
procedure TForm1.btn1Click(Sender: TObject);
begin
se1.Value:=se1.Value-1;
end;
procedure TForm1.btn2Click(Sender: TObject);
begin
se1.Value:=se1.Value+1;
end;