{ $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 GetArcCoords(var ArcCoords:ArcCoordsType); begin ArcCoords:=ActArcCoords; end; procedure Arc(x,y,alpha,beta:Integer;Radius:word); const i:Array[0..20]of Byte= (0,3,0, 2,3,1, 2,1,0, 0,1,1, 0,3,0, 2,3,1, 2,1,0); var counter,index : integer; endofs,ofs : integer; xa,ya,xe,ye : Array[0..2]of Integer; xp,yp : integer; xradius,yradius : word; first,ready : Boolean; ofscount : byte; procedure DrawArc(index1,index2,index3:byte); var ende,incr:integer; begin if index3=0 then begin counter:=index; ende:=0; incr:=-4; end else begin counter:=-4; ende:=index-4; incr:=4; end; if first then begin repeat first:=false; counter:=counter+incr; xp:=PInteger(BufferMem)[counter+index1]; yp:=PInteger(BufferMem)[counter+index2]; until (counter=ende) or (((xp=xa[0]) or (xp=xa[1]) or (xp=xa[2])) and ((yp=ya[0]) or (yp=ya[1]) or (yp=ya[2]))); if Counter=Ende then exit else putpixeli(xp,yp,aktcolor); end; repeat if (((xp=xe[0]) or (xp=xe[1]) or (xp=xe[2])) and ((yp=ye[0]) or (yp=ye[1]) or (yp=ye[2]))) and ((ofs mod 4)=endofs) then begin putpixeli(xp,yp,aktcolor); ready:=true; exit; end; counter:=counter+incr; xp:=PInteger(BufferMem)[counter+index1]; yp:=PInteger(BufferMem)[counter+index2]; putpixeli(xp,yp,aktcolor); until counter=Ende; end; begin first:=true; ready:=false; XRadius:=(Radius*10000) div XAsp; YRadius:=(Radius*10000) div YAsp; alpha:=alpha mod 360; beta:=beta mod 360; case alpha of 0.. 89 : ofs:=0; 90..179 : ofs:=1; 180..269 : ofs:=2; 270..359 : ofs:=3; end; case beta of 0.. 89 : endofs:=0; 90..179 : endofs:=1; 180..269 : endofs:=2; 270..359 : endofs:=3; end; xa[1]:=x+round(sin((alpha+90)*Pi/180) * XRadius); ya[1]:=y+round(cos((alpha+90)*Pi/180) * YRadius); xe[1]:=x+round(sin((beta+90)*Pi/180) * XRadius); ye[1]:=y+round(cos((beta+90)*Pi/180) * YRadius); ActArcCoords.x:=x; ActArcCoords.y:=y; ActArcCoords.xstart:=xa[1]; ActArcCoords.ystart:=ya[1]; ActArcCoords.xend:=xe[1]; ActArcCoords.yend:=ye[1]; xa[0]:=xa[1]-1; xa[2]:=xa[1]+1; ya[0]:=ya[1]-1; ya[2]:=ya[1]+1; xe[0]:=xe[1]-1; xe[2]:=xe[1]+1; ye[0]:=ye[1]-1; ye[2]:=ye[1]+1; index:=Calcellipse(x,y,Radius,Radius); ofscount:=0; repeat DrawArc(i[ofs*3],i[ofs*3+1],i[ofs*3+2]); ofs:=(ofs+1) mod 7; inc(ofscount); until ready or (ofscount>16); end; procedure PieSlice(X,Y,alpha,beta:integer;Radius: Word); var angle : real; XRadius, YRadius : word; stline : LineSettingsType; writemode : word; begin Arc(x,y,alpha,beta,Radius); GetLineSettings(stline); writemode:=aktwritemode; aktwritemode:=normalput; SetLineStyle(SolidLn,0,NormWidth); MoveTo(ActArcCoords.xstart,ActArcCoords.ystart); LineTo(x,y); LineTo(ActArcCoords.xend,ActArcCoords.yend); PutPixeli(ActArcCoords.xstart,ActArcCoords.ystart,aktcolor); PutPixeli(x,y,aktcolor); PutPixeli(ActArcCoords.xend,ActArcCoords.yend,aktcolor); alpha:=alpha mod 360; beta:=beta mod 360; if alpha<=beta then angle:=(alpha+beta)/2 else angle:=(alpha-360+beta)/2; { fill from the point in the middle of the slice } XRadius:=(Radius*10000) div XAsp; YRadius:=(Radius*10000) div YAsp; {$ifdef GraphDebug} Writeln(stderr,'Arc Center ',x,' ',y); Writeln(stderr,'Radii ',xradius,' ',yradius); Writeln(stderr,'Start ',ActArcCoords.xstart,' ',ActArcCoords.ystart); if not ColorsEqual(truecolor,getpixel(ActArcCoords.xstart,ActArcCoords.ystart)) then Writeln('Start error not set'); Writeln(stderr,'End ',ActArcCoords.xend,' ',ActArcCoords.yend); if not ColorsEqual(truecolor,getpixel(ActArcCoords.xend,ActArcCoords.yend)) then Writeln('End error not set'); Writeln(stderr,'Fill start ',x+round(sin((angle+90)*Pi/180)*XRadius/2),' ', y+round(cos((angle+90)*Pi/180)*YRadius/2)); {$endif GraphDebug} { avoid rounding errors } if abs(ActArcCoords.xstart-ActArcCoords.xend) +abs(ActArcCoords.ystart-ActArcCoords.yend)>2 then FloodFill(x+round(sin((angle+90)*Pi/180)*XRadius/2), y+round(cos((angle+90)*Pi/180)*YRadius/2),truecolor); aktwritemode:=writemode; aktlineinfo:=stline; end; { $Log$ Revision 1.6 1998-11-23 10:04:17 pierre * pieslice and sector work now !! * bugs in text writing removed + scaling for defaultfont added + VertDir for default font added * RestoreCRTMode corrected Revision 1.5 1998/11/20 18:42:05 pierre * many bugs related to floodfill and ellipse fixed Revision 1.4 1998/11/19 15:09:35 pierre * several bugfixes for sector/ellipse/floodfill + graphic driver mode const in interface G800x600x256... + added backput mode as in linux graph.pp (clears the background of textoutput) Revision 1.3 1998/11/19 09:48:46 pierre + added some functions missing like sector ellipse getarccoords (the filling of sector and ellipse is still buggy I use floodfill but sometimes the starting point is outside !!) * fixed a bug in floodfill for patterns (still has problems !!) Revision 1.2 1998/11/18 09:31:30 pierre * changed color scheme all colors are in RGB format if more than 256 colors + added 24 and 32 bits per pixel mode (compile with -dDEBUG) 24 bit mode with banked still as problems on pixels across the bank boundary, but works in LinearFrameBufferMode Look at install/demo/nmandel.pp Revision 1.1.1.1 1998/03/25 11:18:42 root * Restored version Revision 1.3 1998/01/26 11:58:53 michael + Added log at the end Working file: rtl/dos/ppi/arc.ppi description: ---------------------------- revision 1.2 date: 1997/12/01 12:21:27; author: michael; state: Exp; lines: +13 -0 + added copyright reference in header. ---------------------------- revision 1.1 date: 1997/11/27 08:33:51; author: michael; state: Exp; Initial revision ---------------------------- revision 1.1.1.1 date: 1997/11/27 08:33:51; author: michael; state: Exp; lines: +0 -0 FPC RTL CVS start ============================================================================= }