# How to create a circle using GeneralPath.

3 replies [Last post]
fordfarline
Offline
Joined: 2006-11-06

Hi everyone!

I have to create a circle or a sector using GeneralPath. This class has two methods for draw it: curveTo an quadTo. My problem is that i donÂ´t know how to calculate the controls points. I read some about Bezier curve, but i donÂ´t undertand it very well.

fordfarline
Offline
Joined: 2006-11-06

Thanks a lot!!!

I use this circle to draw in a flash file, with flagstone. I had to draw circles with start and end angle. I had probed with Arc2D class, but the flash library doesnÂ´t understand this shape all the times. So i decided draw by myself. I have find a url, where explain how to calculate de bezierÂ´s control points, from the url you send.

this is the url http://www.stillhq.com/ctpfaq/2002/03/c1088.html#AEN1212

It had been very useful for me. Thanks again

Hi, why don't you use the Ellipse2D classes ?

Il you can't use these classes, you should take a look at this page :

http://www.whizkidtech.redprince.net/bezier/circle/

The following picture illustrates the solution to draw the quadrant AB :

A = (0,R) ; B = (R,0) ; A' = (R*kappa,R) ; B' = (R,R*kappa)
kappa = 0.5522847498

if you want to draw the circle with center (x,y) and radius R with
GeneralPath, it gives :

GeneralPath circle = new GeneralPath();

circle.moveTo(x, y-R); // move to A
circle.curveTo(x+R*kappa, y-R, x+R, y-R*kappa, x+R, y); // curve to
A', B', B

// Second
circle.curveTo(x+R, y+R*kappa, x+R*kappa, y+R, x, y+R );

// Third
circle.curveTo(x-R*kappa, y+R, x-R, y+R*kappa, x-R, y);

// Last
circle.curveTo(x-R, y-R*kappa, x-R*kappa, y-R, x, y-R );

// Ensure closeness of the circle
circle.closePath;

>Hi everyone!
>
> I have to create a circle or a sector using GeneralPath. This class has two methods for draw it: curveTo an quadTo. My problem is that i donÂ´t know how to calculate the controls points. I read some about Bezier curve, but i donÂ´t undertand it very well.
>
>[Message sent by forum member 'fordfarline' (fordfarline)]
>
>
>===========================================================================
>To unsubscribe, send email to listserv@java.sun.com and include in the body
>of the message "signoff JAVA2D-INTEREST". For general help, send email to
>listserv@java.sun.com and include in the body of the message "help".
>
>
>

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".
[att1.html]
[moz-screenshot.jpg]

Michael Toula

GeneralPath gp = new GeneralPath(new Ellipse2D.Float(x,y, radius,

This will create a circle with a radius of 5.
Mike
******************************************
Michael TOULA
Software Engineer

Dalim Software GmbH
Strassburger Str. 6
D-77694
Kehl am Rhein
GERMANY

tel: +49 7851 919 612
fax: +49 7851 735 76
web: www.dalim.com
******************************************

Sent by: Discussion list for Java 2D API
06/11/06 17:35

Subject
[JAVA2D] How to create a circle using GeneralPath.

Hi everyone!

I have to create a circle or a sector using GeneralPath. This class has
two methods for draw it: curveTo an quadTo. My problem is that i donÂ´t
know how to calculate the controls points. I read some about Bezier curve,
but i donÂ´t undertand it very well.

[Message sent by forum member 'fordfarline' (fordfarline)]