tam_giac_linedda
program tamgiac;
uses graph;
var
m,y:real;
x,i,gd,gm,trx,try:integer;
const color=blue;
procedure lineDDA(x1,y1,x2,y2:integer);
begin
x:=x1;y:=y1;
m:=(y2-y1)/(x2-x1);
putpixel(x,round(y),color);
while x<=x2 do
begin
x:=x+1;y:=y+m;
putpixel(x,round(y),color);
end;
end;
begin
gd:=0;initgraph(gd,gm,'d:\tp\bgi');
lineDDA(100,200,250,260);
lineDDA(100,200,300,420);
lineDDA(250,260,300,420);
trx:=300;try:=0;
lineDDA(100+trx,200+try,250+trx,260+try);
lineDDA(100+trx,200+try,300+trx,420+try);
lineDDA(250+trx,260+try,300+trx,420+try);
readln;
closegraph;
end.
Bạn đang đọc truyện trên: AzTruyen.Top