const int MaxPoints = 15; struct TRPoint{ float X, Y; }; //--------------------------------------------------------------------------- class TForm1 : public TForm { __published: // IDE-managed Components TTimer *Timer1; void __fastcall FormCreate(TObject *Sender); void __fastcall FormPaint(TObject *Sender); void __fastcall FormResize(TObject *Sender); void __fastcall Timer1Timer(TObject *Sender); private: // User declarations TRPoint Points[MaxPoints]; float Rotation; //¶óµð¾È¿¡¼­ ȸÀü º¯¼ö int PointCount; void __fastcall RotatePoints(void); //ȸÀü ÇÔ¼ö public: // User declarations __fastcall TForm1(TComponent* Owner); }; //--------------------------------------------------------------------------- extern PACKAGE TForm1 *Form1; //--------------------------------------------------------------------------- #endif ¸ÅÀÎ ÀÔ´Ï´Ù. void __fastcall TForm1::FormCreate(TObject *Sender) { Canvas->Pen->Color = clBlack; Rotation = 0; //óÀ½ ȸÀü º¯¼ö´Â 0À¸·Î ¼³Á¤ PointCount = MaxPoints; RotatePoints(); } //--------------------------------------------------------------------------- void __fastcall TForm1::FormPaint(TObject *Sender) { int centerX = ClientWidth/2; //ÆûÀÇ Áß°£ XÁÂÇ¥ int centerY = ClientHeight/2; //ÆûÀÇ Áß°¡ YÁÂÇ¥ //int radius = min(centerY, centerX); centerX = (centerY> centerX)?centerY:centerX; //µÎ °ªÁß ÀÛÀº °ªÀ» ¼±ÅÃÇØ radius¿¡ ÇÒ´ç int radius = centerY; //Æû¿¡ ¸Â°Ô Ÿ¿ø ±×¸®±â Canvas->Ellipse(0, 0, radius*2, radius*2); for(int i = 0; i< PointCount; i++) { for(int j = 0; j< PointCount; j++) { Canvas->MoveTo(radius + floor(Points[i].X* radius), radius + floor(Points[j].Y* radius)); //i,j°¡ Áõ°¡ÇÔ¿¡ µû¶ó radius °è»êÀ¸·Î Ÿ¿øÀ» ±×·ÁÁÝ´Ï´Ù. } } } //--------------------------------------------------------------------------- void __fastcall TForm1::FormResize(TObject *Sender) { Invalidate();//ÄÁµå·Ñ ÀüºÎ¸¦ ´Ù½Ã ±×¸±¶§ Invalidate()ÇÔ¼ö »ç¿ëÇÕ´Ï´Ù. } //--------------------------------------------------------------------------- void __fastcall TForm1::Timer1Timer(TObject *Sender) { RotatePoints(); //0.5Ãʸ¶´Ù ȸÀüÇÕ´Ï´Ù. Invalidate(); } //--------------------------------------------------------------------------- void __fastcall TForm1::RotatePoints(void) { const float M_2PI = 2*M_PI; //2pi¶óµð¾È »ó¼ö ¼³Á¤ float StepAngle = M_2PI / PointCount; Rotation+= M_PI/32; //ȸÀü¾Þ±Û Áõ°¡°ª if(Rotation > StepAngle) { Rotation -= StepAngle; //¾Þ±Û°ª º¸´Ù Ŭ °æ¿ì ȸÀü °¨¼ö int i; float j; for(i = 0, j = Rotation; i < PointCount; i++, j+=StepAngle) { Points[i].X = cos(j); //radius°ª¿¡ µû¶ó °öÇØÁý´Ï´Ù. Points[i].Y = sin(j); } } }