procedure ellipse;
 Var
   loop,length2,oldx,oldy,length,cx,cy:integer;
   rotation,n,u,v,ang,newlength:real;
 Begin
   Prompt ('Any button: to position centre of ellipse');
   Getinput (state,x,y);
   Moveabs (x,y);
   Linerel (0,0);
   cx:=x;cy:=y;
   Prompt ('Any button: set length of 1 axis, and rotation');
   Getinput (state,x,y);
   Moveabs (x,y);
   Linerel (0,0);
   length := round(sqrt((x-cx)*(x-cx)+(y-cy)*(y-cy)));
   If abs(x-cx)<0.00000000001 then If (y-cy)>0  then rotation:=PI/2 
                                                else rotation:=3*PI/2
                              else rotation := arctan ((y-cy)/(x-cx));
   Prompt ('Any button: to set length of other axis');
   Getinput (state,x,y);
   length2 := round(sqrt((x-cx)*(x-cx)+(y-cy)*(y-cy)));
   x:= cx+length;
   y:= cy;
   For loop:= 0 to 100 do begin
      n:=loop*PI/50;
      oldx:=x;
      oldy:=y;
      u:=length* cos (n);
      v:=length2* sin (n);
      If abs(u) < 0.01 then If v>0 then ang:=PI/2 else ang:= 3*PI/2
                       else ang:= arctan (v/u);
      newlength:= sqrt(u*u+v*v);
      ang:=ang+rotation;
      If (n>PI/2+0.01) and (n<3*PI/2-0.01) then ang:=ang+PI;
      x:= round(cx+newlength* cos(ang));
      y:= round(cy+newlength* sin(ang));
      If abs(n)<0.00000000001 then begin oldx:=x;oldy:=y; end;
      Moveabs (round(oldx),round(oldy));
      Linerel (round(x-oldx),round(y-oldy));
   End;
 End;
