Delphining grafik imkoniyatlari


-rasm. Xarakatlanuvchi aylana


Download 0.58 Mb.
bet18/29
Sana09.03.2023
Hajmi0.58 Mb.
#1254496
1   ...   14   15   16   17   18   19   20   21   ...   29
Bog'liq
delphi uzb графика

10.15-rasm. Xarakatlanuvchi aylana dasturining forma oynasi
10.8-rasm. Xarakatlanuvchi aylana
unit mcircle_;
interface
uses
Windows, Messages, SysUtils, Classes,
Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm) Timer1: TTimer;
procedure Timer1Timer(Sender: TObject};
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
implementation
{$R *.DFM}
var
Form1: TForml;
x,y: byte; // aylana markazining koordinatasi
dx: byte; // aylanani x o’q bo’yicha xarakatlanishidagi o’zgarish qadami
// aylanani o’chirib yangi joyda chizish
procedure Ris;
begin
// aylanani o’chirish
form1.Canvas.Pen.Color:=form1.Color;
form1.Canvas.Ellipse(x,y,x+10,y+10);
x:=x+dx;
// aylanani yangi joyda chizish
form1.Canvas.Pen.Color:=clBlack;
form1.Canvas.Ellipse(x,y, x+10, y+10) ;
end;
// taymerdan signal olish
procedure TForm1.Timer1Timer(Sender: TObject);
begin Ris; end;
procedure TForm1.FormActivate(Sender: TObject);
begin
x:=0;
y:=10;
dx:=5;
timer1.Interval:=50;
// OnTimer hodisasini takrorlanish vaqti —0.5 sekund
form1.canvas.brush.color:=forml.color;
end;
end.
Asosiy ishni Ris protsedurasi bajaryapti. Bu protsedura aylanani o’chiradi va yangi joyda hosil qiladi. Aylanani o’chirish avval chizilgan aylana ustidan fon rangida qayta chizish bilan amakga oshiriladi.
Ris protsedurasini vaqti-vaqti bilan chaqirishni ta’minlash uchun dastur formasiga vizual bo’lagan Timer komponenti o’rnatilgan. Bu komponent belgisi komponentlar palitrasining System bo’limida joylashgan (10.16-rasm). Timer komponentining xususiyatlari 10.9-jadvalda sanab o’tilgan.


Download 0.58 Mb.

Do'stlaringiz bilan baham:
1   ...   14   15   16   17   18   19   20   21   ...   29




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling