Noeud « Next »: Text Area, Noeud « Previous »: Common Routines, Noeud « Up »: Library Description
All the drawing is performed using a virtual brush. the brush has the following intrinsic characteristics:
Its obvious that only one of these characteristics is sufficient to perform all kinds of drawing. However, combining both systems may simplify enormously some complex drawings.
type Color_Type is private;
This is the color type used to perform all the drawings. The type is a private type since the user has not to know the internals of the type to use it.
function RGB (R : Integer; G : Integer; B : Integer) return Color_Type;
This function cretes an RGB (Red Green Blue) color. All the given parameter are considered modulo 65536, the maximal value of a color composant.
IMPORTANT NOTE: All custom colors must be declared
before the call to Create_Main_Window
.
The library defines some predefined colors that may be used without
calling RGB
:
All the routines below:
procedure Clear_Drawing_Area;
This procedure “blanks' the drawing area.
procedure Set_Color (C : Color_Type);
This procedure sets the color of the virtual brush to C
.
function Get_Color return Color_Type;
This function returns the current color of the virtual brush.
procedure Set_Thickness (T : Float);
This procedure sets the thickness of the virtual brush to T
.
function Get_Thickness return Float;
This function returns the current thickness of the virtual brush.
procedure Set_Angle (Angle : Float);
This procedure sets the angle between the horizontal and the virtual
brush orientation to Angle
function Get_Angle return Float;
This function returns the angle between the horizontal and the virtual brush orientation.
procedure Rotate (Angle : Float);
This procedure modifies the virtual brush orientation to Angle +
Current_Orientation
.
procedure Set_Position (X : Float; Y : Float);
This function sets the current Cartesian position of the virtual brush
to (X,Y)
.
procedure Get_Position (X : out Float; Y : out Float);
This procedure gets the current Cartesian position of the virtual brush.
procedure Jump (Distance : Float);
This procedure jumps straight forward the given distance in the direction the virtual brush without drawing any line.
procedure Jump (X : Float; Y : Float);
Same as above but using the Cartesian coordinate.
procedure Line (Distance : Float);
This procedure jumps straight forward the given distance in the direction the virtual brush and draws a line between the start and the end points. The color, style and thickness of the line are specified using the appropriate routines.
procedure Line (X : Float; Y : Float);
Same as above but using the Cartesian coordinate.
procedure Line (X_Start : Float; Y_Start : Float; Distance : Float);
Same as above but start from (X_Start, Y_Start)
. At the end of
execution, the virtual brush is located at the end of the drwn line.
procedure Line (X_Start : Float; Y_Start : Float; X_End : Float; Y_End : Float);
Same as above, but with the Cartesian destination.
procedure Point;
This procedure draws a point in the current position.
procedure Point (Center_X : Float; Center_Y : Float);
Same as above but with a custom position.
type X_Justification_Type is (Left, Center, Right); type Y_Justification_Type is (Top, Center, Bottom);
These two enumeration types are used to align horizontally and vertically inserted text and images (see below).
procedure Insert_Image (File_Name : String; Scale : Float := 1.0; X_Justification : X_Justification_Type := Center; Y_Justification : Y_Justification_Type := Center);
This procedure draws a graphic justified at the virtual brush's current location. This will draw any graphic that Gtk understands, including JPEG, GIF, BMP, PNG, PBM, TIFF, and perhaps some others.
IMPORTANT NOTE: If the given path to the image is a relative path, the image location is calculated relatively to the working directory.
procedure Insert_Text (Text : String; Size : Float := 10.0; X_Justification : X_Justification_Type := Center; Y_Justification : Y_Justification_Type := Center);
This procedure draws a text string justified at the virtual brush's current location. The size is expressed in Pixels.
procedure Draw_Circle (Radius : Float);
This procedure draws a circle with radius Radius
and with the
center at the current position of the virtual brush.
procedure Draw_Circle (Center_X : Float; Center_Y : Float; Radius : Float);
Same as above but the position of the center is given.
procedure Fill_Circle (Radius : Float);
This procedure fills a circle with radius Radius
and with the
center at the current position of the virtual brush. Note that the
actual radius of the filled circle is Radius - 1
pixel.
procedure Fill_Circle (Center_X : Float; Center_Y : Float; Radius : Float);
Same as above but the position of the center is given.
procedure Draw_Rectangle (First_X : Float; First_Y : Float; Width : Float; Height : Float);
This procedure draws a rectangle having the specified bottom left edge.
procedure Fill_Rectangle (First_X : Float; First_Y : Float; Width : Float; Height : Float);
This procedure fills a rectangle having the specified bottom left edge edges. Note that the actual sizes of the filled rectangle is reduced by 1 pixel.
type Float_Array is array (Positive range <>) of Float;
This type defines an array of Float. It must be instantiated with tha actual size.
procedure Draw_Polygon (Edges : Float_Array);
This procedure draws a polygon by linking the given edges. The array
must be in the form (X1, Y1, X2, Y2..., Xn, Yn)
. There fore its
length must be even. If the length of 'Edges' is odd, raise
Constraint_Error.
procedure Fill_Polygon (Edges : Float_Array);
This procedure fills a polygon as it would have been drawn by the subprogram above.
procedure Rafresh;
This procedure redraws the drawing area.
procedure Get_Mouse_Pointer (X : out Float; Y : out Float; Button : out Natural);
This procedure waits for a mouse button action and stores the mouse
pointer coordinate in X
and Y
and the mouse button used
to do the action. If the user closes the windows before giving a mouse
click, Lost_Main_Window
will be raised.