Page d'accueil Description du projet
--/******************************************
--
--  Cedric Pradalier   2001
--  mail : http://cedric.pradalier.free.fr/mail.html
--
--****************************************/

--compilation adamake xxxx -largs graph.o -largs -lX11
   with interfaces.C.strings;
   use interfaces.C.strings;
   package body graph is
   
   procedure SaveImage(x,y,width,height:Natural;nom :string) is
   transcom : Chars_Ptr;
     procedure SaveImg(u,v,w,h:integer;n:Chars_ptr);
     pragma import(c,SaveImg,"SaveImage");
   begin
   transcom := New_String(nom & ".tga");
   SaveImg(x,y,width,height,transcom);
   end SaveImage;
   
   
   
   
   
      procedure SetColor(s:string) is
         transcom : Chars_Ptr;
         procedure SetC(n:Chars_Ptr);
      pragma import(c,SetC,"SetColor");
      begin
         transcom := New_String(s);
         SetC(transcom);
      end SetColor;
   
   
      function GetColorIndex(s:string) return integer is
         transcom : Chars_Ptr;
         function GetC(n:Chars_Ptr) return integer;
      pragma import(c,GetC,"GetColor");
      begin
         transcom := New_String(s);
         return GetC(transcom);
      end GetColorIndex;
   
      function black return integer is
      begin
         return GetColorIndex("#000000");
      end black;
   
      function white return integer is
      begin
         return GetColorIndex("#FFFFFF");
      end white;
   
   
   
      procedure SetBkColor(s:string) is
         transcom : Chars_Ptr;
         procedure SetBkC(n:Chars_Ptr);
      pragma import(c,SetBkC,"SetColor");
      begin
         transcom := New_String(s);
         SetBkC(transcom);
      end SetBkColor;
   
   
      procedure OpenGraph(x,y,width,height:integer;FgColor,BgColor:string) is
         transcom1,transcom2 : Chars_Ptr;
         procedure Open(u,v,w,h:integer;fg,bg:Chars_Ptr);
      pragma import(c,Open,"OpenGraph");
      begin
         transcom1 := New_String(FgColor);
         transcom2 := New_String(BgColor);
         Open(x,y,width,height,transcom1,transcom2);
      end OpenGraph;
   
   
   
   
      Procedure DrawString(x,y:integer;s:string) is
         transcom:Chars_Ptr;
         procedure DrawS(u,v:integer;ch:Chars_Ptr);
      pragma import(c,DrawS,"DrawString");
      begin
         transcom := New_String(s);
         DrawS(x,y,transcom);
      end DrawString;
   
   
      Procedure DrawImageString(x,y:integer;s:string) is
         transcom:Chars_Ptr;
         procedure DrawIS(u,v:integer;ch:Chars_Ptr);
      pragma import(c,DrawIS,"DrawImageString");
      begin
         transcom := New_String(s);
         DrawIS(x,y,transcom);
      end DrawImageString;
   
   
      procedure FillPoly(points:Point2DArray ; shape : integer ; mode : integer) is
         type Pts is record
               x,y:short;
            end record;
         type PArray is array(Natural range <>) of Pts;
         Procedure FillPolygon(points:PArray ; npts : integer ; sh : integer ; md : integer);
      pragma import(c,FillPolygon,"FillPolygon");
         trsfR : PArray(1..Points.N);
      
      begin
         for I in 1..Points.N loop 
            trsfR(I) := (short(points.Pts(I).x),short(points.Pts(I).y));
         end loop;
         FillPolygon(trsfR,Points.N,shape,mode);
      end FillPoly;
   
   end graph;