
14.12.2011, 22:24
|
Прохожий
|
|
Регистрация: 10.12.2011
Сообщения: 5
Репутация: 10
|
|
Помогите с построением вершин (графы)
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
ColorDialog1: TColorDialog;
Image1: TImage;
procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
count:integer=0;
pointmassiv:array of TPoint;
r:integer=20;
s:array of array of integer;
v:array of array of integer;
implementation
{$R *.dfm}
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ColorDialog1.Color:=clBlue;
Image1.Canvas.Brush.color:=form1.colordialog1.color;
Image1.Canvas.Ellipse((x-r),(y-r),(x+r),(y+r));
Image1.Canvas.Textout(x-4,y-6,inttostr(count));
inc(count);
SetLength(pointmassiv,count);
SetLength(s,count,count);
setlength(v,count,count);
pointmassiv[count-1].x:=x;
pointmassiv[count-1].y:=y;
end;
procedure TForm1.Button1Click(Sender: TObject);
var kol,i:integer;
begin
Image1.Canvas.Brush.Color:=clWhite;
Image1.Canvas.FloodFill(50,50,clPurple,fsBorder);
Image1.Canvas.Brush.Color:=clBlack;
Randomize;
kol:=StrToInt(form1.edit1.text);
for i:=1 to kol do
Image1MouseDown(Sender,mbLeft,[ssLeft],50+random(Image1.Width-100),50+random(Image1.Height-100));
end;
end.
lmikle: пользуемся тегами!!!
Создает вершины(то есть круги) к которым в будущем будут проведены узлы и тем самым созданы графы
Как мне сделать так что бы от одной вершине к другой было какое то ограничение на расстояние то есть что бы они не появлялись впритык.
|