На pascal можно так:
Объяснение:
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, Windows;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
procedure TForm1.Button1Click(Sender: TObject);
x,y,i:integer;
begin
x:=0; y:=0;
for i:=1 to 500 do
x:=random(x+i);
y:=random(y+i);
if x>600 then x:=random(x-i);
if y>800 then y:=random(y-i);
canvas.Pen.Color:=RGB(i*5,128*i,-128*(i+1));
canvas.Pen.Width:=2;
canvas.LineTo(x,y);
procedure TForm1.Button2Click(Sender: TObject);
Form1.close;
end.
На pascal можно так:
Объяснение:
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, Windows;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
var
x,y,i:integer;
begin
x:=0; y:=0;
for i:=1 to 500 do
begin
x:=random(x+i);
y:=random(y+i);
if x>600 then x:=random(x-i);
if y>800 then y:=random(y-i);
canvas.Pen.Color:=RGB(i*5,128*i,-128*(i+1));
canvas.Pen.Width:=2;
canvas.LineTo(x,y);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Form1.close;
end;
end.