1. -- 
  2. -- Copyright (c) 2012 Kevin Wellwood 
  3. -- All rights reserved. 
  4. -- 
  5. -- This source code is distributed under the Modified BSD License. For terms and 
  6. -- conditions, see license.txt. 
  7. -- 
  8.  
  9. with Allegro.Bitmaps;                   use Allegro.Bitmaps; 
  10. with Allegro.Color;                     use Allegro.Color; 
  11. with Fonts;                             use Fonts; 
  12.  
  13. package Drawing is 
  14.  
  15.     -- Stores the current drawing state, including the target bitmap, blender, 
  16.     -- and transformation, on a stack. Calling the corresponding Pop_State 
  17.     -- will reset the state to what it was just before the push. 
  18.     -- 
  19.     -- Note: This procedure must NOT be called from multiple threads. The state 
  20.     -- stack is not stored in thread-local memory. 
  21.     procedure Push_State; 
  22.  
  23.     -- Pops the drawing state from the previous corresponding call to Push_State 
  24.     -- and restores it. 
  25.     -- 
  26.     -- Note: This procedure must NOT be called from multiple threads. The state 
  27.     -- stack is not stored in thread-local memory. 
  28.     procedure Pop_State; 
  29.  
  30.     -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  31.  
  32.     -- Sets the drawing target bitmap. 
  33.     procedure Set_Target_Bitmap( bmp : not null A_Allegro_Bitmap ); 
  34.  
  35.     -- Returns the drawing target bitmap. 
  36.     function Get_Target_Bitmap return A_Allegro_Bitmap; 
  37.  
  38.     -- Returns the width of the drawing target in pixels. 
  39.     function Get_Target_Width return Natural; 
  40.  
  41.     -- Returns the height of the drawing target in pixels. 
  42.     function Get_Target_Height return Natural; 
  43.  
  44.     -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  45.  
  46.     -- Clears the entire drawing target to a single color. 
  47.     procedure Clear_To_Color( color : Allegro_Color ); 
  48.  
  49.     -- Draws 'bmp' onto the drawing target, using the given location for its top 
  50.     -- left corner. 
  51.     procedure Draw_Bitmap( bmp : A_Allegro_Bitmap; x, y : Integer ); 
  52.  
  53.     -- Draws 'bmp' onto the drawing target, stretching it to 'width' x 'height'. 
  54.     -- If 'proportional' is to True, 'bmp' will be drawn proportionally within 
  55.     -- the given width and height, instead of being stretched disproportionately 
  56.     -- to fill exactly 'width' x 'height'. 
  57.     procedure Draw_Bitmap_Stretched( bmp           : A_Allegro_Bitmap; 
  58.                                      x, y          : Integer; 
  59.                                      width, height : Positive; 
  60.                                      proportional  : Boolean := False ); 
  61.  
  62.     -- Draws a region of 'bmp' onto the drawing target, stretching it to the 
  63.     -- specified dimensions without respect to the original proportions. 
  64.     procedure Draw_Bitmap_Region_Stretched( bmp        : A_Allegro_Bitmap; 
  65.                                             srcX, 
  66.                                             srcY       : Integer; 
  67.                                             srcWidth, 
  68.                                             srcHeight  : Positive; 
  69.                                             destX, 
  70.                                             destY      : Integer; 
  71.                                             destWidth, 
  72.                                             destHeight : Positive ); 
  73.  
  74.     -- Draws a string onto the drawing target. 
  75.     procedure Draw_String( str   : String; 
  76.                            x, y  : Integer; 
  77.                            font  : A_Font; 
  78.                            color : Allegro_Color ); 
  79.  
  80.     -- Draws a horizontal line on the drawing target. 
  81.     procedure Line_H( x1, x2 : Integer; y : Integer; color : Allegro_Color ); 
  82.  
  83.     -- Draws a vertical line on the drawing target. 
  84.     procedure Line_V( x : Integer; y1, y2 : Integer; color : Allegro_Color ); 
  85.  
  86.     -- Draws a rectangle on the drawing target. 
  87.     procedure Rect( x1, y1, x2, y2 : Integer; color : Allegro_Color ); 
  88.  
  89.     -- Draws a filled rectangle on the drawing target. 
  90.     procedure Rectfill( x1, y1, x2, y2 : Integer; color : Allegro_Color ); 
  91.  
  92.     -- Draws a filled rectangle using additive blending. 
  93.     procedure Rectfill_Additive( x1, y1, x2, y2 : Integer; color : Allegro_Color ); 
  94.  
  95.     -- Draws a triangle on the drawing target. 
  96.     procedure Triangle( x1, y1 : Integer; 
  97.                         x2, y2 : Integer; 
  98.                         x3, y3 : Integer; 
  99.                         color  : Allegro_Color ); 
  100.  
  101.     -- Draws a filled triangle on the drawing target. 
  102.     procedure Triangle_Filled( x1, y1 : Integer; 
  103.                                x2, y2 : Integer; 
  104.                                x3, y3 : Integer; 
  105.                                color  : Allegro_Color ); 
  106.  
  107.     -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  108.  
  109.     type Filter_Type is 
  110.     ( 
  111.         Filter_Nearest,    -- effectively no filter 
  112.         Filter_Linear,     -- linear scaling by Allegro 
  113.         Filter_xBR         -- xBR filter (2x, 3x, 4x only) 
  114.     ); 
  115.  
  116.     function To_Filter( name    : String; 
  117.                         default : Filter_Type := Filter_Type'First 
  118.                       ) return Filter_Type; 
  119.  
  120.     function To_Name( filter : Filter_Type ) return String; 
  121.  
  122. end Drawing;