[fpc-pascal] Re: GRAPHICS HELP : PLEASE PLEASE????

Guillermo Martínez Jiménez gmartinez at burdjia.com
Mon Jun 29 09:59:20 CEST 2009


> From: Zachary Marlow <zachary_marlow at yahoo.com>
> Subject: Re: [fpc-pascal] GRAPHICS HELP : PLEASE PLEASE????
> To: FPC-Pascal users discussions <fpc-pascal at lists.freepascal.org>
> Message-ID: <491787.41572.qm at web35505.mail.mud.yahoo.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Well =
>
> =A0=A0=A0=A0=A0 Like How to draw a circle , I just need some example code p=
> lease =
>
> =A0
> PS THANKS FOR READING AND REPLYING

There are a lot of ways to draw a circle. It depends why and where you
need to draw a circle. There are a lot of differences if you need to
draw it using X11 or using a graphical library. For example, using the
Allegro.pas library:

(* Draw circle using Allegro (http://allegro-pas.sourceforge.net/) *)
PROGRAM circle;

USES
  allegro;

BEGIN
  IF NOT al_init THEN
  BEGIN
    WriteLn ('Error initialising Allegro');
    EXIT;
  END;
  IF al_set_gfx_mode (AL_GFX_AUTODETECT, 320, 240, 0, 0) THEN
  BEGIN
    al_install_keyboard;
    al_circle (al_screen, 160, 100, 50, al_makecol (255, 255, 255));
    al_readkey;
    al_exit;
  END
  ELSE
    WriteLn ('Error setting graphics');
END.

Another way, using Lazarus add a TPaintBox to the TForm and set the
"onDraw" event of the TPaintBox to this:

PROCEDURE TForm1.PaintBox1Paint(Sender: TObject);
VAR
  Tmp: TForm1;
BEGIN
  Tmp := SELF;
  WITH (Sender AS TPaintBox).Canvas DO
  BEGIN
    Ellipse (0, 0, Tmp.Width - 1, Tmp.Height - 1);
  END;
END;



More information about the fpc-pascal mailing list