-- $Date: 2004/01/25 13:55:33 $
-- $Revision: 1.4 $
-- $Author: jcrocholl $

with Lines; use Lines;
with Outlines; use Outlines;

package body Transforms is

   -- Scale an outline by a given factor.
   procedure Scale
     (This   : access Outline-- Scale this outline.
      Factor : in Real)        -- Scaling factor.
   is
      use Outlines.Line_Lists;
   begin
      Reset(This);
      while Next(This) loop
         Lines.Scale(Current(This), Factor);
      end loop;
   end Scale;

   -- Scale a glyph by a given factor.
   procedure Scale
     (This   : access Glyph-- Scale this glyph.
      Factor : in Real)      -- Scaling factor.
   is
      use Glyphs.Outline_Lists;
      Outlines : Outline_List_Access := Get_Outlines(This);
      Bounds   : Rectangle;
   begin
      Reset(Outlines);
      while Next(Outlines) loop
         Scale(Current(Outlines), Factor);
      end loop;
      Bounds := Get_Bounds(This);
      Set_Bounds(This,
        Left => Bounds.Left * Factor,
        Bottom => Bounds.Bottom * Factor,
        Right => Bounds.Right * Factor,
        Top => Bounds.Top * Factor);
   end Scale;

   -- Translate an outline by a given offset.
   procedure Translate
     (This   : access Outline-- Translate this outline.
      Offset : in Vector)      -- Translating offset.
   is
      use Outlines.Line_Lists;
   begin
      Reset(This);
      while Next(This) loop
         Lines.Translate(Current(This), Offset);
      end loop;
   end Translate;

   -- Translate a glyph by a given offset.
   procedure Translate
     (This   : access Glyph-- Translate this glyph.
      Offset : in Vector)    -- Translating offset.
   is
      use Glyphs.Outline_Lists;
      Outlines : Outline_List_Access := Get_Outlines(This);
      Bounds   : Rectangle;
   begin
      Reset(Outlines);
      while Next(Outlines) loop
         Translate(Current(Outlines), Offset);
      end loop;
      Bounds := Get_Bounds(This);
      Set_Bounds(This,
        Left => Bounds.Left + Offset.X,
        Bottom => Bounds.Bottom + Offset.Y,
        Right => Bounds.Right + Offset.X,
        Top => Bounds.Top + Offset.Y);
   end Translate;

end Transforms;