arc.ppi 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 Arc(x,y,alpha,beta:Integer;Radius:word);
  12. const i:Array[0..20]of Byte=
  13. (0,3,0, 2,3,1, 2,1,0, 0,1,1, 0,3,0, 2,3,1, 2,1,0);
  14. var counter,index,ofs : integer;
  15. xa,ya,xe,ye : Array[0..2]of Integer;
  16. xp,yp : integer;
  17. xradius,yradius : word;
  18. first,ready : Boolean;
  19. procedure DrawArc(index1,index2,index3:byte);
  20. var ende,incr:integer;
  21. begin
  22. if index3=0 then begin
  23. counter:=index;
  24. ende:=0;
  25. incr:=-4;
  26. end else begin
  27. counter:=-4;
  28. ende:=index-4;
  29. incr:=4;
  30. end;
  31. if first then begin
  32. repeat
  33. first:=false;
  34. counter:=counter+incr;
  35. xp:=PInteger(BufferMem)[counter+index1];
  36. yp:=PInteger(BufferMem)[counter+index2];
  37. until (counter=ende) or
  38. (((xp=xa[0]) or (xp=xa[1]) or (xp=xa[2])) and
  39. ((yp=ya[0]) or (yp=ya[1]) or (yp=ya[2])));
  40. if Counter=Ende then exit else putpixel(xp,yp,aktcolor);
  41. end;
  42. repeat
  43. if (((xp=xe[0]) or (xp=xe[1]) or (xp=xe[2])) and
  44. ((yp=ye[0]) or (yp=ye[1]) or (yp=ye[2]))) then
  45. begin
  46. ready:=true;
  47. exit;
  48. end;
  49. counter:=counter+incr;
  50. xp:=PInteger(BufferMem)[counter+index1];
  51. yp:=PInteger(BufferMem)[counter+index2];
  52. putpixel(xp,yp,aktcolor);
  53. until counter=Ende;
  54. end;
  55. begin
  56. first:=true; ready:=false;
  57. XRadius:=Radius; YRadius:=Radius;
  58. alpha:=alpha mod 360; beta:=beta mod 360;
  59. case alpha of
  60. 0.. 89 : ofs:=0;
  61. 90..179 : ofs:=1;
  62. 180..269 : ofs:=2;
  63. 270..359 : ofs:=3;
  64. end;
  65. x:=x+aktviewport.x1; y:=y+aktviewport.y1;
  66. xa[1]:=x+round(sin((alpha+90)*Pi/180) * XRadius);
  67. ya[1]:=y+round(cos((alpha+90)*Pi/180) * YRadius);
  68. xe[1]:=x+round(sin((beta+90)*Pi/180) * XRadius);
  69. ye[1]:=y+round(cos((beta+90)*Pi/180) * YRadius);
  70. xa[0]:=xa[1]-1; xa[2]:=xa[1]+1; ya[0]:=ya[1]-1; ya[2]:=ya[1]+1;
  71. xe[0]:=xe[1]-1; xe[2]:=xe[1]+1; ye[0]:=ye[1]-1; ye[2]:=ye[1]+1;
  72. index:=Calcellipse(x,y,Radius,Radius);
  73. repeat
  74. DrawArc(i[ofs*3],i[ofs*3+1],i[ofs*3+2]);
  75. ofs:=(ofs+1) mod 7;
  76. until ready;
  77. end;
  78. {
  79. $Log$
  80. Revision 1.1 1998-03-25 11:18:42 root
  81. Initial revision
  82. Revision 1.3 1998/01/26 11:58:53 michael
  83. + Added log at the end
  84. Working file: rtl/dos/ppi/arc.ppi
  85. description:
  86. ----------------------------
  87. revision 1.2
  88. date: 1997/12/01 12:21:27; author: michael; state: Exp; lines: +13 -0
  89. + added copyright reference in header.
  90. ----------------------------
  91. revision 1.1
  92. date: 1997/11/27 08:33:51; author: michael; state: Exp;
  93. Initial revision
  94. ----------------------------
  95. revision 1.1.1.1
  96. date: 1997/11/27 08:33:51; author: michael; state: Exp; lines: +0 -0
  97. FPC RTL CVS start
  98. =============================================================================
  99. }