Metropoli BBS
VIEWER: progp082.pas MODE: TEXT (ASCII)
{**********************************************************************}
{ Fill a triangle using scan-line function				}
{**********************************************************************}

procedure fill_triag;
const
x0 = 100;
x1 = 0;
x2 = 300;
y0 = 10;
y1 = 100;
y2 = 100;
line_color = 15;
const
MONO = 5;
VMONO = 7;
COLOR = 4;
ENHANCED = 3;
var
i,y,line_start,line_end : integer;
begin
	clear_screen;
	i := get_display_type;
	if i = MONO then set_mode($0F)
	else if i = VMONO then set_mode($0F)
	else if i = COLOR then set_mode($0E)
	else set_mode($10);

	for y := y0 to y1 do begin	{ Loop over raster lines	}
					{ Compute intercepts		}
		line_start := x0 + ((y - y0)*(x1 - x0)) div (y1 - y0);
		line_end   := x0 + ((y - y0)*(x2 - x0)) div (y2 - y0);
		scanline(line_start,line_end,y,line_color); {Fill section}
	end;
	y := integer(readkey);
	{--- Set default text mode					}
	i := get_display_type;
	if i = MONO then set_mode(7)
	else if i = VMONO then set_mode(7)
	else	set_mode(3);
end;
[ RETURN TO DIRECTORY ]