unit perspective2r; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, math; type TForm1 = class(TForm) Panel1: TPanel; Label4: TLabel; Label2: TLabel; Label5: TLabel; Label10: TLabel; Image1: TImage; Button4: TButton; Edit1: TEdit; Edit2: TEdit; Edit3: TEdit; SaveDialog1: TSaveDialog; Button2: TButton; Button1: TButton; Label1: TLabel; Label3: TLabel; Label6: TLabel; Label7: TLabel; procedure Button4Click(Sender: TObject); procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; const PI_TIMES_2 = 6.2831853; NOISEDX = 2; NOISEDY = 2; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.Button4Click(Sender: TObject); begin Close; end; procedure TForm1.Button1Click(Sender: TObject); var i,j,x,y,h, bd,d,t,n,nn:integer; a,b,k,l,costheta,sintheta: real; begin image1.canvas.pen.color:=255*(256*256+256+1); image1.canvas.brush.color:=255*(256*256+256+1); image1.canvas.rectangle(0,0,501,501); image1.canvas.brush.style:=bsclear; image1.canvas.pen.color:=0*(256*256+256+1); // image1.canvas.ellipse(250-round(38*pi),250-round(38*pi), // 250+round(38*pi),250+round(38*pi)); // image1.canvas.ellipse(250-round(76*pi),250-round(76*pi), // 250+round(76*pi),250+round(76*pi)); image1.canvas.brush.color:=0*(256*256+256+1); // drawoval(512,384,round(100*pi),round(100*pi)); bd:=strtoint(edit1.text); b:=bd*pi/180; h:=strtoint(edit2.text); d:=strtoint(edit3.text); image1.canvas.Rectangle(250-round(h/2),480, 250+round(h/2),490); for i:=-9 to 9 do begin k:=(pi/36)*i; l:=pi/4; if i>0 then begin n:=round(arctan(l/k)*180/pi*d); for t:=-n to n do begin x:=round(h*tan(k/cos(t*pi/(180*d)))*cos(t*pi/(180*d)))+250; y:=round(h*tan(k/cos(t*pi/(180*d)))*sin(t*pi/(180*d)))+250; image1.canvas.rectangle(x-1,y-1,x+1,y+1); end; end; if i<0 then begin n:=round(arctan(-l/k)*180/pi*d); for t:=-n to n do begin x:=round(h*tan(k/cos(t*pi/(180*d)))*cos(t*pi/(180*d)))+250; y:=round(h*tan(k/cos(t*pi/(180*d)))*sin(t*pi/(180*d)))+250; image1.canvas.rectangle(x-1,y-1,x+1,y+1); end; end; if i=0 then begin image1.canvas.pen.width:=2; image1.canvas.moveto(250,250-round(h*tan(l))); image1.canvas.lineto(250,250+round(h*tan(l))); image1.canvas.pen.width:=1; end; end; for j:=-9 to 9 do begin l:=(pi/36)*j; k:=pi/4; if j>0 then begin n:=round(arctan(l/k)*180/pi*d); nn:=round(180*d-arctan(l/k)*180/pi*d); for t:=n to nn do begin x:=round(h*tan(l/sin(t*pi/(180*d)))*cos(t*pi/(180*d)))+250; y:=round(h*tan(l/sin(t*pi/(180*d)))*sin(t*pi/(180*d)))+250; image1.canvas.rectangle(x-1,y-1,x+1,y+1); end; end; if j<0 then begin n:=round(arctan(-l/k)*180/pi*d); nn:=round(180*d-arctan(-l/k)*180/pi*d); for t:=n to nn do begin x:=round(h*tan(l/sin(t*pi/(180*d)))*cos(t*pi/(180*d)))+250; y:=round(h*tan(l/sin(t*pi/(180*d)))*sin(t*pi/(180*d)))+250; image1.canvas.rectangle(x-1,y-1,x+1,y+1); end; end; if j=0 then begin image1.canvas.pen.width:=2; image1.canvas.moveto(250-round(h*tan(k)),250); image1.canvas.lineto(250+round(h*tan(k)),250); image1.canvas.pen.width:=1; end; end; end; procedure TForm1.FormCreate(Sender: TObject); begin image1.canvas.pen.color:=255*(256*256+256+1); image1.canvas.brush.color:=255*(256*256+256+1); image1.canvas.rectangle(0,0,501,501); // randomize; SaveDialog1.InitialDir:='d:\öŽ‹}Œ`'; {GetCurrentDir} image1.picture.bitmap.pixelformat:=pf24bit; button1click(sender); activecontrol:=edit1; end; procedure TForm1.Button2Click(Sender: TObject); var currentfile: string; begin if savedialog1.execute then begin currentfile:=savedialog1.filename; image1.picture.SaveToFile(currentfile) end; end; end.