+ Stencil Renderables and small refactoring

This commit is contained in:
Vovanium 2023-08-09 19:13:20 +03:00
parent 2f392b68f1
commit 0de3e6b0be
6 changed files with 72 additions and 17 deletions

View File

@ -10,6 +10,11 @@ package Video.Colors with Pure is
-- Universal definition for color component (like R, G, B channels or Alpha)
-- defined to cover the best color resolution required (e. g. 8 bit in true color systems)
subtype Opacity is Color_Component;
Opaque : constant Opacity;
Transparent : constant Opacity;
subtype Color_Component_1_Bit is Integer range 0 .. 1;
subtype Color_Component_4_Bit is Integer range 0 .. 2**4 - 1;
subtype Color_Component_5_Bit is Integer range 0 .. 2**5 - 1;
@ -43,7 +48,7 @@ package Video.Colors with Pure is
R : Color_Component;
G : Color_Component;
B : Color_Component;
A : Color_Component := From_8_Bit (2**Color_Component_Bits - 1);
A : Opacity := From_8_Bit (2**Color_Component_Bits - 1);
end record;
function RGB_8 (
@ -61,4 +66,7 @@ package Video.Colors with Pure is
private
type Color_Component is range 0 .. 2**Color_Component_Bits - 1;
Opaque : constant Opacity := Color_Component'Last;
Transparent : constant Opacity := Color_Component'First;
end Video.Colors;

View File

@ -0,0 +1,4 @@
with Video.Stencils;
package Video.Renderables.Color.Stencil
is new Renderables.Color.Generic_Stencil (Stencil_Type => Video.Stencils.Stencil'Class);

View File

@ -1,14 +0,0 @@
--
-- Base interface for rendering image (sprite) to image (renderable)
--
generic
type Sprite (<>) is limited private;
package Video.Renderables.Generic_Sprite is
type Sprite_Renderable is limited interface and Root_Renderable;
procedure Paste (
Target : in out Sprite_Renderable;
A : Integer_Geometry.Point;
Source : Sprite) is abstract;
end Video.Renderables.Generic_Sprite;

View File

@ -1,4 +1,3 @@
with Video.Images;
with Video.Renderables.Generic_Sprite;
package Video.Renderables.Image is new Video.Renderables.Generic_Sprite (Images.Image'Class);
package Video.Renderables.Image is new Video.Renderables.Generic_Image (Images.Image'Class);

View File

@ -61,6 +61,33 @@ package Video.Renderables with Pure is
Bounds : in Box;
Paint : in Paint_Type) is abstract;
generic
type Stencil_Type (<>) is limited private;
package Generic_Stencil is
type Stencil_Renderable is limited interface and Root_Renderable;
procedure Fill (
Target : in out Stencil_Renderable;
A : in Point;
Shape : in Stencil_Type;
Paint : in Paint_Type) is abstract;
end Generic_Stencil;
end Paint_Renderables;
--
-- Base interface for rendering image (sprite) to image (renderable)
--
generic
type Image_Type (<>) is limited private;
package Generic_Image is
type Image_Renderable is limited interface and Root_Renderable;
procedure Paste (
Target : in out Image_Renderable;
A : Integer_Geometry.Point;
Source : Image_Type) is abstract;
end Generic_Image;
end Video.Renderables;

View File

@ -0,0 +1,31 @@
with Video.Integer_Geometry, Video.Colors;
use Video.Integer_Geometry, Video.Colors;
package Video.Stencils is
type Stencil is interface;
function Bounding_Box (
Source : Stencil)
return Box is abstract;
-- Stencil bounds in native (whatever it means) resolution
function Pixel (
Source : Stencil;
A : Point)
return Opacity is abstract;
type Raster_Stencil is interface and Stencil;
generic
type Pixel_Type is private;
package Generic_Raster is
type Stencil is interface and Raster_Stencil;
function Pixel (
Source : Stencil;
A : Point)
return Pixel_Type is abstract;
end Generic_Raster;
end Video.Stencils;