unit mWorkerThread;
interface
uses
classes, Graphics;
type
WorkerThread =
class(TThread)
protected
procedure Execute;
override;
procedure berechnePixel();
function rechne(X_Ko, Y_Ko: double): Integer;
public
Bild : TBitMap;
X_Min, Y_Min, X_Max, Y_Max: double;
ThreadCount, Hoehe, Breite: Integer;
end;
implementation
function WorkerThread.rechne(X_Ko, Y_Ko: double): Integer;
var
i: Integer;
nX, nY, X, Y, A: double;
begin
i := 0;
X := 0;
Y := 0;
while (i < 100)
and (A < 4)
do begin
nX := (X*X) - (Y*Y) + X_Ko;
nY := 2 * X * Y + Y_Ko;
X := nX;
Y := nY;
A := X*X + Y*Y;
Inc(i);
end;
result := i;
end;
procedure WorkerThread.berechnePixel();
var
x, y: Integer;
faktorX, faktorY, tmp: double;
begin
x := 0;
tmp := Y_Min;
Bild := TBitMap.Create;
Bild.Width := Hoehe;
Bild.Height := Breite;
faktorX := (Abs(x_Min)+Abs(x_Max)) / Bild.Width;
faktorY := (Abs(y_Min)+Abs(y_Max)) / Bild.Height;
while (x_Min <= x_Max)
do begin
y := 0;
while (y_Min <= y_Max)
do begin
case rechne(x_Min, y_Min)
of
0..10: Bild.Canvas.Pixels[x,y] := clBlack;
11..20: Bild.Canvas.Pixels[x,y] := clOlive;
21..30: Bild.Canvas.Pixels[x,y] := clYellow;
31..40: Bild.Canvas.Pixels[x,y] := clLime;
41..50: Bild.Canvas.Pixels[x,y] := clGreen;
51..60: Bild.Canvas.Pixels[x,y] := clAqua;
61..70: Bild.Canvas.Pixels[x,y] := clBlue;
71..80: Bild.Canvas.Pixels[x,y] := clNavy;
81..90: Bild.Canvas.Pixels[x,y] := clPurple;
else Bild.Canvas.Pixels[x,y] := $000000;
end;
y_Min := y_Min + faktorY;
Inc(y);
end;
y_Min := tmp;
x_Min := x_Min + faktorX;
Inc(x);
end;
end;
procedure WorkerThread.Execute;
begin
berechnePixel;
end;
end.