-- $Date: 2004/01/10 08:48:20 $
-- $Revision: 1.15 $
-- $Author: jcrocholl $

with Lists;

with Parsers; use Parsers;
with Real_Numbers; use Real_Numbers;
with Real_Vectors; use Real_Vectors;
with Lines; use Lines;

package Outlines is

   -- Instance of generic package Lists with Lines.Line as the
   -- component type.
   package Line_Lists is new Lists(Lines.Line);
   use Line_Lists;

   -- A list of lines, each of which may be either straight
   -- (Lines.Line) or a quadratic (Lines.Quadratic) or cubic
   -- (Lines.Cubic) bezier curve.
   subtype Outline is Line_Lists.List;

   Empty_Outline : constant Outline := Line_Lists.Empty_List;

   ----------------------------
   -- Step-by-step construction
   ----------------------------

   -- Add a straight line to an outline.
   procedure Add_Straight
     (This : in out Outline-- Add to this outline.
      To   : in Vector);     -- End point of straight line.

   -- Add a cubic bezier curve to an outline.
   procedure Add_Cubic
     (This      : in out Outline-- Add to this outline.
      Control_A : in Vector;      -- Control point A of bezier curve.
      Control_B : in Vector;      -- Control point B of bezier curve.
      To        : in Vector);     -- End point of bezier curve.

   -------------------
   -- Postscript input
   -------------------

   -- Parse a PostScript description of an Outline.
   function Read
     (From : in Parser-- The parser to read from.
     return Outline;    -- The newly created Outline.

   ---------------------
   -- Outline conversion
   ---------------------

   -- Approximate every cubic bezier curve by possibly multiple
   -- straight lines.
   --
   -- Input parameter Tolerance specifies the maximum acceptable error
   -- between the original cubic bezier curve and the approximation.
   procedure Straighten
     (This      : in out Outline-- The outline to straighten.
      Tolerance : in Real);       -- Maximum error tolerance.

end Outlines;