|
Delphi dasturlash tilida geometrik chizmalar
|
bet | 1/3 | Sana | 17.02.2024 | Hajmi | 87,03 Kb. | | #158299 |
Bog'liq DELPHI DASTURLASH TILIDA GEOMETRIK CHIZMALAR
Tutashgan chiziq chizish. O‘zaro tutashgan kesmalardan iborat shaklni chizish uchun polyline usulidan foydalaniladi. Bu usul parametri TPoint tipli massivdan iborat. Tutash chiziqni forma oynasiga chiqarish uchun “Button1” tugmachasidan foydalanamiz.
“Button1” dasturlash maydonchasiga quyidagi dasturni kiritamiz:
var
gr: array[1..50] of TPoint;
x0,y0: integer;
dx,dy: integer;
i: integer; begin
x0 := 100; y0 := 200;
dx :=5; dy := 5;
for i:=1 to 50 do begin
gr[i].x := x0 + (i-1)*dx;
gr[i].y := y0 + (i-1)*dy;
end;
with form1.Canvas do begin
MoveTo(x0,y0); LineTo(x0,10);
MoveTo(x0,y0); LineTo(200,y0);
Polyline(gr);
end;
end;
Dastur kodi va oynaning umumiy ko‘rinishini keltiramiz:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
gr: array[1..50] of TPoint;
|
| |