Программирование - это просто
Advertisement
arrow Delphi arrow Delphi arrow (TCanvas, TImage, Polygon, TTimer)
07.02.2023 .
1:
C#
Delphi
Web-
Excel-
.
(TCanvas, TImage, Polygon, TTimer) E-mail
megabax   
22.10.2009 .
New Page 2

 (TCanvas, TImage, Polygon, TTimer)

, . . .

, , . . . . , .

, , , , , Private TfrmGameSample , DrawFigure ( ).

TfrmGameSample = class(TForm)
     btnShow: TButton;
     Label1: TLabel;
     Label2: TLabel;
     Label3: TLabel;
     Label4: TLabel;
     edRatioX: TEdit;
     edRatioY: TEdit;
     imImage: TImage;
     seX: TSpinEdit;
     seY: TSpinEdit;
     Timer: TTimer;
     seDelay: TSpinEdit;
     procedure FormCreate(Sender: TObject);
     procedure FormDestroy(Sender: TObject);
     procedure TimerTimer(Sender: TObject);
     procedure btnShowClick(Sender: TObject);
     procedure seDelayChange(Sender: TObject);
private
    { Private declarations }
    Points:array[1..5] of TPoint;
    Axes:TAxesSystem;
    IsStarted:boolean;
    procedure DrawFigure;

public
   { Public declarations }
end;

TAxesSystem TfrmGameSample . DrawFigure:

procedure TfrmGameSample.DrawFigure;
var Rect:TRect;
begin
     //
    Rect.Left:=0;
    Rect.Top:=0;
    Rect.Right:=imImage.Width;
    Rect.Bottom:=imImage.Height;
    imImage.Canvas.FillRect(Rect);

   //
   imImage.Canvas.Polygon(Points);
end;

FormCreate :

procedure TfrmGameSample.FormCreate(Sender: TObject);
var i:integer;
      Trian:array[1..5,1..2] of double;
begin
      IsStarted:=false;

     Trian[1,1]:=1;
     Trian[1,2]:=2;

     Trian[2,1]:=5;
     Trian[2,2]:=4;

     Trian[3,1]:=4;
     Trian[3,2]:=2;

     Trian[4,1]:=4;
     Trian[4,2]:=-1;

     Trian[5,1]:=3;
     Trian[5,2]:=-1;

     Axes:=TAxesSystem.Create;

    //
    Axes.X:=seX.Value;
    Axes.Y:=seY.Value;
    Axes.RatioX:=StrToFloat(edRatioX.Text);
    Axes.RatioY:=StrToFloat(edRatioY.Text);

    for i:=1 to 5 do Points[i]:=Axes.GetPoint(Trian[i,1],Trian[i,2]);
end;

TAxesSystem, . FormDestroy:

procedure TfrmGameSample.FormDestroy(Sender: TObject);
begin
     FreeAndNil(Axes);
end;

, .

, . "" OnClick:

procedure TfrmGameSample.btnShowClick(Sender: TObject);
begin
     IsStarted:=true;
     DrawFigure;
end;

, .

TTimer. System*:

      (TCanvas, TImage, Polygon TTimer)

OnTimer:

procedure TfrmGameSample.TimerTimer(Sender: TObject);
var i:integer;
begin
    if IsStarted then
    begin
        for i:=1 to 5 do Points[i].X:=Points[i].X+1;
        DrawFigure;
    end;
end;

( ).  , , . . , DrawFigure.

TSpinEdit*:

:

procedure TfrmGameSample.seDelayChange(Sender: TObject);
begin
     Timer.Interval:=seDelay.Value;
end;

"", . :

      (TCanvas, TImage, Polygon TTimer)


, *,   . 1274 "Delphi", Borland Delphi.. 


( 06.11.2011 . )
 
« .   . »
 
© 2023 Программирование - это просто
Joomla! - , GNU/GPL.
© 2005-2008 Joom.Ru - Joomla!
Design by Mamboteam.com | Powered by Mambobanner.de
  .