Witam,
Bazując na pseudokodzie z Wiki:
For each pixel on the screen do:
{
x0 = scaled x co-ordinate of pixel (must be scaled to lie somewhere in the interval (-2.5 to 1)
y0 = scaled y co-ordinate of pixel (must be scaled to lie somewhere in the interval (-1, 1)x = 0
y = 0iteration = 0
max_iteration = 1000while ( xx + yy <= (22) AND iteration < max_iteration )
{
xtemp = xx - yy + x0
y = 2x*y + y0x = xtemp iteration = iteration + 1
}
if ( iteration == max_iteration )
then
color = black
else
color = iterationplot(x0,y0,color)
}
Próbuje napisać program rysujący fraktal Mandelbrota. Na chwile obecną mój kod wygląda tak:
Int16 res_x, res_y, i = 0, i_MAX=1000, x, y, xtemp;
Color kolor;
Bitmap^ srcBmp = gcnew Bitmap(310,310);
for(res_x = 1; res_x <=300; res_x++)
{
x = 0;
y = 0;
i = 0;
while(x*x + y*y < 4 && i < i_MAX)
{
xtemp = x*x - y*y +res_x;
y = 2*x*y + res_y;
x = xtemp;
i++;
}
if(i == i_MAX) { kolor = System::Drawing::Color::FromArgb(0,0,0); }
else { kolor = System::Drawing::Color::FromArgb(200,200,200); }
srcBmp->SetPixel(res_x,res_y,kolor);
for(res_y = 1; res_y<=300; res_y++)
{
x = 0;
y = 0;
i = 0;
while(x*x + y*y < 4 && i < i_MAX)
{
xtemp = x*x - y*y +res_x;
y = 2*x*y + res_y;
x = xtemp;
i++;
}
if(i == i_MAX) { kolor = System::Drawing::Color::FromArgb(0,0,0); }
else { kolor = System::Drawing::Color::FromArgb(200,150,120); }
srcBmp->SetPixel(res_x,res_y,kolor);
}
}
srcBmp->Save("test.bmp");
pictureBox1->Load("test.bmp");
Jednak po wielu próbach modyfikacji ciągle otrzymuje jednolity obraz powstały z System::FromArgb(200,150,120). W czym problem? Może ktoś mnie oświecić ?