comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@acm.org
Subject: Re: graphical output with claw
Date: Tue, 19 Apr 2005 16:29:53 -0500
Date: 2005-04-19T16:29:53-05:00	[thread overview]
Message-ID: <XtOdnf9d9erM5fjfRVn-rg@comcast.com> (raw)
In-Reply-To: e499e546.0504191145.248c9348@posting.google.com

>Can somebody show me an example program with claw that draws just one
>pixel in a defined color into a window?
   How about 50 pixels (a single pixel is hard to see)
with Claw,
     Claw.Basic_Window,
     Claw.Canvas;
package Pixels is
  type Window_Type is new Claw.Basic_Window.Basic_Window_Type with private;
  -- an open window of this type shows a cloud of random red dots

  procedure Open(Window   : in out Window_Type;
                 Title    : in String);

private
  type Window_Type is new Claw.Basic_Window.Basic_Window_Type with record
    Is_Active : Boolean := False;
  end record;

  procedure When_Draw(Window           : in out Window_Type;
                      Easel            : in out Claw.Canvas.Basic_Canvas_Type'Class;
                      Erase_Background : in     Boolean;
                      Area             : in     Claw.Rectangle_Type);
end Pixels;
-----------------
with Ada.Numerics.Float_Random,
     Claw.Bitmaps;
package body Pixels is

  Gen : Ada.Numerics.Float_Random.Generator;

  procedure Open(Window   : in out Window_Type;
                 Title    : in String) is
  begin
    Create(Window, Title);
    Show(Window, Claw.Codes.Show_Startup);
    Window.Is_Active := True;
    Update(Window);
  end Open;

  procedure When_Draw(Window           : in out Window_Type;
                      Easel            : in out Claw.Canvas.Basic_Canvas_Type'Class;
                      Erase_Background : in     Boolean;
                      Area             : in     Claw.Rectangle_Type) is
    use Ada.Numerics.Float_Random;
  begin
    if Window.Is_Active then
      for i in 1 .. 50 loop
        Claw.Bitmaps.Set_Pixel(Easel,
                               (X=>Claw.Int(10.0+40.0*Random(Gen)),
                                Y=>Claw.Int(10.0+20.0*Random(Gen))),
                               Claw.Colors.RGB(Red=>255,Blue=>0,Green=>0));
      end loop;
    end if;
  end When_Draw;

end Pixels;
-----------------
with Claw,
     Pixels;
procedure Showdots is
  A_Window : Pixels.Window_Type;
begin
  Pixels.Open(A_Window,"Simple Example");
  delay 10.0;
end Showdots;



      reply	other threads:[~2005-04-19 21:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-19 19:45 graphical output with claw Duke Luke
2005-04-19 21:29 ` tmoran [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox