home *** CD-ROM | disk | FTP | other *** search
- unit Main;
-
- { Program copyright (c) 1995 by Charles Calvert }
- { Project Name: ELLIPSES }
-
- { Program to show how to use the Canvas object to
- draw ellipses to the screen. Also demonstrates
- a few facts about the Delphi coordinate system,
- and about accessing the colors available on your
- system.
-
- Some cosmetic issues:
- Panel added at top of screen, and controls placed
- on panel. A second panel used instead of a label. }
-
-
-
- interface
-
- uses
- WinTypes, WinProcs, SysUtils,
- Classes, Graphics, StdCtrls,
- Controls, Printers, Forms, ExtCtrls;
-
- type
- TForm1 = class(TForm)
- Panel1: TPanel;
- Start: TButton;
- Panel2: TPanel;
- Edit1: TEdit;
- procedure BStartClick(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- procedure TForm1.BStartClick(Sender: TObject);
- var
- Borders: Integer;
- i, j, x, y: Integer;
- R: TRect;
- begin
- j := 0;
- R := GetClientRect;
- x := R.Right;
- Borders := Panel1.Height;
- y := R.Bottom - Borders;
- i := StrToInt(Edit1.Text);
- while j < i do begin
- Canvas.Ellipse(Random(x), Random(y) + Borders, Random(x), Random(y) + Borders);
- Canvas.Brush.Color := RGB(Random(255), Random(255), Random(255));
- inc(j);
- end;
- Edit1.SetFocus;
- Edit1.Text := '';
- end;
-
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- Edit1.Text := '100';
- end;
-
- end.
-