>FUNCTION DrawCircle >*||||||||||||||||||||||||||||||| >*| >*| DrawCircle >*| Gérald Santerre >*| 03/1998 >*| >*| Draw circle, arc or pie >*| >*| PARAMETERS: (* = optionnal) >*| >*| CenterX >*| and CenterY = current position of the center of the circle to trace >*| Rayon = Radius of the circle (rayon is raduis in French) >*| DegStart = Start Angle, angle zero is horizontal >*| at the right of the center. >*| Angle is increment by 1 clockwise up to 360 >*| TIP: on a watch, noon is 270, 3 is 0, 6 is 90 and 9 is 180 >*| Opendeg = Width of the Angle to draw (to draw 1/4 pie, Opendeg=90) >*| *LineWidth = Line Width! default=1 >*| *OnActiveForm= Logical, if false, the circle was draw on the main vfp screen >*| if true, the circle ws draw on the _screen.ActiveForm >*| *Pie = Logical, if false, only the arc was drawn (circle if OpenDeg => 360) >*| if true, the shape was close to draw a 'piece of pie' >*| >*|||||||||||||||||||||||||||||||||||||| >LPARAMETERS CenterX,CenterY,Rayon,DegStart,OpenDeg,LineWidht,OnActiveForm,Pie > >*Validate parameters >IF PARAMETERS() < 5 > RETURN .F. >ENDIF > >IF !(TYPE('CenterX')='N' AND TYPE('CenterY')='N' ; > AND TYPE('Rayon')='N' AND TYPE('DegStart')='N' ; > AND TYPE('OpenDeg')='N') > > RETURN .F. >ENDIF > >IF !TYPE('LineWidth')='N' > LineWidth=1 >ENDIF > >*Initialize the virtual paper >IF OnActiveForm > PAPER=_SCREEN.ACTIVEFORM >ELSE > PAPER=_SCREEN >ENDIF > >PAPER.DRAWWIDTH=LineWidht > >*Draw the first side of the pie or set the first point >IF Pie > PAPER.LINE(CenterX,; > CenterY,; > CenterX+(Rayon*COS(DTOR(DegStart))),; > CenterY+(Rayon*SIN(DTOR(DegStart)))) >ELSE > PAPER.CURRENTX=CenterX+(Rayon*COS(DTOR(DegStart))) > PAPER.CURRENTY=CenterY+(Rayon*SIN(DTOR(DegStart))) >ENDIF > >*main loop to draw the arc >FOR angle = DegStart+1 TO DegStart+OpenDeg > PAPER.LINE(CenterX+(Rayon*COS(DTOR(angle))),; > CenterY+(Rayon*SIN(DTOR(angle)))) >ENDFOR > >*close the pie >IF Pie > PAPER.LINE(CenterX,CenterY) >ENDIF > >RETURN .T. >>