triangle.ppi 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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-03-25 11:18:42 root
  54. Initial revision
  55. Revision 1.3 1998/01/26 11:58:45 michael
  56. + Added log at the end
  57. Working file: rtl/dos/ppi/triangle.ppi
  58. description:
  59. ----------------------------
  60. revision 1.2
  61. date: 1997/12/01 12:21:34; author: michael; state: Exp; lines: +13 -1
  62. + added copyright reference in header.
  63. ----------------------------
  64. revision 1.1
  65. date: 1997/11/27 08:33:52; author: michael; state: Exp;
  66. Initial revision
  67. ----------------------------
  68. revision 1.1.1.1
  69. date: 1997/11/27 08:33:52; author: michael; state: Exp; lines: +0 -0
  70. FPC RTL CVS start
  71. =============================================================================
  72. }