Pinstripe/Display: Difference between revisions

Ada version
m (→‎{{header|Perl 6}}: proper error message on file open failure, style tweaks)
(Ada version)
Line 62:
}
</lang>
 
=={{header|Ada}}==
{{libheader|SDLAda}}
<lang Ada>with SDL.Video.Windows.Makers;
with SDL.Video.Surfaces;
with SDL.Video.Renderers.Makers;
with SDL.Video.Rectangles;
with SDL.Video.Pixel_Formats;
with SDL.Events.Events;
 
procedure Pinstripe_Display is
 
Width : constant := 800;
Height : constant := 400;
 
Window : SDL.Video.Windows.Window;
Surface : SDL.Video.Surfaces.Surface;
Renderer : SDL.Video.Renderers.Renderer;
Event : SDL.Events.Events.Events;
 
use SDL;
use type SDL.C.int;
 
procedure Draw_Pinstripe (Line_Width : in C.int;
Line_Height : in C.int;
Screen_Width : in C.int;
Y : in C.int)
is
Count : constant C.int := Screen_Width / (2 * Line_Width);
begin
Renderer.Set_Draw_Colour (Colour => (255, 255, 255, 255));
for A in 0 .. Count loop
Renderer.Fill (Rectangle => (X => 2 * A * Line_Width, Y => Y,
Width => Line_Width,
Height => Line_Height));
end loop;
end Draw_Pinstripe;
 
procedure Wait is
use type SDL.Events.Event_Types;
begin
loop
while SDL.Events.Events.Poll (Event) loop
if Event.Common.Event_Type = SDL.Events.Quit then
return;
end if;
end loop;
delay 0.100;
end loop;
end Wait;
 
begin
if not SDL.Initialise (Flags => SDL.Enable_Screen) then
return;
end if;
 
SDL.Video.Windows.Makers.Create (Win => Window,
Title => "Pinstripe",
Position => SDL.Natural_Coordinates'(X => 10, Y => 10),
Size => SDL.Positive_Sizes'(Width, Height),
Flags => 0);
Surface := Window.Get_Surface;
SDL.Video.Renderers.Makers.Create (Renderer, Surface);
 
Surface.Fill (SDL.Video.Rectangles.Rectangle'(0, 0, Width, Height),
SDL.Video.Pixel_Formats.To_Pixel
(Format => Surface.Pixel_Format,
Red => 0, Green => 0, Blue => 0));
 
Draw_Pinstripe (1, Height / 4, Width, 0);
Draw_Pinstripe (2, Height / 4, Width, 100);
Draw_Pinstripe (3, Height / 4, Width, 200);
Draw_Pinstripe (4, Height / 4, Width, 300);
 
Window.Update_Surface;
 
Wait;
Window.Finalize;
SDL.Finalise;
end Pinstripe_Display;</lang>
 
=={{header|AutoHotkey}}==
211

edits