unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
     
    { Public declarations }
  end;

var
  Form1: TForm1;
   y,k:integer;
implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var x:integer;
begin
    x := 210;//Random(ClientWidth - 10);
    y := y+10;//Random(ClientHeight - 10);
    Canvas.MoveTo(x,y);
    Canvas.Pen.Color := RGB(Random(256),Random(256),Random(256));
    case Random(5) of
      0: Canvas.Pen.Style := psSolid;
      1: Canvas.Pen.Style := psDash;
      2: Canvas.Pen.Style := psDot;
      3: Canvas.Pen.Style := psDashDot;
      4: Canvas.Pen.Style := psDashDotDot;
  end;
  Canvas.LineTo(x+200, y);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Refresh;  //kasuje poprzedni prostokąt
  Canvas.Brush.Color :=clRed;//RGB(Random(256),Random(256),Random(256)); //kolorem pędzla
  //malowane są wzory po kolei albo losowo jak w ksiązce aplikacje w Delphi z Radom(7)

  case k of
    0: Canvas.Brush.Style := bsClear;
    1: Canvas.Brush.Style := bsSolid;
    2: Canvas.Brush.Style := bsBDiagonal;
    3: Canvas.Brush.Style := bsFDiagonal;
    4: Canvas.Brush.Style := bsCross;
    5: Canvas.Brush.Style := bsDiagCross;
    6: Canvas.Brush.Style := bsHorizontal;
    7: Canvas.Brush.Style := bsVertical;
  end;
  k:=(k+1) MOD 8;
  Canvas.Rectangle(0,0, 200,100);
end;

end.
