home *** CD-ROM | disk | FTP | other *** search
- PROGRAM ProbaTriangle; { Dibujado de triangulos rellenos. Navi/PhyMosys }
-
- USES Crt;
-
- VAR i : Integer;
-
- PROCEDURE Modo(x : WORD); Assembler;
- ASM
- mov ax, x
- int 10h
- END;
-
- PROCEDURE Triangle(x1,y1, x2,y2, x3,y3 : Integer; col : BYTE);
- PROCEDURE Canviar(VAR a, b : Integer);
- VAR Aux : Integer;
- BEGIN
- Aux:=b;
- b:=a;
- a:=Aux;
- END;
- VAR
- ax, bx, cx, dx,
- aux : Real;
- si, di : Word;{Real;}
- dreta : Boolean;
- aux2 : word;
- BEGIN
- If NOT (y1<y2) Then
- BEGIN
- Canviar(x1,x2);
- Canviar(y1,y2);
- END;
- If NOT (y1<y3) Then
- BEGIN
- Canviar(x1,x3);
- Canviar(y1,y3);
- END;
- If NOT (y2<y3) Then
- BEGIN
- Canviar(x2,x3);
- Canviar(y2,y3);
- END; { Ordenados! }
-
- di:=320*y1+x1;
- si:=320*y2;
- bx:=320+((x1-x3)/(y1-y3));
- dx:=abs(((x2-x1)/(y2-y1))-((x1-x3)/(y1-y3)));
- cx:=0;
-
- If x2>x1 Then
- dreta:=TRUE
- Else
- dreta:=FALSE;
-
- While di<si do
- BEGIN
- aux:=1;
- If dreta then
- While aux<cx do
- BEGIN
- aux2:=word(Round(di+aux));
- Mem[$A000:aux2]:=col;
- aux:=aux+1;
- END
- Else
- While aux<cx do
- BEGIN
- aux2:=word(Round(di-aux));
- Mem[$A000:aux2]:=col;
- aux:=aux+1;
- END;
- di:=di+word(Round(bx));
- cx:=cx+dx;
- END;
-
- si:=320*y3;
- dx:=abs(((x2-x3)/(y2-y3))-((x1-x3)/(y1-y3)));
-
- While di<=si do
- BEGIN
- aux:=1;
- If dreta then
- While aux<cx do
- BEGIN
- aux2:=word(Round(di+aux));
- Mem[$A000:aux2]:=col;
- aux:=aux+1;
- END
- Else
- While aux<cx do
- BEGIN
- aux2:=word(Round(di-aux));
- Mem[$A000:aux2]:=col;
- aux:=aux+1;
- END;
- di:=di+word(Round(bx));
- cx:=cx-dx;
- END;
- END;
-
- BEGIN
- WriteLn('Demo de dibujado de triangulos');
- ReadLn;
- Modo($13);
-
- For i:=1 to 200 do
- BEGIN
- Triangle(130,80, 100,20, 40,130, i);
- Triangle(20,60, 20,30, 100,40, i);
- Triangle(310,0, 170,110, 190,15, i);
- Triangle(134,150, 95,135, 120,115, i);
- END;
-
- ReadLn;
- Modo(3);
- END.
-