text stringlengths 0 234 |
|---|
-- Draw_String -- |
----------------- |
procedure Draw_String |
(Buffer : in out Bitmap_Buffer'Class; |
Area : Rect; |
Msg : String; |
Font : Hershey_Font; |
Bold : Boolean; |
Outline : Boolean; |
Foreground : Bitmap_Color; |
Fast : Boolean := True) |
is |
Length : constant Natural := |
Hershey_Fonts.Strlen (Msg, Font, Area.Height); |
Ratio : Float; |
Current : Point := (0, 0); |
Prev : UInt32; |
FG : constant UInt32 := Bitmap_Color_To_Word (Buffer.Color_Mode, |
Foreground); |
Blk : constant UInt32 := Bitmap_Color_To_Word (Buffer.Color_Mode, |
Black); |
procedure Internal_Draw_Line |
(X0, Y0, X1, Y1 : Natural; |
Width : Positive); |
procedure Internal_Draw_Line |
(X0, Y0, X1, Y1 : Natural; |
Width : Positive) |
is |
begin |
Draw_Line (Buffer, |
(Area.Position.X + Natural (Float (X0) * Ratio), |
Area.Position.Y + Y0), |
(Area.Position.X + Natural (Float (X1) * Ratio), |
Area.Position.Y + Y1), |
Width, |
Fast); |
end Internal_Draw_Line; |
procedure Draw_Glyph is new Hershey_Fonts.Draw_Glyph |
(Internal_Draw_Line); |
begin |
if Length > Area.Width then |
Ratio := Float (Area.Width) / Float (Length); |
else |
Ratio := 1.0; |
Current.X := (Area.Width - Length) / 2; |
end if; |
Buffer.Set_Source (Foreground); |
for C of Msg loop |
Draw_Glyph |
(Fnt => Font, |
C => C, |
X => Current.X, |
Y => Current.Y, |
Height => Area.Height, |
Bold => Bold); |
end loop; |
if Outline and then Area.Height > 40 then |
for Y in Area.Position.Y + 1 .. Area.Position.Y + Area.Height loop |
Prev := Buffer.Pixel ((Area.Position.X, Y)); |
if Prev = FG then |
Buffer.Set_Pixel ((Area.Position.X, Y), Black); |
end if; |
for X in Area.Position.X + 1 .. Area.Position.X + Area.Width loop |
declare |
Col : constant UInt32 := Buffer.Pixel ((X, Y)); |
Top : constant UInt32 := Buffer.Pixel ((X, Y - 1)); |
begin |
if Prev /= FG |
and then Col = FG |
then |
Buffer.Set_Pixel ((X, Y), Blk); |
elsif Prev = FG |
and then Col /= FG |
then |
Buffer.Set_Pixel ((X - 1, Y), Blk); |
elsif Top /= FG |
and then Top /= Blk |
and then Col = FG |
then |
Buffer.Set_Pixel ((X, Y), Blk); |
elsif Top = FG |
and then Col /= FG |
then |
Buffer.Set_Pixel ((X, Y - 1), Blk); |
end if; |
Prev := Col; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.