triangle.ppi 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1993,97 by the Free Pascal development team.
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. procedure Triangle(A,B,C:PointType);
  12. var temp : PointType;
  13. yc,yl : Integer;
  14. x1,x2,x3 : Integer;
  15. y1,y2,y3 : Integer;
  16. begin
  17. if B.Y < A.Y then begin Temp:=A; A:=B; B:=Temp; end;
  18. if C.Y < B.Y then begin Temp:=B; B:=C; C:=Temp; end;
  19. if B.Y < A.Y then begin Temp:=A; A:=B; B:=Temp; end;
  20. x1:=b.x-a.x; y1:=b.y-a.y;
  21. x2:=c.x-b.x; y2:=c.y-b.y;
  22. x3:=c.x-a.x; y3:=c.y-a.y;
  23. yl:=b.y-a.y;
  24. if y1 <> 0 then
  25. for yc:=0 to y1 do
  26. begin
  27. patternline(a.x + yc * x1 div y1,a.x+ yc * x3 div y3,a.y+yc);
  28. end;
  29. if y2 <> 0 then
  30. for yc:=0 to y2 do
  31. begin
  32. patternline(c.x - yc * x2 div y2,c.x - yc * x3 div y3,c.y-yc);
  33. end;
  34. end;
  35. procedure Filltriangle(A,B,C:PointType);
  36. begin
  37. _graphresult:=grOK;
  38. if not isgraphmode then
  39. begin
  40. _graphresult:=grnoinitgraph;
  41. exit;
  42. end;
  43. Triangle(A,B,C);
  44. if (aktcolor<>aktfillsettings.color) or (aktfillsettings.pattern<>1) then
  45. begin
  46. line(a.x,a.y,b.x,b.y);
  47. line(b.x,b.y,c.x,c.y);
  48. line(c.x,c.y,a.x,a.y);
  49. end;
  50. end;
  51. {
  52. $Log$
  53. Revision 1.1 1998-12-21 13:07:05 peter
  54. * use -FE
  55. Revision 1.1.1.1 1998/03/25 11:18:42 root
  56. * Restored version
  57. Revision 1.3 1998/01/26 11:58:45 michael
  58. + Added log at the end
  59. Working file: rtl/dos/ppi/triangle.ppi
  60. description:
  61. ----------------------------
  62. revision 1.2
  63. date: 1997/12/01 12:21:34; author: michael; state: Exp; lines: +13 -1
  64. + added copyright reference in header.
  65. ----------------------------
  66. revision 1.1
  67. date: 1997/11/27 08:33:52; author: michael; state: Exp;
  68. Initial revision
  69. ----------------------------
  70. revision 1.1.1.1
  71. date: 1997/11/27 08:33:52; author: michael; state: Exp; lines: +0 -0
  72. FPC RTL CVS start
  73. =============================================================================
  74. }