--
-- Copyright (c) 2012 Kevin Wellwood
-- All rights reserved.
--
-- This source code is distributed under the Modified BSD License. For terms and
-- conditions, see license.txt.
--
with Allegro.Bitmaps; use Allegro.Bitmaps;
with Allegro.Color; use Allegro.Color;
with Fonts; use Fonts;
package Drawing is
-- Stores the current drawing state, including the target bitmap, blender,
-- and transformation, on a stack. Calling the corresponding Pop_State
-- will reset the state to what it was just before the push.
--
-- Note: This procedure must NOT be called from multiple threads. The state
-- stack is not stored in thread-local memory.
procedure Push_State;
-- Pops the drawing state from the previous corresponding call to Push_State
-- and restores it.
--
-- Note: This procedure must NOT be called from multiple threads. The state
-- stack is not stored in thread-local memory.
procedure Pop_State;
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-- Sets the drawing target bitmap.
procedure Set_Target_Bitmap( bmp : not null A_Allegro_Bitmap );
-- Returns the drawing target bitmap.
function Get_Target_Bitmap return A_Allegro_Bitmap;
-- Returns the width of the drawing target in pixels.
function Get_Target_Width return Natural;
-- Returns the height of the drawing target in pixels.
function Get_Target_Height return Natural;
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-- Clears the entire drawing target to a single color.
procedure Clear_To_Color( color : Allegro_Color );
-- Draws 'bmp' onto the drawing target, using the given location for its top
-- left corner.
procedure Draw_Bitmap( bmp : A_Allegro_Bitmap; x, y : Integer );
-- Draws 'bmp' onto the drawing target, stretching it to 'width' x 'height'.
-- If 'proportional' is to True, 'bmp' will be drawn proportionally within
-- the given width and height, instead of being stretched disproportionately
-- to fill exactly 'width' x 'height'.
procedure Draw_Bitmap_Stretched( bmp : A_Allegro_Bitmap;
x, y : Integer;
width, height : Positive;
proportional : Boolean := False );
-- Draws a region of 'bmp' onto the drawing target, stretching it to the
-- specified dimensions without respect to the original proportions.
procedure Draw_Bitmap_Region_Stretched( bmp : A_Allegro_Bitmap;
srcX,
srcY : Integer;
srcWidth,
srcHeight : Positive;
destX,
destY : Integer;
destWidth,
destHeight : Positive );
-- Draws a string onto the drawing target.
procedure Draw_String( str : String;
x, y : Integer;
font : A_Font;
color : Allegro_Color );
-- Draws a horizontal line on the drawing target.
procedure Line_H( x1, x2 : Integer; y : Integer; color : Allegro_Color );
-- Draws a vertical line on the drawing target.
procedure Line_V( x : Integer; y1, y2 : Integer; color : Allegro_Color );
-- Draws a rectangle on the drawing target.
procedure Rect( x1, y1, x2, y2 : Integer; color : Allegro_Color );
-- Draws a filled rectangle on the drawing target.
procedure Rectfill( x1, y1, x2, y2 : Integer; color : Allegro_Color );
-- Draws a filled rectangle using additive blending.
procedure Rectfill_Additive( x1, y1, x2, y2 : Integer; color : Allegro_Color );
-- Draws a triangle on the drawing target.
procedure Triangle( x1, y1 : Integer;
x2, y2 : Integer;
x3, y3 : Integer;
color : Allegro_Color );
-- Draws a filled triangle on the drawing target.
procedure Triangle_Filled( x1, y1 : Integer;
x2, y2 : Integer;
x3, y3 : Integer;
color : Allegro_Color );
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
type Filter_Type is
(
Filter_Nearest, -- effectively no filter
Filter_Linear, -- linear scaling by Allegro
Filter_xBR -- xBR filter (2x, 3x, 4x only)
);
function To_Filter( name : String;
default : Filter_Type := Filter_Type'First
) return Filter_Type;
function To_Name( filter : Filter_Type ) return String;
end Drawing;