'=========================================================================== ' Subject: CIRCLE DRAWING ROUTINE Date: 06-08-98 (04:14) ' Author: Don Schullian Code: QB, QBasic, PDS ' Origin: d83@ath.forthnet.gr Packet: GRAPHICS.ABC '=========================================================================== DECLARE SUB DRAWcircle (Xcen%, Ycen%, Radius%, Colour%, Sdeg%, Edeg%, Aspect!) DECLARE FUNCTION fDeg2Rad! (Degree!) ' ' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ· GENERIC ' ÚÄÄ´ DASoft ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ· ' ³ ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ Copyright 1998 ³ DATE: 1998-06-06 ÇÄ· ' ³ ³ FILE NAME CIRCLE .QB º by ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÄ º º ' ³ ³ º Don Schullian, Jr. º º ' ³ ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ d83@ath.forthnet.gr º º ' ³ º º ' ³ Public Domain º º ' ³ º º ' ÔÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º ' ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ ' ' This routine draws a circle or arc with or without a pie wedge. The ' parameters are the same as the CIRCLE command with one exception: ' Sdeg% and Edeg% are the starting and ending DEGREEs, not radians. ' (I don't think in radians!) 0 degree is assumed to be at the top of ' the circle and they proceed around the circle clockwise (to the right). ' eg: 90 degrees is EAST, 180 is SOUTH and 270 is WEST. ' ' The STEP value in the FOR/NEXT loop can be adjusted as required depending ' on which screen you are using. I've found that values from -.005 to -0025 ' work with most VESA screens but #13 may not require such fine stepping. ' ' Please, let me know if you experience any problems with this routine. ' ' C'ya, ' ' Don '.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø ' ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø COMMON SHARED pPi!: pPi! = (4 * ATN(1)) SCREEN 12 LINE (320, 0)-(320, 479), 7 LINE (0, 240)-(639, 240), 7 DRAWcircle 320, 240, 140, 14, 0, 0, 1.51 ' complete circle DRAWcircle 320, 240, 205, 13, 81, 163, 1! ' small arc in lower R quad DRAWcircle 320, 240, 130, 12, 175, -40, 1! ' pie shape in upper L quad DRAWcircle 320, 240, 130, 11, 40, 175, 1! ' complete the arc above DRAWcircle 320, 240, 319, 10, 0, 0, .75 ' one BIG mama DO: LOOP UNTIL LEN(INKEY$) SCREEN 0 CLS END ' ------------------------------------------------------------------------- ' -------- see CIRCLE help for parameter details ' ------------------------------------------------------------------------- SUB DRAWcircle (Xcen%, Ycen%, Radius%, Colour%, Sdeg%, Edeg%, Aspect!) IF Aspect! < 0 THEN Xrad! = ABS(Aspect!) * Radius% Yrad! = Radius% ELSE Xrad! = Radius% Yrad! = Aspect! * Radius% END IF Srdn! = fDeg2Rad!(ABS(Sdeg%)) Erdn! = fDeg2Rad!(ABS(Edeg%)) IF Erdn! >= Srdn! THEN Srdn! = Srdn! + 6.28 Xo% = -1 Yo% = -1 FOR Rdn! = Srdn! TO Erdn! STEP -.003 X1% = (Xrad! * COS(Rdn!)) Y1% = (Yrad! * SIN(Rdn!)) IF (X1% <> Xo%) OR (Y1% <> Yo%) THEN Xo% = X1% Yo% = Y1% X1% = Xcen% + X1% Y1% = Ycen% - Y1% PSET (X1%, Y1%), Colour% END IF NEXT IF (Sdeg% < 0) OR (Edeg% < 0) THEN X1% = (Xrad! * COS(Srdn!)) Y1% = (Yrad! * SIN(Srdn!)) X1% = Xcen% + X1% Y1% = Ycen% - Y1% LINE (Xcen%, Ycen%)-(X1%, Y1%), Colour% X1% = (Xrad! * COS(Erdn!)) Y1% = (Yrad! * SIN(Erdn!)) X1% = Xcen% + X1% Y1% = Ycen% - Y1% LINE (Xcen%, Ycen%)-(X1%, Y1%), Colour% END IF END SUB FUNCTION fDeg2Rad! (Degree!) IF Degree! > 89 THEN F! = 2.5 ELSE F! = .5 fDeg2Rad! = (F! * pPi!) - ((pPi! / 180) * Degree!) + .0001 END FUNCTION