Code
program ascii3d;
uses crt;
type
TPoint = array[0..1] of Real;
Function XOffset(Z:Real) : Real;
Begin
XOffset := Z/2;
{Output: Assign the procedure name to the value.
If you forget to assign the function to the value,
you will get a trash value from the memory}
End;
Function YOffset(Z:Real) : Real;
Begin
YOffset := Z/3;
{Output: Assign the procedure name to the value.
If you forget to assign the function to the value,
you will get a trash value from the memory}
End;
Function Transform(X:Real;Y:Real;Z:Real) :TPoint;
VAR
P : Array[0..1] Of Real;
Begin
P[0]:=X+XOffset(Z)+20;
P[1]:=Y+YOffset(Z)+20;
Transform:= P;
End;
var
count: integer;
canvas : Array[1..40,1..40] of char;
i:tpoint;
i2:tpoint;
temp:integer;
steps:integer;
ti:integer;
temp2:integer;
chrr:char;
x:real;
y:real;
z:real;
begin
count:=0;
while 'a'='a' do begin
count:= (count+2)mod 360;
ClrScr;
Writeln('');
for temp:= 1 to 40 do begin
for temp2:= 1 to 40 do begin
canvas[temp][temp2]:='.';
end;end;
for temp := 0 to 3 do begin
for temp2 := 0 to 1 do begin
x:=Cos((temp /4.0 +count/360)* pi*2)*16.6;
y:=(temp2-0.5)*2*7;
z:=Sin((temp /4.0 +count/360)* pi*2)*16.6;
i:=Transform(x,y,z);
i2:=Transform(x,-y,z);
Steps:=16;
for ti := 1 to Steps do begin
canvas[round(i2[1]-((i2[1]-i[1])/ti))][round(i2[0]-((i2[0]-i[0])/ti))]:='&';
end;
x:=Cos(((temp+1) /4.0 +count/360)* pi*2)*16.6;
y:=(temp2-0.5)*2*7;
z:=Sin(((temp+1) /4.0 +count/360)* pi*2)*16.6;
i2:=Transform(x,y,z);
Steps:=16;
for ti := 1 to Steps do begin
canvas[round(i2[1]-((i2[1]-i[1])/ti))][round(i2[0]-((i2[0]-i[0])/ti))]:='&';
end;
Canvas[round(i[1])][round(i[0])]:='&';
end;
end;
for temp:= 1 to 40 do begin
for temp2:= 1 to 40 do begin
chrr:= canvas[temp][temp2];
if chrr='.' then TextColor(LightBlue) ;
if chrr=',' then TextColor(Red) ;
if chrr='&' then TextColor(White) ;
Write(chrr);
end;
Writeln('');
end;
Delay(60);
end;
end.

