was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

57 Visitors Online


 
...ein Mandelbrot Fraktal zeichnen?
Autor: Max Kleiner
Homepage: http://max.kleiner.com
[ Tip ausdrucken ]  

Tip Bewertung (30):  
     




procedure DrawMandelbrot(ACanvas: TCanvas; X, Y, au, bu: Double; X2, Y2: Integer);
var
  
c1, c2, z1, z2, tmp: Double;
  i, j, Count: Integer;
begin
  
c2 := bu;
  for i := 10 to X2 do 
  begin
    
c1 := au;
    for j := 0 to Y2 do 
    begin
      
z1 := 0;
      z2 := 0;
      Count := 0;
     {count is deep of iteration of the mandelbrot set
      if |z| >=2 then z is not a member of a mandelset}
      
while (((z1 * z1 + z2 * z2 < 4) and (Count <= 90))) do 
      begin
        
tmp := z1;
        z1 := z1 * z1 - z2 * z2 + c1;
        z2 := 2 * tmp * z2 + c2;
        Inc(Count);
      end;
      //the color-palette depends on TColor(n*count mod t)
      {$IFDEF LINUX}
      
ACanvas.Pen.Color := (16 * Count mod 255);
      ACanvas.DrawPoint(j, i);
      {$ELSE}
      
ACanvas.Pixels[j, i] := (16 * Count mod 255);
      {$ENDIF}
      
c1 := c1 + X;
    end;
    c2 := c2 + Y;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  
R: TRect;
  au, ao: Integer;
  dX, dY, bo, bu: Double;
begin
  
// Initialize Mandelbrot
  
R.Left := 0;
  R.Right := 200;
  R.Top := 0;
  R.Bottom := 205;
  ao := 1;
  au := -2;
  bo := 1.5;
  bu := -1.5;
  //direct scaling cause of speed
  
dX := (ao - au) / (R.Right - R.Left);
  dY := (bo - bu) / (R.Bottom - R.Top);
  DrawMandelbrot(Self.Canvas, dX, dY, au, bu, R.Right, R.Bottom);
end;

 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners