编程delphi题已知三角形三个顶点画出一个三角形
1个回答
2015-01-18
展开全部
用lazarus编制,和delphi类似,x坐标不超过900,y坐标不超过600。若超过,同比例缩小即可。
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
end;
procedure TForm1.Button1Click(Sender: TObject);
var
x1,y1,x2,y2,x3,y3:real;
begin
val(edit1.Text,x1);
val(edit2.text,y1);
val(edit3.text,x2);
val(edit4.text,y2);
val(edit5.Text,x3);
val(edit6.text,y3);
canvas.Line(trunc(x1),600-trunc(y1),trunc(x2),600-trunc(y2));
canvas.Line(trunc(x1),600-trunc(y1),trunc(x3),600-trunc(y3));
canvas.Line(trunc(x2),600-trunc(y2),trunc(x3),600-trunc(y3));
end;
end.
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
end;
procedure TForm1.Button1Click(Sender: TObject);
var
x1,y1,x2,y2,x3,y3:real;
begin
val(edit1.Text,x1);
val(edit2.text,y1);
val(edit3.text,x2);
val(edit4.text,y2);
val(edit5.Text,x3);
val(edit6.text,y3);
canvas.Line(trunc(x1),600-trunc(y1),trunc(x2),600-trunc(y2));
canvas.Line(trunc(x1),600-trunc(y1),trunc(x3),600-trunc(y3));
canvas.Line(trunc(x2),600-trunc(y2),trunc(x3),600-trunc(y3));
end;
end.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询