Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Articles
Search: 

How to draw a partial circle or pie in Visual Foxpro?
Gérald Santerre, March 25, 1998
This drawa a partial circle or pie in Visual FoxPro. You can pass the current positions of the center of the circle to trace, the radius of the circle, the start angle, the width of the angle to draw, the line width and a parameter to detect if you want to draw a pie or not.
Summary
This drawa a partial circle or pie in Visual FoxPro. You can pass the current positions of the center of the circle to trace, the radius of the circle, the start angle, the width of the angle to draw, the line width and a parameter to detect if you want to draw a pie or not.
Description
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.
Gérald Santerre, Gerald Santerre enrg.
Gérald Santerre joined the Universal Thread team in November 2001. After the completion of his programming course, he began working for a small shop with FoxPro Windows. A couple of months later, Microsoft launched Visual FoxPro 3 and he started his journey in the world of OOP. He worked for the National Bank of Canada Intranet doing Web programming with VFP. Since January 2001, he became self employed and he has designed some applications for the Nortel Network's, Bombardier's Intranet site and for other customers as well. He is always open to new contract opportunities, so feel free to contact him!
More articles from this author
Gérald Santerre, January 14, 2002
The type of small binary file that come to mind was the cursor files. These littles files that we must copy somewhere on the user machine during install. If you have icons or bitmaps, it's not a problem, the files can be build into the executable. But the cursor must reside on the disk somewhere nea...
Gérald Santerre, February 1, 2002
Gérald Santerre, from the Universal Thread, has interviewed Whil Hentzen, from Hentzenwerke Corporation in mid January. We initiated some topics on the company, the Visual FoxPro book publishing and the Great Lakes Great Database Workshop conference. Who is Whil Hentzen? (Looking over shou...
Gérald Santerre, February 1, 2002
Gérald Santerre, from the Universal Thread, has interviewed Claudio Lassala, from FoxTotal Network in mid January. Claudio Lassala joined the Universal Thread team in January 2002. He has been recently awarded as a VFP MVP. He is involved in various areas such as being the co-editor of the UTMag/Rap...
Gérald Santerre, January 1, 2001
Cet article est un extrait de ce que vous pouvez trouver sur ma home page http://www.total.net/~gersan. Ce site est avant tout un site maison, il est sans prétentions. Si vous y trouvez quelque chose qui vous intéresse, prenez le! BTW, it's all in french!
Gérald Santerre, March 1, 2002
Gérald Santerre, from the Universal Thread, has interviewed John Petersen, president and founder of Main Line Software, Inc., a Philadelphia, Pennsylvania based software application and database design firm. MLSI development platforms include Visual FoxPro, Visual Basic, Access, and SQL-Server in mi...
Gérald Santerre, June 1, 2002
As you may have noticed, Microsoft has recently launched a new community program named ".Net Code Wise Community". Universal Thread has been chosen as a founding member of this program. It was in this context that we have interviewed Josh Levine, the Business Development Manager for MSCOM who helped...
Gérald Santerre, January 1, 2002
Monday, 31 December 2001, I was on my way to go to the new year party with my wife's family and I read a mail from Michel, between other things I see this little sentence: "BTW, have you prepared your profile for the UT Magazine?". Duh! Pardon?... "Sorry, I have send a mes...
Gérald Santerre, June 22, 1997
To start the default web browser and load a location(web page) you can use the Win API function ShellExecute().
Gérald Santerre, June 1, 2002
You spent a lot of time on the Universal Thread on a regular basis. You have noticed that the site is always on evolution. But, do you know who is behind the scene to constantly enhance your experience online? Who is Michel Fournier? After having graduated in computer science in 1987, I m...