this slowpoke moves

Draw Animate Pixel Spirale

uses Math

type
  TXYZPoint = record
    x, y, z: Real;
  end;
  TCircle = array[1..36] of TXYZPoint;
  
public
{ Public declarations }
    procedure Proekcia(Point: TXYZPoint; var x, y: integer);
    procedure Povorot(xi, yi: Real; var x, y: Real; fi: Real);
    
var
  Form1   : TForm1;
  CircleArray: array[1..16] of TCircle;
  
//


procedure TForm1.FormCreate(Sender: TObject);
var
  i, j: Integer;
  zc  : Real;
begin
  zc := - 144;
  for i := 1 to 16 do
  begin
    for j := 1 to 36 do
    begin
      CircleArray[i][j].x := cos(DegToRad(j * 10)) * 50;
      CircleArray[i][j].y := sin(DegToRad(j * 10)) * 50;
      CircleArray[i][j].z := zc;
      zc := zc + 0.5;
    end;
  end;
end;

procedure TForm1.Povorot(xi, yi: Real; var x, y: Real; fi: Real);
begin
  x := xi * Cos(DegToRad(fi)) - yi * Sin(DegToRad(fi));
  y := xi * Sin(DegToRad(fi)) + yi * Cos(DegToRad(fi));
end;

procedure TForm1.Proekcia(Point: TXYZPoint; var x, y: integer);
begin
  x := Round(Point.x + Point.z / 255);
  y := Round(Point.y + Point.z / 255);
end;

procedure TForm1.TimerTimer(Sender: TObject);
var
  i, j, x, y: Integer;
  xf, yf    : Real;
begin
  Canvas.Rectangle(0, 0, Width, Height);
  for i := 1 to 16 do
    for j := 1 to 36 do
    begin
      Povorot(CircleArray[i][j].x, CircleArray[i][j].z, xf, yf, 1.00);
      CircleArray[i][j].x := xf;
      CircleArray[i][j].z := yf;
      Povorot(CircleArray[i][j].y, CircleArray[i][j].z, xf, yf, 1.00);
      CircleArray[i][j].y := xf;
      CircleArray[i][j].z := yf;
      Povorot(CircleArray[i][j].x, CircleArray[i][j].y, xf, yf, 1.00);
      CircleArray[i][j].x := xf;
      CircleArray[i][j].y := yf;
      Proekcia(CircleArray[i][j], x, y);
      Canvas.Lock;
      Canvas.Pixels[200 + x, 200 + y] := clWhite;
      Canvas.Unlock;
    end;
end;    

Keine Kommentare:

Kommentar veröffentlichen

Beliebte Posts

Translate