-- $Date: 2004/01/01 12:21:12 $
-- $Revision: 1.11 $
-- $Author: jcrocholl $

with Real_Numbers; use Real_Numbers;
with Real_Vectors; use Real_Vectors;
with Outlines; use Outlines;
with Fonts; use Fonts;

package body Straight is

   AX : constant := 0.6; AY : constant := 0.5;
   BX : constant := 0.4; BY : constant := 0.3;
   CX : constant := 0.5; CY : constant := 0.4;
   DX : constant := 0.3; DY : constant := 0.2;
   EX : constant := 0.4; EY : constant := 0.3;
   FX : constant := 0.2; FY : constant := 0.1;

   function Notehead_Crotchet return Glyph is
      Temp   : Outline;
      Result : Glyph;
   begin
      Result := Glyphs.Create("notehead/crotchet");

      Temp := Empty_Outline;
      Add_Straight(Temp, Vector'( BX, AY));
      Add_Straight(Temp, Vector'( AX, BY));
      Add_Straight(Temp, Vector'( AX, -BY));
      Add_Straight(Temp, Vector'( BX, -AY));
      Add_Straight(Temp, Vector'(-BX, -AY));
      Add_Straight(Temp, Vector'(-AX, -BY));
      Add_Straight(Temp, Vector'(-AX, BY));
      Add_Straight(Temp, Vector'(-BX, AY));
      Add_Outline(Result, Temp);

      Set_Bounds(Result, -AX, -AY, AX, AY);
      return Result;
   end Notehead_Crotchet;

   function Notehead_Minim return Glyph is
      Temp   : Outline;
      Result : Glyph;
   begin
      Result := Glyphs.Create("notehead/minim");

      Temp := Empty_Outline;
      Add_Straight(Temp, Vector'(-FX, EY));
      Add_Straight(Temp, Vector'(-EX, FY));
      Add_Straight(Temp, Vector'(-CX, -DY));
      Add_Straight(Temp, Vector'(-DX, -CY));
      Add_Straight(Temp, Vector'( FX, -EY));
      Add_Straight(Temp, Vector'( EX, -FY));
      Add_Straight(Temp, Vector'( CX, DY));
      Add_Straight(Temp, Vector'( DX, CY));
      Add_Outline(Result, Temp);

      Temp := Empty_Outline;
      Add_Straight(Temp, Vector'( BX, AY));
      Add_Straight(Temp, Vector'( AX, BY));
      Add_Straight(Temp, Vector'( AX, -BY));
      Add_Straight(Temp, Vector'( BX, -AY));
      Add_Straight(Temp, Vector'(-BX, -AY));
      Add_Straight(Temp, Vector'(-AX, -BY));
      Add_Straight(Temp, Vector'(-AX, BY));
      Add_Straight(Temp, Vector'(-BX, AY));
      Add_Outline(Result, Temp);

      Set_Bounds(Result, -AX, -AY, AX, AY);
      return Result;
   end Notehead_Minim;

   -- Load a glyph of this font.
   function Load_Glyph
     (Glyph_Name : in String-- The name of the glyph.
     return Glyph is          -- The newly created glyph.
   begin
      if Glyph_Name = "notehead/crotchet" then return Notehead_Crotchet;
      elsif Glyph_Name = "notehead/minim" then return Notehead_Minim;
      else raise Glyph_Not_Found;
      end if;
   end Load_Glyph;

end Straight;