Delphining grafik imkoniyatlari


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

Bazaviy nuqtalar uslubi
Grafik elementlar to’plamidan iborat bo’lgan murakkab tasvirlarni dasturlashda bazaviy nuqtalar usulidan foydalaniladi. Usulning moxiyati quyidagicha:

  1. Tasvirning ma’lum bir nuqtalari bazaviy deb olinadi;

  2. Tasvirning boshqa nuqtalari bazaviy nuqtalarga nisbatan hisoblanadi;

  3. agar tasvirning nuqtalari bazaviy nuqtaga nisbatan birlik piksellarda berilmasa, u holda tasvirni mas’shtablash imkoni bo’ladi.

10.17-rasmda korabl tasviri keltirilgan. Bazaviy nuqta deb (X0, Y0) koordinata olingan. Qolgan nuqtalarning koordinatalari shu nuqtaga nisbatan olinadi.



10.17-rasm. Tasvir koordinatalarini bazaviy nuqtaga nisbatan aniqlanishi
10.9-listingda xarakatlanayotgan korablni hosil qilish dasturi keltirilgan.
10.9-listing. Korabl
unit ship_;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
x,y: integer; // korabl koordinatalari (bazaviy nuqta)
implementation
{$R *.DFM}
// korablni chizish
procedure Titanik(x,y: integer; // bazaviy nuqtalar koordinatasi
color: TColor); // korabl rangi
const dx = 5; dy = 5;
var
buf: TColor;
begin
with form1.canvas do begin
buf:=pen.Color; // joriy rangni saqlaymiz
pen.Color:=color;
// kerakli rangni o’rnatamiz
// chizamiz . . .
// korpus
MoveTo(x,y);
LineTo(x,y-2*dy) ;
LineTo (x+10*dx, y-2*dy) ;
LineTo (x+ll*dx, y-3*dy) ;
LineTo (x+17*dx,y-3*dy) ;
LineTo (x+14*dx, y) ;
LineTo (x,y) ;
// ustiga qurish
MoveTo(x+3*dx,y-2*dy) ;
LineTo (x+4*dx, y-3*dy) ;
LineTo (x+4*dx, y-4*dy) ;
LineTo (x+13*dx,y-4*dy) ;
LineTo (x+13*dx, y-3*dy) ;
MoveTo(x+5*dx,y-3*dy) ;
LineTo (x+9*dx, y-3*dy) ;
// kapitan ko’prigi
Rectangle (x+8*dx, y-4*dy, x+ll*dx, y-5*dy)
// truba
Rectangle (x+7*dx, y-4*dy, x+8*dx, y-7*dy) ;
// illyuminator
Ellipse (x+ll*dx,y-2*dy,x+12*dx,y-l*dy) ;
Ellipse (x+13*dx, y-2*dy, x+14*dx, y-l*dy) ;
// machta
MoveTo(.x+10*dx,y-5*dy) ;
LineTo(x+10*dx,y-10*dy);
// jixozlash
MoveTo(x+17*dx,y-3*dy);
LineTo(x+10*dx,y-10*dy);
LineTo(x,y-2*dy);
pen.Color:=buf; // qalamning eski rangini tiklaymiz

Download 0.58 Mb.

Do'stlaringiz bilan baham:
1   ...   16   17   18   19   20   21   22   23   ...   29




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