program rajzolo; uses newdelay,crt,graph; type pont=record x:integer; y:integer; end; tomb=array[1..3] of pont; var a,b,c:pont; t:tomb; kf,ka,kj,kb:integer; x1,x2,y1,y2,c1,c2:integer; function GraphInit:boolean; var gd,gm:integer; utv:string; begin utv:=''; DetectGraph(gd,gm); {$I-} InitGraph(gd,gm,utv); while (GraphResult<>grOK) and (utv<>'exit') do begin {writeln('K‚rem az utvonalat a BGI filehoz vagy exit');} utv:='c:\bp\bgi'; {readln(utv);} DetectGraph(gd,gm); Initgraph(gd,gm,utv); end; GraphInit:=(utv<>'exit'); {$I+} end; procedure keret(x0,y0,x1,y1:integer); begin setcolor(white); rectangle(x0,y0,x1,y1); setfillstyle(solidfill ,blue); bar(x0+1,y0+1,x1-1,y1-1); end; procedure egyenes(x1,y1,x2,y2:integer); var hx,hy,h,i,x,y:integer; lx,ly:real; begin hx:=x2-x1; hy:=y2-y1; if abs(hx)>abs(hy) then h:=abs(hx) else h:=abs(hy); if h=0 then putpixel(x1,y1,red) else begin lx:=hx/h; ly:=hy/h; x:=x1; y:=y1; for i:=1 to (h+1) do begin putpixel(x,y,red); x:=round(x+lx); y:=round(y+ly); end; end; end; procedure csere(var a,b:pont); var s:pont; begin s:=a; a:=b; b:=s; end; procedure rendez(var t:tomb;n:integer); var i,j,min:integer; begin min:=1; for i:=1 to n-1 do begin for j:=i+1 to n do if t[j].ywhite) do ye:=ye+j; vonalveg:=ye; end; procedure fest(x,y:integer); var y1,y2,i:integer; begin y1:=vonalveg(x,y,-1); y2:=vonalveg(x,y,1); line(x,y1,x,y2); for i:=y1 to y2 do begin if getpixel(x+1,i)<>white then fest(x+1,i); if getpixel(x-1,i)<>white then fest(x-1,i); end; end; procedure rajzh(a,b,c:pont); begin line(a.x,a.y,b.x,b.y); line(c.x,c.y,b.x,b.y); line(a.x,a.y,c.x,c.y); end; procedure vegp(x1,y1,x2,y2:integer; var c1,c2:integer); begin c1:=0; c2:=0; if y1>kf then c1:=(c1 or 1); if y2>kf then c2:=(c2 or 1); if x1>kj then c1:=(c1 or 2); if x2>kj then c2:=(c2 or 2); if y10)) do begin if c1=0 then csere2(c1,x1,y1,c2,x2,y2); if (c1 and 1)=1 then vagaf(x1,y1,x2,y2); if (c1 and 2)=1 then vagaj(x1,y1,x2,y2); if (c1 and 4)=1 then vagaa(x1,y1,x2,y2); if (c1 and 8)=1 then vagab(x1,y1,x2,y2); vegp(x1,y1,x2,y2,c1,c2); end; if ((c1=0) and (c2=0)) then line(x1,y1,x2,y2); end; begin if graphinit then begin a.x:=100; a.y:=200; b.x:=300; b.y:=300; c.x:=200; c.y:=100; kf:= 300; ka:= 100; kb:= 100; kj:= 400; x1:=50; y1:=50; x2:=500; y2:=450; {egyenes(50,50,500,450);} vago(50,50,500, 450); {haromszogfest(a,b,c);} {rajzh(a,b,c); fest(200,150);} end; repeat until keypressed; end.