1. with Allegro.Bitmaps;                   use Allegro.Bitmaps; 
  2. with Allegro.Truecolor;                 use Allegro.Truecolor; 
  3. with Font_API;                          use Font_API; 
  4.  
  5. package Drawing_Contexts is 
  6.  
  7.     type Layer_Type is (Background, Foreground); 
  8.  
  9.     type Drawing_Context is private; 
  10.  
  11.     -- Creates a new drawing context using the given bitmap. All drawing calls 
  12.     -- with this context will be translated to the bitmap by 'offx', 'offy' 
  13.     -- pixels. 
  14.     function Create_Drawing_Context( bmp   : not null A_Bitmap; 
  15.                                      offx, 
  16.                                      offy  : Integer; 
  17.                                      layer : Layer_Type ) return Drawing_Context; 
  18.  
  19.     -- Solidly blits the bitmap. 
  20.     procedure Blit( dc       : Drawing_Context; 
  21.                     source   : A_Bitmap; 
  22.                     source_x, 
  23.                     source_y, 
  24.                     dest_x, 
  25.                     dest_y   : Integer; 
  26.                     width, 
  27.                     height   : Natural ); 
  28.  
  29.     -- Clears the whole bitmap to a color. 
  30.     procedure Clear_To_Color( dc : Drawing_Context; color : Color_Type ); 
  31.  
  32.     -- Draws a sprite using full alpha channel blending. 
  33.     procedure Draw_Alpha_Sprite( dc     : Drawing_Context; 
  34.                                  sprite : A_Bitmap; 
  35.                                  x, y   : Integer ); 
  36.  
  37.     -- Draws a sprite using the standard mask color for transparent pixels. 
  38.     procedure Draw_Sprite( dc     : Drawing_Context; 
  39.                            sprite : A_Bitmap; 
  40.                            x, y   : Integer ); 
  41.  
  42.     -- Returns the layer of the drawing context that was specified at creation. 
  43.     function Get_Layer( dc : Drawing_Context ) return Layer_Type; 
  44.  
  45.     -- Draws a straight line. 
  46.     procedure Line( dc     : Drawing_Context; 
  47.                     x1, y1, 
  48.                     x2, y2 : Integer; 
  49.                     color  : Color_Type ); 
  50.  
  51.     -- Draws a rectangle. 
  52.     procedure Rect( dc      : Drawing_Context; 
  53.                     x1, y1, 
  54.                     x2, y2  : Integer; 
  55.                     color   : Color_Type; 
  56.                     opacity : Natural := 255 ); 
  57.     pragma Precondition( opacity <= 255 ); 
  58.  
  59.     -- Draws a filled rectangle. 
  60.     procedure Rectfill( dc      : Drawing_Context; 
  61.                         x1, y1, 
  62.                         x2, y2  : Integer; 
  63.                         color   : Color_Type; 
  64.                         opacity : Natural := 255 ); 
  65.     pragma Precondition( opacity <= 255 ); 
  66.  
  67.     -- Solidly blits the bitmap, stretching it to a different size. 
  68.     procedure Stretch_Blit( dc            : Drawing_Context; 
  69.                             bmp           : A_Bitmap; 
  70.                             source_x, 
  71.                             source_y      : Integer; 
  72.                             source_width, 
  73.                             source_height : Positive; 
  74.                             dest_x, 
  75.                             dest_y        : Integer; 
  76.                             dest_width, 
  77.                             dest_height   : Positive ); 
  78.  
  79.     -- Blits a bitmap using the transparent color as a mask. 'w' and 'h' are the 
  80.     -- destination size to stretch the sprite to. If 'proportional' is to True, 
  81.     -- the sprite will be drawn proportionally within the new width and height, 
  82.     -- instead of being stretched disproportionately to fill it entirely. 
  83.     procedure Stretch_Sprite( dc           : Drawing_Context; 
  84.                               sprite       : A_Bitmap; 
  85.                               x, y         : Integer; 
  86.                               w, h         : Positive; 
  87.                               proportional : Boolean ); 
  88.  
  89.     -- Draws a string string, using the given font. If 'smooth' is set to True, 
  90.     -- the text will be anti-aliased with the context's bitmap. 
  91.     procedure Textout( dc     : Drawing_Context; 
  92.                        f      : Font_Type; 
  93.                        s      : String; 
  94.                        x, y   : Integer; 
  95.                        color  : Color_Type; 
  96.                        smooth : Boolean ); 
  97.  
  98.     -- Draws a triangle. 
  99.     procedure Triangle( dc      : Drawing_Context; 
  100.                         x1, y1  : Integer; 
  101.                         x2, y2  : Integer; 
  102.                         x3, y3  : Integer; 
  103.                         color   : Color_Type; 
  104.                         opacity : Natural := 255 ); 
  105.     pragma Precondition( opacity <= 255 ); 
  106.  
  107. private 
  108.  
  109.     type Drawing_Context is 
  110.         record 
  111.             bmp   : A_Bitmap := null; 
  112.             offx, 
  113.             offy  : Integer := 0; 
  114.             layer : Layer_Type := Background; 
  115.         end record; 
  116.  
  117. end Drawing_Contexts;