Hosted by
|
with Messages; use Messages;
with Integer_Strings; use Integer_Strings;
package body Glyph_Images is
procedure Bounds_To_Pixels
(Bounds : in Rectangle;
Zoom : in Vector;
SX, SY : out Integer;
Size : out Vector;
Center : out Vector)
is
TL : Real_Vectors.Vector := Get_Top_Left(Bounds);
BR : Real_Vectors.Vector := Get_Bottom_Right(Bounds);
CX : Integer := 1 + Greater_Or_Equal(-Zoom.X * TL.X - 0.5);
CY : Integer := 1 + Greater_Or_Equal(-Zoom.Y * TL.Y - 0.5);
begin
SX := CX + Greater_Or_Equal(Zoom.X * BR.X - 0.5);
SY := CY + Greater_Or_Equal(Zoom.Y * BR.Y - 0.5);
Center := (Real(CX), Real(CY));
Size := (Real(SX), Real(SY));
end Bounds_To_Pixels;
function Bounds_To_Image
(Bounds : in Real_Vectors.Rectangle;
Staff_Height : in Real;
Aspect_Ratio : in Real := 1.0)
return Glyph_Image_Access
is
SX, SY : Integer;
Size : Vector;
Center : Vector;
Result : Glyph_Image_Access;
Zoom : Real := Staff_Height / 400.0;
begin
Bounds_To_Pixels(Bounds, (Zoom * Aspect_Ratio, Zoom), SX, SY, Size, Center);
Result := new Glyph_Image(SX, SY);
Result.Staff_Height := Staff_Height;
Result.Aspect_Ratio := Aspect_Ratio;
Result.Center := Center;
return Result;
end Bounds_To_Image;
procedure Black_Box
(This : access Glyph_Image;
X1, X2 : in Real;
Y1, Y2 : in Real) is
begin
if Y1 > Y2 then
Black_Box(This, X1, X2, Y2, Y1);
return;
end if;
if X1 > X2 then
Black_Box(This, X2, X1, Y1, Y2);
return;
end if;
for Integer_Y in
Integer(This.Center.Y + Y1 * This.Staff_Height / 400.0) ..
Integer(This.Center.Y + Y2 * This.Staff_Height / 400.0)
loop
for Integer_X in
Integer(This.Center.X + X1 * This.Staff_Height / 400.0) ..
Integer(This.Center.X + X2 * This.Staff_Height / 400.0)
loop
This.Pixels(Integer_Y, Integer_X) := 0;
end loop;
end loop;
end Black_Box;
end Glyph_Images;
|