USES Graph,CRT;
CONST
 Resolution = 70;

TYPE
   Point3D = Record
     X,Y : Real;
   End;

Type Poly = record
  X,Y       : Real;
  Ang       : Real;
  NumPoints : byte;
  points    : array [0..15] of Point3D;
  Color     : byte;
End;

VAR  CtrlPt: Array [-1..7] Of Point3D;
     RotatePt : Array [-1..7] Of Point3D;
     Cube : Poly;

Procedure ShowObj(inp : Poly);
Var X1,Y1,X2,Y2 : Real; i : integer;
Begin
  X1 := inp.Points[0].X*cos(inp.Ang*3.14/180)-inp.Points[0].Y*sin(inp.Ang*3.14/180);
  Y1 := inp.Points[0].X*sin(inp.Ang*3.14/180)+inp.Points[0].Y*cos(inp.Ang*3.14/180);
  MoveTo(round(X1+Inp.X),round(Inp.Y-Y1));
  SetColor(inp.color);
  for i := 1 to inp.NumPoints-1 do
    begin
      X2 := inp.Points[i].X*cos(inp.Ang*3.14/180)-inp.Points[i].Y*sin(inp.Ang*3.14/180);
      Y2 := inp.Points[i].X*sin(inp.Ang*3.14/180)+inp.Points[i].Y*cos(inp.Ang*3.14/180);
      LineTo(round(X2+Inp.X),round(Inp.Y-Y2));
    end;
  X1 := inp.Points[0].X*cos(inp.Ang*3.14/180)-inp.Points[0].Y*sin(inp.Ang*3.14/180);
  Y1 := inp.Points[0].X*sin(inp.Ang*3.14/180)+inp.Points[0].Y*cos(inp.Ang*3.14/180);
  LineTo(round(X1+Inp.X),round(Inp.Y-Y1));
End;{ShowCube}
{--------------------------------------}
PROCEDURE Spline_Calc (Ap, Bp, Cp, Dp: Point3D; T, D: Real; Var X, Y: Real);
VAR T2, T3: Real;
BEGIN
   T2 := T * T; 				      { Square of t }
   T3 := T2 * T;				      { Cube of t }
   X := ((Ap.X*T3) + (Bp.X*T2) + (Cp.X*T) + Dp.X)/D;  { Calc x value }
   Y := ((Ap.Y*T3) + (Bp.Y*T2) + (Cp.Y*T) + Dp.Y)/D;  { Calc y value }
END;

PROCEDURE BSpline_ComputeCoeffs (N: Integer; Var Ap, Bp, Cp, Dp: Point3D);
BEGIN
   Ap.X := -CtrlPt[N-1].X + 3*CtrlPt[N].X - 3*CtrlPt[N+1].X + CtrlPt[N+2].X;
   Bp.X := 3*CtrlPt[N-1].X - 6*CtrlPt[N].X + 3*CtrlPt[N+1].X;
   Cp.X := -3*CtrlPt[N-1].X + 3*CtrlPt[N+1].X;
   Dp.X := CtrlPt[N-1].X + 4*CtrlPt[N].X + CtrlPt[N+1].X;
   Ap.Y := -CtrlPt[N-1].Y + 3*CtrlPt[N].Y - 3*CtrlPt[N+1].Y + CtrlPt[N+2].Y;
   Bp.Y := 3*CtrlPt[N-1].Y - 6*CtrlPt[N].Y + 3*CtrlPt[N+1].Y;
   Cp.Y := -3*CtrlPt[N-1].Y + 3*CtrlPt[N+1].Y;
   Dp.Y := CtrlPt[N-1].Y + 4*CtrlPt[N].Y + CtrlPt[N+1].Y;
END;
{--------------------------------------}
PROCEDURE Rotate_ComputeCoeffs (N: Integer; Var Ap, Bp, Cp, Dp: Point3D);
BEGIN
   Ap.X := -RotatePt[N-1].X + 3*RotatePt[N].X - 3*RotatePt[N+1].X + RotatePt[N+2].X;
   Ap.Y := -RotatePt[N-1].Y + 3*RotatePt[N].Y - 3*RotatePt[N+1].Y + RotatePt[N+2].Y;
   Bp.X := 3*RotatePt[N-1].X - 6*RotatePt[N].X + 3*RotatePt[N+1].X;
   Bp.Y := 3*RotatePt[N-1].Y - 6*RotatePt[N].Y + 3*RotatePt[N+1].Y;
   Cp.X := -3*RotatePt[N-1].X + 3*RotatePt[N+1].X;
   Cp.Y := -3*RotatePt[N-1].Y + 3*RotatePt[N+1].Y;
   Dp.X := RotatePt[N-1].X + 4*RotatePt[N].X + RotatePt[N+1].X;
   Dp.Y := RotatePt[N-1].Y + 4*RotatePt[N].Y + RotatePt[N+1].Y;
END;
{--------------------------------------}

PROCEDURE BSpline (X1,Y1,X2,Y2:ReAL;o:poly);
VAR I, J: Integer; X, Y, Lx, Ly,A1,A2: Real; Ap, Bp, Cp, Dp: Point3D;
    A, B, C, D: Point3D;
BEGIN

   CtrlPt[1].X := X1;   CtrlPt[1].Y := Y1;
   CtrlPt[5].X := X2;   CtrlPt[5].Y := Y2;
   CtrlPt[2].X := Random(640); CtrlPt[2].Y := Random(480);
   CtrlPt[3].X := Random(640); CtrlPt[3].Y := Random(480);
   CtrlPt[4].X := Random(640); CtrlPt[4].Y := Random(480);
   RotatePt[1].X := 0; RotatePt[1].Y := 0;
   RotatePt[5].X := 360; RotatePt[5].Y := 360;
   RotatePt[2].X := Random(360); RotatePt[2].Y := Random(360);
   RotatePt[3].X := Random(360); RotatePt[3].Y := Random(360);
   RotatePt[4].X := Random(360); RotatePt[4].Y := Random(360);
   CtrlPt[-1] := CtrlPt[1];
   CtrlPt[0] := CtrlPt[1];
   CtrlPt[6] := CtrlPt[5];
   CtrlPt[7] := CtrlPt[5];
   RotatePt[-1] := RotatePt[1];
   RotatePt[0] := RotatePt[1];
   RotatePt[6] := RotatePt[5];
   RotatePt[7] := RotatePt[5];

   For I := 0 To 5 Do Begin
     BSpline_ComputeCoeffs(I, Ap, Bp, Cp, Dp);
     Rotate_ComputeCoeffs(I, A, B, C, D);
     For J := 1 To Resolution Do Begin
       Spline_Calc(Ap, Bp, Cp, Dp, J/Resolution, 6, X, Y);
       Spline_Calc(A, B, C, D,J/Resolution , 6, A1,A2);
       o.Ang := round(A1) mod 360;
       o.X := X;
       o.Y := Y;
       ShowObj(o);
       Delay(2500 div Resolution);
       ShowObj(o);
     End;
     If KeyPressed then
     Begin
       ReadKey;
       o.Ang := 0;
       o.X := X2;
       o.Y := Y2;
       ShowObj(o);
       Exit;
     End;
   End;
   ShowObj(o);
END;
{--------------------------------------}
Procedure InitObj;

Begin
with Cube do begin
  NumPoints := 5;
  Color := Green;
  Points[0].X := -10;
  Points[0].Y := -5;
  Points[1].X := 10;
  Points[1].Y := -5;
  Points[2].X := 10;
  Points[2].Y := 15;
  Points[3].X := 10;
  Points[3].Y := 5;
  Points[4].X := -10;
  Points[4].Y := 15;
  Ang := 0;
  X := 320;
  y := 200;
End;
End;{InitObj}
{-------------------------------------}
Procedure _A(posX,posY : byte);
Var _1,_2:poly;
Begin
Randomize;

with _1 do begin
NumPoints := 7;
Points[0].X := -15;  Points[0].Y := -15;
Points[2].X := -5;  Points[2].Y := -5;
Points[3].X := 5;  Points[3].Y := -5;
Points[4].X := 5;  Points[4].Y := -15;
Points[5].X := 15;  Points[5].Y := -15;
Points[6].X := 0;  Points[6].Y := 25;
Points[1].X :=-5 ;  Points[1].Y := -15;
Repeat Color := Random(15); until color <> Black;
End;

with _2 do begin
 NumPoints := 3;
Points[0].X := -5;  Points[0].Y := -5;
Points[2].X := 0;  Points[2].Y := 5;
Points[1].X := 5 ;  Points[1].Y := -5;
Repeat Color := Random(15); until color <> Black;
End;
   BSpline(Random(640),480,20+posX*40,posY*70+5,_1);
   BSpline(Random(640),480,20+posX*40,posY*70,_2);
End;{A}
{--------------------}

Procedure _B(posX,posY : byte);
Var _1,_2,_3:poly;
Begin
Randomize;

with _1 do begin
NumPoints := 9;
Points[0].X := -15;  Points[0].Y := -20;
Points[1].X :=5 ;  Points[1].Y := -20;
Points[2].X := 15;  Points[2].Y := -15;
Points[3].X := 15;  Points[3].Y := -10;
Points[4].X := 5;  Points[4].Y := 0;
Points[5].X := 15;  Points[5].Y := 5;
Points[6].X := 15;  Points[6].Y := 15;
Points[7].X := 5;  Points[7].Y := 20;
Points[8].X := -15;  Points[8].Y := 20;
Repeat Color := Random(15); until color <> Black;
End;

with _2 do begin
NumPoints := 4;
Points[0].X := -5;  Points[0].Y := -15;
Points[1].X := 5 ;  Points[1].Y := -15;
Points[2].X := 5;  Points[2].Y := -5;
Points[3].X := -5 ;  Points[3].Y := -5;
Repeat Color := Random(15); until color <> Black;
End;
with _3 do begin
NumPoints := 4;
Points[0].X := -5;  Points[0].Y := 5;
Points[1].X := 5 ;  Points[1].Y := 5;
Points[2].X := 5;  Points[2].Y := 15;
Points[3].X := -5 ;  Points[3].Y := 15;
Repeat Color := Random(15); until color <> Black;
End;
   BSpline(Random(640),480,20+posX*40,posY*70,_1);
   BSpline(Random(640),480,20+posX*40-2,posY*70,_2);
   BSpline(Random(640),480,20+posX*40-2,posY*70,_3);
End;{B}
{--------------------}

Procedure _C(posX,posY : byte);
Var _1,_2,_3:poly;
Begin
Randomize;

with _1 do begin
NumPoints := 6;
Points[0].X := -5; Points[0].Y := -20;
Points[1].X := 5 ;   Points[1].Y := -20;
Points[2].X := 15;  Points[2].Y := -10;
Points[3].X := 10;  Points[3].Y := -5;
Points[4].X := 5;   Points[4].Y := -10;
Points[5].X := -15;  Points[5].Y := -10;
Repeat Color := Random(15); until color <> Black;
End;

with _2 do begin
NumPoints := 4;
Points[0].X := -15;  Points[0].Y := -10;
Points[1].X := -8 ;  Points[1].Y := -10;
Points[2].X := -8;   Points[2].Y := 10;
Points[3].X := -15 ; Points[3].Y := 10;
Repeat Color := Random(15); until color <> Black;
End;
with _3 do begin
NumPoints := 6;
Points[0].X := -15;  Points[0].Y := 10;
Points[1].X := 5 ;  Points[1].Y := 10;
Points[2].X := 10;  Points[2].Y := 5;
Points[3].X := 15 ;  Points[3].Y := 10;
Points[4].X := 5 ;  Points[4].Y := 20;
Points[5].X := -5 ;  Points[5].Y := 20;
Repeat Color := Random(15); until color <> Black;
End;
   BSpline(Random(640),480,20+posX*40,posY*70,_1);
   BSpline(Random(640),480,20+posX*40,posY*70,_2);
   BSpline(Random(640),480,20+posX*40,posY*70,_3);
End;{C}
{--------------------}

Procedure _D(posX,posY : byte);
Var _1,_2:poly;
Begin
Randomize;

with _1 do begin
NumPoints := 7;
Points[0].X := -15;  Points[0].Y := -20;
Points[1].X := -5 ;  Points[1].Y := -20;
Points[2].X := 5;  Points[2].Y := -15;
Points[3].X := 15;  Points[3].Y := 0;
Points[4].X := 5;  Points[4].Y := 15;
Points[5].X := -5;  Points[5].Y := 20;
Points[6].X := -15;  Points[6].Y := 20;
Repeat Color := Random(15); until color <> Black;
End;

with _2 do begin
NumPoints := 3;
Points[0].X := -5;  Points[0].Y := -10;
Points[2].X := 5;  Points[2].Y := 0;
Points[1].X := -5 ;  Points[1].Y := 10;
Repeat Color := Random(15); until color <> Black;
End;
   BSpline(Random(640),480,20+posX*40,posY*70,_1);
   BSpline(Random(640),480,20+posX*40,posY*70,_2);
End;{D}
{--------------------}

Procedure _E(posX,posY : byte);
Var _1,_2:poly;
Begin
Randomize;

with _1 do begin
NumPoints := 8;
Points[0].X := -15;  Points[0].Y := -20;
Points[1].X := 15 ;  Points[1].Y := -20;
Points[2].X := 15;  Points[2].Y := -10;
Points[3].X := -5;  Points[3].Y := -10;
Points[4].X := -5;  Points[4].Y := -5;
Points[5].X := 0;  Points[5].Y := -5;
Points[6].X := 0;  Points[6].Y := 5;
Points[7].X := -15;  Points[7].Y := 5;
Repeat Color := Random(15); until color <> Black;
End;

with _2 do begin
NumPoints := 6;
Points[0].X := -15;  Points[0].Y := 5;
Points[1].X := -5;  Points[1].Y := 5;
Points[2].X := -5 ;  Points[2].Y := 10;
Points[3].X := 15 ;  Points[3].Y := 10;
Points[4].X := 15 ;  Points[4].Y := 20;
Points[5].X := -15 ;  Points[5].Y := 20;

Repeat Color := Random(15); until color <> Black;
End;
   BSpline(Random(640),480,20+posX*40,posY*70,_1);
   BSpline(Random(640),480,20+posX*40,posY*70,_2);
End;{E}
{--------------------}
Procedure _F(posX,posY : byte);
Var _1,_2:poly;
Begin
Randomize;

with _1 do begin
NumPoints := 6;
Points[0].X := -15;  Points[0].Y := -20;
Points[1].X := -5 ;  Points[1].Y := -20;
Points[2].X := -5;  Points[2].Y := -5;
Points[3].X := 5;  Points[3].Y := -5;
Points[4].X := 5;  Points[4].Y := 0;
Points[5].X := -15;  Points[5].Y := 0;
Repeat Color := Random(15); until color <> Black;
End;

with _2 do begin
NumPoints := 6;
Points[0].X := -15;  Points[0].Y := 0;
Points[1].X := -5;  Points[1].Y := 0;
Points[2].X := -5 ;  Points[2].Y := 10;
Points[3].X := 15 ;  Points[3].Y := 10;
Points[4].X := 15 ;  Points[4].Y := 20;
Points[5].X := -15 ;  Points[5].Y := 20;

Repeat Color := Random(15); until color <> Black;
End;
   BSpline(Random(640),480,20+posX*40,posY*70,_1);
   BSpline(Random(640),480,20+posX*40,posY*70,_2);
End;{F}
{--------------------}
Procedure _G(posX,posY : byte);
Var _1,_2,_3:poly;
Begin
Randomize;

with _1 do begin
NumPoints := 9;
Points[0].X := -5; Points[0].Y := -20;
Points[1].X := 5 ;   Points[1].Y := -20;
Points[2].X := 15;  Points[2].Y := -10;
Points[3].X := 15;  Points[3].Y := 0;
Points[4].X := 0;   Points[4].Y := 0;
Points[5].X := 0;  Points[5].Y := -5;
Points[6].X := 5;  Points[6].Y := -5;
Points[7].X := 5;  Points[7].Y := -10;
Points[8].X := -15;  Points[8].Y := -10;
Repeat Color := Random(15); until color <> Black;
End;

with _2 do begin
NumPoints := 4;
Points[0].X := -15;  Points[0].Y := -10;
Points[1].X := -5 ;  Points[1].Y := -10;
Points[2].X := -5;   Points[2].Y := 10;
Points[3].X := -15 ; Points[3].Y := 10;
Repeat Color := Random(15); until color <> Black;
End;
with _3 do begin
NumPoints := 6;
Points[0].X := -15;  Points[0].Y := 10;
Points[1].X := 5 ;  Points[1].Y := 10;
Points[2].X := 10;  Points[2].Y := 5;
Points[3].X := 15 ;  Points[3].Y := 10;
Points[4].X := 5 ;  Points[4].Y := 20;
Points[5].X := -5 ;  Points[5].Y := 20;
Repeat Color := Random(15); until color <> Black;
End;
   BSpline(Random(640),480,20+posX*40,posY*70,_1);
   BSpline(Random(640),480,20+posX*40,posY*70,_2);
   BSpline(Random(640),480,20+posX*40,posY*70,_3);
End;{G}
{--------------------}
Procedure _H(posX,posY : byte);
Var _1,_2:poly;
Begin
Randomize;
with _1 do begin
NumPoints := 8;
Points[0].X := -15;  Points[0].Y := -20;
Points[1].X := -5 ;  Points[1].Y := -20;
Points[2].X := -5;  Points[2].Y := -10;
Points[3].X := 5;  Points[3].Y := -10;
Points[4].X := 5;  Points[4].Y := 0;
Points[5].X := -5;  Points[5].Y := 0;
Points[6].X := -5;  Points[6].Y := 20;
Points[7].X := -15;  Points[7].Y := 20;
Repeat Color := Random(15); until color <> Black;
End;

with _2 do begin
NumPoints := 4;
Points[0].X := 5;  Points[0].Y := -20;
Points[1].X := 15;  Points[1].Y := -20;
Points[2].X := 15 ;  Points[2].Y := 20;
Points[3].X := 5 ;  Points[3].Y := 20;
Repeat Color := Random(15); until color <> Black;
End;
   BSpline(Random(640),480,20+posX*40,posY*70,_1);
   BSpline(Random(640),480,20+posX*40,posY*70,_2);
End;{H}
{--------------------}
Procedure _I(posX,posY : byte);
Var _1,_2:poly;
Begin
Randomize;
with _2 do begin
NumPoints := 8;
Points[0].X := -15;  Points[0].Y := -20;
Points[1].X := 15 ;  Points[1].Y := -20;
Points[2].X := 15;  Points[2].Y := -10;
Points[3].X := 5;  Points[3].Y := -10;
Points[4].X := 5;  Points[4].Y := 10;
Points[5].X := -5;  Points[5].Y := 10;
Points[6].X := -5;  Points[6].Y := -10;
Points[7].X := -15;  Points[7].Y := -10;
Repeat Color := Random(15); until color <> Black;
End;

with _1 do begin
NumPoints := 4;
Points[0].X := -15;  Points[0].Y := 10;
Points[1].X := 15;  Points[1].Y := 10;
Points[2].X := 15 ;  Points[2].Y := 20;
Points[3].X := -15 ;  Points[3].Y := 20;
Repeat Color := Random(15); until color <> Black;
End;
   BSpline(Random(640),480,20+posX*40,posY*70,_1);
   BSpline(Random(640),480,20+posX*40,posY*70,_2);
End;{I}
{--------------------}
Procedure _J(posX,posY : byte);
Var _1,_2:poly;
Begin
Randomize;
with _1 do begin
NumPoints := 9;
Points[0].X := -15;  Points[0].Y := -10;
Points[1].X := -5 ;  Points[1].Y := -20;
Points[2].X := 5;  Points[2].Y := -20;
Points[3].X := 15;  Points[3].Y := -10;
Points[4].X := 15;  Points[4].Y := 0;
Points[5].X := 5;  Points[5].Y := 0;
Points[6].X := 5;  Points[6].Y := -10;
Points[7].X := -5;  Points[7].Y := -10;
Points[8].X := -10;  Points[8].Y := -5;
Repeat Color := Random(15); until color <> Black;
End;

with _2 do begin
NumPoints := 6;
Points[0].X := 5;  Points[0].Y := 0;
Points[1].X := 15;  Points[1].Y := 0;
Points[2].X := 15 ;  Points[2].Y := 20;
Points[3].X := -15 ;  Points[3].Y := 20;
Points[4].X := -15 ;  Points[4].Y := 10;
Points[5].X := 5 ;  Points[5].Y := 10;
Repeat Color := Random(15); until color <> Black;
End;
   BSpline(Random(640),480,20+posX*40,posY*70,_1);
   BSpline(Random(640),480,20+posX*40,posY*70,_2);
End;{J}
{--------------------}
Procedure _K(posX,posY : byte);
Var _1,_2:poly;
Begin
Randomize;
with _1 do begin
NumPoints := 8;
Points[0].X := -15;  Points[0].Y := -20;
Points[1].X := -5 ;  Points[1].Y := -20;
Points[2].X := -5;  Points[2].Y := -5;
Points[3].X := 0;  Points[3].Y := -5;
Points[4].X := 5;  Points[4].Y := -20;
Points[5].X := 15;  Points[5].Y := -20;
Points[6].X := 5;  Points[6].Y := 0;
Points[7].X := -15;  Points[7].Y := 0;
Repeat Color := Random(15); until color <> Black;
End;

with _2 do begin
NumPoints := 8;
Points[0].X := -15;  Points[0].Y := 20;
Points[1].X := -5 ;  Points[1].Y := 20;
Points[2].X := -5;  Points[2].Y := 5;
Points[3].X := 0;  Points[3].Y := 5;
Points[4].X := 5;  Points[4].Y := 20;
Points[5].X := 15;  Points[5].Y := 20;
Points[6].X := 5;  Points[6].Y := 0;
Points[7].X := -15;  Points[7].Y := 0;

Repeat Color := Random(15); until color <> Black;
End;
   BSpline(Random(640),480,20+posX*40,posY*70,_1);
   BSpline(Random(640),480,20+posX*40,posY*70,_2);
End;{K}
{--------------------}
Procedure _L(posX,posY : byte);
Var _1,_2:poly;
Begin
Randomize;
with _2 do begin
NumPoints := 6;
Points[0].X := -15;  Points[0].Y := -20;
Points[1].X := 15 ;  Points[1].Y := -20;
Points[2].X := 15;  Points[2].Y := -10;
Points[3].X := -5;  Points[3].Y := -10;
Points[4].X := -5;  Points[4].Y := 0;
Points[5].X := -15;  Points[5].Y := 0;
Repeat Color := Random(15); until color <> Black;
End;

with _1 do begin
NumPoints := 4;
Points[0].X := -15;  Points[0].Y :=0;
Points[1].X := -5;  Points[1].Y := 0;
Points[2].X := -5 ;  Points[2].Y := 20;
Points[3].X := -15 ;  Points[3].Y := 20;
Repeat Color := Random(15); until color <> Black;
End;
   BSpline(Random(640),480,20+posX*40,posY*70,_1);
   BSpline(Random(640),480,20+posX*40,posY*70,_2);
End;{L}
{--------------------}
Procedure _M(posX,posY : byte);
Var _1,_2:poly;
Begin
Randomize;
with _1 do begin
NumPoints := 7;
Points[0].X := -15;  Points[0].Y := -20;
Points[1].X := -5 ;  Points[1].Y := -20;
Points[2].X := -5;  Points[2].Y := 10;
Points[3].X := 0;  Points[3].Y := -10;
Points[4].X := 0;  Points[4].Y := 10;
Points[5].X := -5;  Points[5].Y := 20;
Points[6].X := -15;  Points[6].Y := 20;
Repeat Color := Random(15); until color <> Black;
End;

with _2 do begin
NumPoints := 7;
Points[0].X := 15;  Points[0].Y := -20;
Points[1].X := 5 ;  Points[1].Y := -20;
Points[2].X := 5;  Points[2].Y := 10;
Points[3].X := 0;  Points[3].Y := -10;
Points[4].X := 0;  Points[4].Y := 10;
Points[5].X := 5;  Points[5].Y := 20;
Points[6].X := 15;  Points[6].Y := 20;
Repeat Color := Random(15); until color <> Black;
End;
   BSpline(Random(640),480,20+posX*40,posY*70,_1);
   BSpline(Random(640),480,20+posX*40,posY*70,_2);
End;{M}
{--------------------}
Procedure _N(posX,posY : byte);
Var _1,_2,_3:poly;
Begin
Randomize;

with _1 do begin
NumPoints := 4;
Points[0].X := -5; Points[0].Y := 0;
Points[1].X := 5 ;   Points[1].Y := -20;
Points[2].X := 5;  Points[2].Y := 0;
Points[3].X := -5;  Points[3].Y := 20;
Repeat Color := Random(15); until color <> Black;
End;

with _2 do begin
NumPoints := 4;
Points[0].X := -15;  Points[0].Y := -20;
Points[1].X := -5 ;  Points[1].Y := -20;
Points[2].X := -5;   Points[2].Y := 20;
Points[3].X := -15 ; Points[3].Y := 20;
Repeat Color := Random(15); until color <> Black;
End;
with _3 do begin
NumPoints := 4;
Points[0].X := 15;  Points[0].Y := -20;
Points[1].X := 5 ;  Points[1].Y := -20;
Points[2].X := 5;   Points[2].Y := 20;
Points[3].X := 15 ; Points[3].Y := 20;
Repeat Color := Random(15); until color <> Black;
End;
   BSpline(Random(640),480,20+posX*40,posY*70,_1);
   BSpline(Random(640),480,20+posX*40,posY*70,_2);
   BSpline(Random(640),480,20+posX*40,posY*70,_3);
End;{N}
{--------------------}
Procedure _O(posX,posY : byte);
Var _1,_2:poly;
Begin
Randomize;
with _2 do begin
NumPoints := 6;
Points[0].X := -5;  Points[0].Y := -5;
Points[1].X := 0 ;  Points[1].Y := -10;
Points[2].X := 5;  Points[2].Y := -5;
Points[3].X := 5;  Points[3].Y := 5;
Points[4].X := 0;  Points[4].Y := 10;
Points[5].X := -5;  Points[5].Y := 5;
Repeat Color := Random(15); until color <> Black;
End;

with _1 do begin
NumPoints := 8;
Points[0].X := -15;  Points[0].Y :=-10;
Points[1].X := -5;  Points[1].Y := -20;
Points[2].X := 5 ;  Points[2].Y := -20;
Points[3].X := 15 ;  Points[3].Y := -10;
Points[4].X := 15;  Points[4].Y :=10;
Points[5].X := 5;  Points[5].Y := 20;
Points[6].X := -5 ;  Points[6].Y := 20;
Points[7].X := -15 ;  Points[7].Y := 10;
Repeat Color := Random(15); until color <> Black;
End;
   BSpline(Random(640),480,20+posX*40,posY*70,_1);
   BSpline(Random(640),480,20+posX*40,posY*70,_2);
End;{O}
{--------------------}
Procedure _P(posX,posY : byte);
Var _1,_2:poly;
Begin
Randomize;
with _2 do begin
NumPoints := 4;
Points[0].X := -5;  Points[0].Y := 5;
Points[1].X := 5 ;  Points[1].Y := 5;
Points[2].X := 5;  Points[2].Y := 15;
Points[3].X := -5;  Points[3].Y :=15;
Repeat Color := Random(15); until color <> Black;
End;

with _1 do begin
NumPoints := 8;
Points[0].X := -15;  Points[0].Y :=-20;
Points[1].X := -5;  Points[1].Y := -20;
Points[2].X := -5 ;  Points[2].Y := 0;
Points[3].X := 5 ;  Points[3].Y := 0;
Points[4].X := 15;  Points[4].Y :=5;
Points[5].X := 15;  Points[5].Y := 15;
Points[6].X := 5 ;  Points[6].Y := 20;
Points[7].X := -15 ;  Points[7].Y := 20;
Repeat Color := Random(15); until color <> Black;
End;
   BSpline(Random(640),480,20+posX*40,posY*70,_1);
   BSpline(Random(640),480,20+posX*40,posY*70,_2);
End;{P}
{--------------------}
Procedure _Q(posX,posY : byte);
Var _1,_2,_3:poly;
Begin
Randomize;
with _2 do begin
NumPoints := 6;
Points[0].X := -5;  Points[0].Y := -5;
Points[1].X := 0 ;  Points[1].Y := -10;
Points[2].X := 5;  Points[2].Y := -5;
Points[3].X := 5;  Points[3].Y := 5;
Points[4].X := 0;  Points[4].Y := 10;
Points[5].X := -5;  Points[5].Y := 5;
Repeat Color := Random(15); until color <> Black;
End;

with _1 do begin
NumPoints := 8;
Points[0].X := -15;  Points[0].Y :=-10;
Points[1].X := -5;  Points[1].Y := -20;
Points[2].X := 5 ;  Points[2].Y := -20;
Points[3].X := 15 ;  Points[3].Y := -10;
Points[4].X := 15;  Points[4].Y :=10;
Points[5].X := 5;  Points[5].Y := 20;
Points[6].X := -5 ;  Points[6].Y := 20;
Points[7].X := -15 ;  Points[7].Y := 10;
Repeat Color := Random(15); until color <> Black;
End;

with _3 do begin
NumPoints := 4;
Points[0].X := 5;  Points[0].Y :=-15;
Points[1].X := 10;  Points[1].Y := -20;
Points[2].X := 15 ;  Points[2].Y := -15;
Points[3].X := 10 ;  Points[3].Y := -10;
Repeat Color := Random(15); until color <> Black;
End;
   BSpline(Random(640),480,20+posX*40,posY*70,_1);
   BSpline(Random(640),480,20+posX*40,posY*70,_2);
   BSpline(Random(640),480,20+posX*40,posY*70,_3);
End;{Q}
{--------------------}
Procedure _R(posX,posY : byte);
Var _1,_2,_3:poly;
Begin
Randomize;
with _2 do begin
NumPoints := 4;
Points[0].X := -5;  Points[0].Y := 5;
Points[1].X := 5 ;  Points[1].Y := 5;
Points[2].X := 5;  Points[2].Y := 15;
Points[3].X := -5;  Points[3].Y :=15;
Repeat Color := Random(15); until color <> Black;
End;

with _1 do begin
NumPoints := 8;
Points[0].X := -15;  Points[0].Y :=-20;
Points[1].X := -5;  Points[1].Y := -20;
Points[2].X := -5 ;  Points[2].Y := 0;
Points[3].X := 5 ;  Points[3].Y := 0;
Points[4].X := 15;  Points[4].Y :=5;
Points[5].X := 15;  Points[5].Y := 15;
Points[6].X := 5 ;  Points[6].Y := 20;
Points[7].X := -15 ;  Points[7].Y := 20;
Repeat Color := Random(15); until color <> Black;
End;

with _3 do begin
NumPoints := 4;
Points[0].X := -5;  Points[0].Y :=-10;
Points[1].X := 5;  Points[1].Y := -20;
Points[2].X := 15 ;  Points[2].Y := -20;
Points[3].X := -5 ;  Points[3].Y := 0;
Repeat Color := Random(15); until color <> Black;
End;

   BSpline(Random(640),480,20+posX*40,posY*70,_1);
   BSpline(Random(640),480,20+posX*40,posY*70,_2);
   BSpline(Random(640),480,20+posX*40,posY*70,_3);
End;{R}
{--------------------}
Procedure _S(posX,posY : byte);
Var _1,_2:poly;
Begin
Randomize;
with _2 do begin
NumPoints := 8;
Points[0].X := -15;  Points[0].Y := -5;
Points[1].X := 5 ;  Points[1].Y := -5;
Points[2].X := 5;  Points[2].Y := 5;
Points[3].X := -5;  Points[3].Y :=5;
Points[4].X := -5;  Points[4].Y := 10;
Points[5].X := 15 ;  Points[5].Y := 10;
Points[6].X := 15;  Points[6].Y := 20;
Points[7].X := -15;  Points[7].Y :=20;
Repeat Color := Random(15); until color <> Black;
End;

with _1 do begin
NumPoints := 6;
Points[0].X := -15;  Points[0].Y :=-20;
Points[1].X := 15;  Points[1].Y := -20;
Points[2].X := 15 ;  Points[2].Y := 5;
Points[3].X := 5 ;  Points[3].Y := 5;
Points[4].X := 5;  Points[4].Y :=-10;
Points[5].X := -15;  Points[5].Y := -10;
Repeat Color := Random(15); until color <> Black;
End;
   BSpline(Random(640),480,20+posX*40,posY*70,_1);
   BSpline(Random(640),480,20+posX*40,posY*70,_2);
End;{S}
{--------------------}
Procedure _T(posX,posY : byte);
Var _1,_2:poly;
Begin
Randomize;
with _2 do begin
NumPoints := 4;
Points[0].X := -5;  Points[0].Y := -20;
Points[1].X := 5 ;  Points[1].Y := -20;
Points[2].X := 5;  Points[2].Y := 10;
Points[3].X := -5;  Points[3].Y := 10;
Repeat Color := Random(15); until color <> Black;
End;

with _1 do begin
NumPoints := 4;
Points[0].X := -15;  Points[0].Y := 10;
Points[1].X := 15;  Points[1].Y := 10;
Points[2].X := 15 ;  Points[2].Y := 20;
Points[3].X := -15 ;  Points[3].Y := 20;
Repeat Color := Random(15); until color <> Black;
End;
   BSpline(Random(640),480,20+posX*40,posY*70,_1);
   BSpline(Random(640),480,20+posX*40,posY*70,_2);
End;{T}
{--------------------}
Procedure _U(posX,posY : byte);
Var _1,_2:poly;
Begin
Randomize;
with _1 do begin
NumPoints := 7;
Points[0].X := 0;  Points[0].Y := -20;
Points[1].X := 5 ;  Points[1].Y := -20;
Points[2].X := 15;  Points[2].Y := -10;
Points[3].X := 15;  Points[3].Y := 20;
Points[4].X := 5;  Points[4].Y := 20;
Points[5].X := 5;  Points[5].Y := -5;
Points[6].X := 0;  Points[6].Y := -10;
Repeat Color := Random(15); until color <> Black;
End;

with _2 do begin
NumPoints := 7;
Points[0].X := 0;  Points[0].Y := -20;
Points[1].X := -5 ;  Points[1].Y := -20;
Points[2].X := -15;  Points[2].Y := -10;
Points[3].X := -15;  Points[3].Y := 20;
Points[4].X := -5;  Points[4].Y := 20;
Points[5].X := -5;  Points[5].Y := -5;
Points[6].X := 0;  Points[6].Y := -10;
Repeat Color := Random(15); until color <> Black;
End;
   BSpline(Random(640),480,20+posX*40,posY*70,_1);
   BSpline(Random(640),480,20+posX*40,posY*70,_2);
End;{U}
{--------------------}
Procedure _V(posX,posY : byte);
Var _1,_2:poly;
Begin
Randomize;
with _2 do begin
NumPoints := 6;
Points[0].X := 0;  Points[0].Y := -20;
Points[1].X := 15 ;  Points[1].Y := 0;
Points[2].X := 15;  Points[2].Y := 20;
Points[3].X := 5;  Points[3].Y :=20;
Points[4].X := 5;  Points[4].Y := 0;
Points[5].X := 0;  Points[5].Y :=-5;
Repeat Color := Random(15); until color <> Black;
End;

with _1 do begin
NumPoints := 6;
Points[0].X := 0;  Points[0].Y := -20;
Points[1].X := -15 ;  Points[1].Y := 0;
Points[2].X := -15;  Points[2].Y := 20;
Points[3].X := -5;  Points[3].Y :=20;
Points[4].X := -5;  Points[4].Y := 0;
Points[5].X := 0;  Points[5].Y :=-5;
Repeat Color := Random(15); until color <> Black;
End;
   BSpline(Random(640),480,20+posX*40,posY*70,_1);
   BSpline(Random(640),480,20+posX*40,posY*70,_2);
End;{V}
{--------------------}
Procedure _W(posX,posY : byte);
Var _1,_2:poly;
Begin
Randomize;
with _2 do begin
NumPoints := 7;
Points[0].X := 0;  Points[0].Y := -10;
Points[1].X := -5 ;  Points[1].Y := -20;
Points[2].X := -15;  Points[2].Y := -10;
Points[3].X := -15;  Points[3].Y :=20;
Points[4].X := -5;  Points[4].Y := 20;
Points[5].X := -5;  Points[5].Y :=-5;
Points[6].X := 0;  Points[6].Y := 5;
Repeat Color := Random(15); until color <> Black;
End;

with _1 do begin
NumPoints := 7;
Points[0].X := 0;  Points[0].Y := -10;
Points[1].X := 5 ;  Points[1].Y := -20;
Points[2].X := 15;  Points[2].Y := -10;
Points[3].X := 15;  Points[3].Y :=20;
Points[4].X := 5;  Points[4].Y := 20;
Points[5].X := 5;  Points[5].Y :=-5;
Points[6].X := 0;  Points[6].Y := 5;
Repeat Color := Random(15); until color <> Black;
End;
   BSpline(Random(640),480,20+posX*40,posY*70,_1);
   BSpline(Random(640),480,20+posX*40,posY*70,_2);
End;{W}
{--------------------}
Procedure _X(posX,posY : byte);
Var _1,_2:poly;
Begin
Randomize;
with _2 do begin
NumPoints := 11;
Points[0].X := -15;  Points[0].Y := 20;
Points[1].X := -5 ;  Points[1].Y :=20;
Points[2].X := -5;  Points[2].Y := 10;
Points[3].X := 0;  Points[3].Y :=5;
Points[4].X := 5;  Points[4].Y := 10;
Points[5].X := 5;  Points[5].Y := 20;
Points[6].X := 15;  Points[6].Y :=20;
Points[7].X := 15;  Points[7].Y :=10;
Points[8].X := 10;  Points[8].Y := 0;
Points[9].X := -10;  Points[9].Y :=0;
Points[10].X := -15;  Points[10].Y := 10;
Repeat Color := Random(15); until color <> Black;
End;

with _1 do begin
NumPoints := 11;
Points[0].X := -15;  Points[0].Y := -20;
Points[1].X := -5 ;  Points[1].Y := -20;
Points[2].X := -5;  Points[2].Y := -10;
Points[3].X := 0;  Points[3].Y :=-5;
Points[4].X := 5;  Points[4].Y := -10;
Points[5].X := 5;  Points[5].Y := -20;
Points[6].X := 15;  Points[6].Y :=-20;
Points[7].X := 15;  Points[7].Y :=-10;
Points[8].X := 10;  Points[8].Y := 0;
Points[9].X := -10;  Points[9].Y :=0;
Points[10].X := -15;  Points[10].Y := -10;
Repeat Color := Random(15); until color <> Black;
End;
   BSpline(Random(640),480,20+posX*40,posY*70,_1);
   BSpline(Random(640),480,20+posX*40,posY*70,_2);
End;{X}
{--------------------}
Procedure _Y(posX,posY : byte);
Var _1,_2:poly;
Begin
Randomize;
with _2 do begin
NumPoints := 4;
Points[0].X := -5;  Points[0].Y := -20;
Points[1].X :=  5 ;  Points[1].Y :=-20;
Points[2].X :=  5;  Points[2].Y :=  0;
Points[3].X := -5;  Points[3].Y := 0;
Repeat Color := Random(15); until color <> Black;
End;

with _1 do begin
NumPoints := 11;
Points[0].X := -5;  Points[0].Y := 0;
Points[1].X := 5 ;  Points[1].Y := 0;
Points[2].X := 15;  Points[2].Y := 10;
Points[3].X := 15;  Points[3].Y := 20;
Points[4].X := 5;  Points[4].Y :=  20;
Points[5].X := 5;  Points[5].Y :=  10;
Points[6].X := 0;  Points[6].Y :=  5;
Points[7].X := -5;  Points[7].Y :=10;
Points[8].X := -5;  Points[8].Y :=20;
Points[9].X := -15;  Points[9].Y :=20;
Points[10].X := -15;  Points[10].Y := 10;
Repeat Color := Random(15); until color <> Black;
End;
   BSpline(Random(640),480,20+posX*40,posY*70,_1);
   BSpline(Random(640),480,20+posX*40,posY*70,_2);
End;{Y}
{--------------------}
Procedure _Z(posX,posY : byte);
Var _1,_2:poly;
Begin
Randomize;
with _1 do begin
NumPoints := 7;
Points[0].X := -15;  Points[0].Y := -20;
Points[1].X := 15 ;  Points[1].Y := -20;
Points[2].X := 15;  Points[2].Y := -10;
Points[3].X := -5;  Points[3].Y := -10;
Points[4].X := 15;  Points[4].Y :=  10;
Points[5].X := 5;  Points[5].Y :=  10;
Points[6].X := -15;  Points[6].Y :=-10;
Repeat Color := Random(15); until color <> Black;
End;
with _2 do begin
NumPoints := 4;
Points[0].X := -15;  Points[0].Y := 20;
Points[1].X := 15 ;  Points[1].Y := 20;
Points[2].X := 15;   Points[2].Y := 10;
Points[3].X := -15;  Points[3].Y := 10;
Repeat Color := Random(15); until color <> Black;
End;
   BSpline(Random(640),480,20+posX*40,posY*70,_1);
   BSpline(Random(640),480,20+posX*40,posY*70,_2);
End;{Z}
{--------------------}
Procedure WriteText(T : string);
Var j,i,con : byte;
Begin
  IF length(t) < 14 then con := abs(14-length(t))div 2 else con := 0;
   For i := 1 to length(t) do
    begin
     IF I < 14 then BEGIN
      j := i + con;
      case t[i] of
        'A','a' : _A(j,3);
        'B','b' : _B(j,3);
        'C','c' : _C(j,3);
        'D','d' : _D(j,3);
        'E','e' : _E(j,3);
        'F','f' : _F(j,3);
        'G','g' : _G(j,3);
        'H','h' : _H(j,3);
        'I','i' : _I(j,3);
        'J','j' : _J(j,3);
        'K','k' : _K(j,3);
        'L','l' : _L(j,3);
        'M','m' : _M(j,3);
        'N','n' : _N(j,3);
        'O','o' : _O(j,3);
        'P','p' : _P(j,3);
        'Q','q' : _Q(j,3);
        'R','r' : _R(j,3);
        'S','s' : _S(j,3);
        'T','t' : _T(j,3);
        'U','u' : _U(j,3);
        'V','v' : _V(j,3);
        'W','w' : _W(j,3);
        'X','x' : _X(j,3);
        'Y','y' : _Y(j,3);
        'Z','z' : _Z(j,3);
      end;
      END;
    end;
End;{WriteText}
{------------------------------}
VAR i,j : integer;
    str : string;
BEGIN
   InitObj;
   Write('Введите строку: ');
   ReadLn(Str);
   I := Detect;
   InitGraph(I, J, '');
   SetWriteMode(XORPUT);
   WriteText(Str);
   ReadKey;
   CloseGraph;
END.
