//--------------------------------------------------------------------------- #include #pragma hdrstop #include "ympyra2.h" //--------------------------------------------------------------------------- #pragma resource "*.dfm" TFormYmpyra* FormYmpyra; //----------------------------------------------------------------------------- //TCircle //----------------------------------------------------------------------------- void __fastcall TCircle::SetSize() { Left = Fpt.x-r; Top = Fpt.y-r; Width = r+r; Height = r+r; } void __fastcall TCircle::SetPt(const TPoint &npt) { Fpt = npt; SetSize(); } void __fastcall TCircle::SetR(int nr) { Fr = nr; SetSize(); } __fastcall TCircle::TCircle(TWinControl* AOwner, const TPoint &apt, int ar) : TGraphicControl(AOwner) { Parent = AOwner; Fpt = apt; Fr = ar; SetSize(); } void __fastcall TCircle::Paint(void) { Canvas->Brush->Style = bsClear; Canvas->Ellipse(0,0,2*r,2*r); } //--------------------------------------------------------------------------- void __fastcall TFormYmpyra::Alku() { pt.x = 30; pt.y = 100; r = 40; for ( int i=0; i < Ympyroita; i++ ) { ympyrat[i] = new TCircle(PanelKuva,pt,r); pt.x = pt.x + 10; } dp.x = 10; dp.y = 10; } //--------------------------------------------------------------------------- void __fastcall TFormYmpyra::Seuraava() { pt.x += dp.x; pt.y += dp.y; if ( pt.x > PanelKuva->Width ) dp.x = -10; if ( pt.x < 0 ) dp.x = 10; if ( pt.y > PanelKuva->Height) dp.y = -10; if ( pt.y < 0 ) dp.y = 10; ympyrat[askel]->SetPt(pt); askel++; if ( askel >= Ympyroita ) askel = 0; } //--------------------------------------------------------------------------- __fastcall TFormYmpyra::TFormYmpyra(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TFormYmpyra::CheckBoxAutomaattiClick(TObject *Sender) { TimerAutomaatti->Enabled = CheckBoxAutomaatti->Checked; } //--------------------------------------------------------------------- void __fastcall TFormYmpyra::TimerAutomaattiTimer(TObject *Sender) { Seuraava(); } //--------------------------------------------------------------------- void __fastcall TFormYmpyra::FormCreate(TObject *Sender) { Alku(); askel = 0; } //--------------------------------------------------------------------- void __fastcall TFormYmpyra::ButtonSeuraavaClick(TObject *Sender) { Seuraava(); } //---------------------------------------------------------------------