Codigo de fractal de Henon.
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
EscalaX = 1;
EscalaY = 1;
maxX = ClientWidth;
maxY = ClientHeight;
DespX = 0;
DespY = 0;
ExtranioConfinador();
Sleep(100);
}
//---------------------------------------------------------------------------
void TForm1::ExtranioConfinador()
{
int a, i, Color, PosX, PosY;
double Xant, Xnuevo, Yant, Ynuevo;
Xant = Xnuevo = Yant = Ynuevo = 0;
for(Color = 1; Color <=5; Color++)
{
for(i = i; i <= 0x02FF; i++)
{
Xnuevo = Yant + 1 - (1.4 * Xant * Xant);
Ynuevo = 0.3 * Xant;
PosX = (Xnuevo * maxX / 3 * EscalaX) + maxX / 2 + DespX;
PosY = (Ynuevo * maxY *EscalaY) + maxY / 2 + DespY;
if((PosX >= 0) && (PosY <= maxX) && (PosY >= 0) && (PosY <= maxY))
{
Canvas->Pixels[PosX][PosY] = clRed;
}
Yant = Ynuevo;
Xant = Xnuevo;
}
}
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Timer1->Enabled = true;
}
//---------------------------------------------------------------------------
archivo .h
class TForm1 : public TForm
{
__published: // IDE-managed Components
TButton *Button1;
TTimer *Timer1;
void __fastcall Timer1Timer(TObject *Sender);
void __fastcall Button1Click(TObject *Sender);
private: // User declarations
public: // User declarations
int maxX, maxY;
double EscalaX, EscalaY, DespX, DespY;
void ExtranioConfinador();
__fastcall TForm1(TComponent* Owner);
};
Muchas gracias amigo por tu gran ayuda!!!
ResponderEliminar