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

 (TImage, , Delphi, )

(Delphi, )

, . , . 2.1, . , .  .

. , . . , 2, , (Delphi, ). *:

      (TImage, , Delphi, )

"" ( Name) btnStop, seXX seYY.

privete ( )

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;
      Label5: TLabel;
      btnStop: TButton;
      GroupBox1: TGroupBox;
      seXX: TSpinEdit;
      seYY: TSpinEdit;
      Label6: TLabel;
      Label7: TLabel;
      procedure FormCreate(Sender: TObject);
      procedure FormDestroy(Sender: TObject);
      procedure TimerTimer(Sender: TObject);
      procedure btnShowClick(Sender: TObject);
      procedure seDelayChange(Sender: TObject);
      procedure btnStopClick(Sender: TObject);
      procedure seXXChange(Sender: TObject);
      procedure seYYChange(Sender: TObject);
      procedure imImageMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
private
     { Private declarations }
     Points:array[1..5] of TPoint;
     Alpha:array[1..5] of Real;
     Gip:array[1..5] of Real;

     XX,YY:integer;
     Axes:TAxesSystem;
     IsStarted:boolean;
     procedure DrawFigure;
public
     { Public declarations }
end;

:

procedure TfrmGameSample.TimerTimer(Sender: TObject);
var i:integer;
begin
    if IsStarted then
    begin
       for i:=1 to 5 do
       begin
           Alpha[i]:=Alpha[i]-PI/60;
           Points[i].X:=trunc(Sin(Alpha[i])*gip[i])+XX;
           Points[i].Y:=trunc(Cos(Alpha[i])*gip[i])+YY;
       end;
      DrawFigure;
  end;
end;

""

procedure TfrmGameSample.btnShowClick(Sender: TObject);
var i:integer;
begin
    IsStarted:=true;
    XX:=seXX.Value;
    YY:=seYY.Value;
    for i:=1 to 5 do
    begin
        Alpha[i]:=arcTan((YY-Points[i].Y)/(XX-Points[i].X));
        gip[i]:=sqrt(sqr(XX-Points[i].X)+sqr(YY-Points[i].Y))
    end;
    DrawFigure;
end;

, , "" btnStopClick, SpinEdit seXXChange seXXChange :

procedure TfrmGameSample.btnStopClick(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;

procedure TfrmGameSample.seXXChange(Sender: TObject);
begin
   XX:=seXX.Value;
end;

procedure TfrmGameSample.seYYChange(Sender: TObject);
begin
   YY:=seYY.Value;
end;

, , . , OnMouseDown (imImage, TImage):

procedure TfrmGameSample.imImageMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
    XX:=X;
    YY:=Y;
end;

:

      (TImage, , Delphi, )

(Delphi, )


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


 

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