program rajzolo; uses newdelay,crt,graph; 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 kor(r,u,v:integer); var x,y:integer; begin x:=0; y:=r; while (y>=x) do begin putpixel(x+u,y+v,green); putpixel(y+u,x+v,green); putpixel(y+u,-x+v,green); putpixel(x+u,-y+v,green); putpixel(-x+u,-y+v,green); putpixel(-y+u,-x+v,green); putpixel(-y+u,x+v,green); putpixel(-x+u,y+v,green); if ((x+1)*(x+1)+(y*y)) > r*r then y:=y-1; x:=x+1; end; end; procedure ellipszis(a,b,u,v:integer); var x,y,y1:integer; {y:ellipszist,y1:kort} begin x:=0; y1:=a; while (y1>0) do begin {y:=y1*round(b/a);} y:=y1; putpixel(x+u,y+v,green); putpixel(x+u,-y+v,green); putpixel(-x+u,-y+v,green); putpixel(-x+u,y+v,green); if ((x+1)*(x+1)+(y1*y1)) > a*a then y1:=y1-1; x:=x+1; end; end; Procedure negyedkor(r,u,v:integer); var i,x,y:integer; alfa,alfafok:real; begin alfafok:=1; alfa:=(alfafok/360)*2*pi; for i:=0 to trunc(pi/2/alfa) do begin x:=round(r*cos(i*alfa)); y:=round(r*sin(i*alfa)); putpixel(x+u,y+v,lightred); putpixel(-x+u,y+v,lightred); putpixel(-x+u,-y+v,lightred); putpixel(x+u,-y+v,lightred); end; end; Procedure negyedellipszis(a,b,u,v:integer); var i,x,y:integer; alfa,alfafok:real; begin alfafok:=0.10; alfa:=(alfafok/360)*2*pi; for i:=0 to trunc(pi/2/alfa) do begin x:=round(a*cos(i*alfa)); y:=round(a*sin(i*alfa)*(b/a)); putpixel(x+u,y+v,lightred); putpixel(-x+u,y+v,lightred); putpixel(-x+u,-y+v,lightred); putpixel(x+u,-y+v,lightred); end; end; begin IF graphinit then begin {keret(20,100,500,150);} egyenes(200,100,200,220); kor(40,300,100); circle(400,100,40); ellipszis(40,40,200,300); negyedkor(40,500,300); negyedellipszis(40,100,350,350); end; repeat until keypressed; end.