type TForm1 = class(TForm) Button1: TButton; Image1: TImage; Edit1: TEdit; Label1: TLabel; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject); var x,y,t:real; x1,y1,M:integer; //M -коэффициент масштабирования begin x1:=Image1.Width div 2; y1:=Image1.Height div 2; with Image1.Canvas do begin MoveTo(x1,0); LineTo(x1,Image1.Height); MoveTo(x1,0); LineTo(x1-5,10); MoveTo(x1,0);LineTo(x1+5,10); MoveTo(0,y1);LineTo(Image1.Width,y1); LineTo(Image1.Width-10,y1-5); MoveTo(Image1.Width,y1); LineTo(Image1.Width-10,y1+5); TextOut(x1+1,y1+1,'0'); TextOut(Image1.Width-16,y1+2,'X'); TextOut(x1-15,0,'Y'); x := -200; y := 1/x; M:=strtoint(edit1.text); moveto(x1+round(x)*M,(y1-round(y)*M)); repeat x:=x+0.1; if x<>0 then //точка разрыва begin y := 1/x; lineto(x1+round(x*M),(y1-round(y*M))); end else begin x:=x+0.1; y := 1/x; MoveTo(x1+round(x*M),(y1-round(y*M))); end; until x>=200; end; end;
procedure TForm1.FormCreate(Sender: TObject); begin Label1.Caption:='коэффициент масштабирования'; Button1.Caption:='Построить'; Edit1.Text:='15'; Button1.OnClick(sender);//Построение end;
Answers & Comments
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Image1: TImage;
Edit1: TEdit;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
x,y,t:real;
x1,y1,M:integer; //M -коэффициент масштабирования
begin
x1:=Image1.Width div 2;
y1:=Image1.Height div 2;
with Image1.Canvas do
begin
MoveTo(x1,0); LineTo(x1,Image1.Height);
MoveTo(x1,0); LineTo(x1-5,10);
MoveTo(x1,0);LineTo(x1+5,10);
MoveTo(0,y1);LineTo(Image1.Width,y1);
LineTo(Image1.Width-10,y1-5);
MoveTo(Image1.Width,y1); LineTo(Image1.Width-10,y1+5);
TextOut(x1+1,y1+1,'0');
TextOut(Image1.Width-16,y1+2,'X');
TextOut(x1-15,0,'Y');
x := -200;
y := 1/x;
M:=strtoint(edit1.text);
moveto(x1+round(x)*M,(y1-round(y)*M));
repeat
x:=x+0.1;
if x<>0 then //точка разрыва
begin
y := 1/x;
lineto(x1+round(x*M),(y1-round(y*M)));
end
else
begin
x:=x+0.1;
y := 1/x;
MoveTo(x1+round(x*M),(y1-round(y*M)));
end;
until x>=200;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Label1.Caption:='коэффициент масштабирования';
Button1.Caption:='Построить';
Edit1.Text:='15';
Button1.OnClick(sender);//Построение
end;
end.