{
    $Id$
    This file is part of the Free Pascal run time library.
    Copyright (c) 1993,97 by the Free Pascal development team.

    See the file COPYING.FPC, included in this distribution,
    for details about the copyright.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 **********************************************************************}

procedure Triangle(A,B,C:PointType);

var temp : PointType;
    yc,yl    : Integer;
    x1,x2,x3 : Integer;
    y1,y2,y3 : Integer;
begin
  if B.Y < A.Y then begin Temp:=A; A:=B; B:=Temp; end;
  if C.Y < B.Y then begin Temp:=B; B:=C; C:=Temp; end;
  if B.Y < A.Y then begin Temp:=A; A:=B; B:=Temp; end;
  x1:=b.x-a.x;  y1:=b.y-a.y;
  x2:=c.x-b.x;  y2:=c.y-b.y;
  x3:=c.x-a.x;  y3:=c.y-a.y;
  yl:=b.y-a.y;
  if y1 <> 0 then
    for yc:=0 to y1 do
    begin
      patternline(a.x + yc * x1 div y1,a.x+ yc * x3 div y3,a.y+yc);
    end;
  if y2 <> 0 then
    for yc:=0 to y2 do
    begin
      patternline(c.x - yc * x2 div y2,c.x - yc * x3 div y3,c.y-yc);
    end;
end;

procedure Filltriangle(A,B,C:PointType);
begin
  _graphresult:=grOK;
  if not isgraphmode then
  begin
    _graphresult:=grnoinitgraph;
    exit;
  end;
  Triangle(A,B,C);
  if (aktcolor<>aktfillsettings.color) or (aktfillsettings.pattern<>1) then
  begin
    line(a.x,a.y,b.x,b.y);
    line(b.x,b.y,c.x,c.y);
    line(c.x,c.y,a.x,a.y);
  end;
end;
{
  $Log$
  Revision 1.1  1998-03-25 11:18:42  root
  Initial revision

  Revision 1.3  1998/01/26 11:58:45  michael
  + Added log at the end


  
  Working file: rtl/dos/ppi/triangle.ppi
  description:
  ----------------------------
  revision 1.2
  date: 1997/12/01 12:21:34;  author: michael;  state: Exp;  lines: +13 -1
  + added copyright reference in header.
  ----------------------------
  revision 1.1
  date: 1997/11/27 08:33:52;  author: michael;  state: Exp;
  Initial revision
  ----------------------------
  revision 1.1.1.1
  date: 1997/11/27 08:33:52;  author: michael;  state: Exp;  lines: +0 -0
  FPC RTL CVS start
  =============================================================================
}
