# drawing ellpise - Xwindows

This is a discussion on drawing ellpise - Xwindows ; Hello Could anyone give me example how to draw ellipse ? Thanx...

1. ## drawing ellpise

Hello
Could anyone give me example how to draw ellipse ?

Thanx

2. ## Re: drawing ellpise

On Mon, 24 Nov 2003 15:01:21 +0100, vertigo wrote:

>Hello
> Could anyone give me example how to draw ellipse ?

Which toolkit would you like?

--
Lew Pitcher
IT Consultant, Enterprise Technology Solutions
Toronto Dominion Bank Financial Group

(Opinions expressed are my own, not my employers')

3. ## Re: drawing ellpise

> Which toolkit would you like?

I tried to use XDrawArc() but it did not worked for me. I always had a
single point only How can i draw ellipse usuing this function ? (or
any other one)

Thanx

4. ## Re: drawing ellpise

vertigo wrote:

>
>
>
>> Which toolkit would you like?

>
> I tried to use XDrawArc() but it did not worked for me. I always had a
> single point only How can i draw ellipse usuing this function ? (or
> any other one)
>
> Thanx

You first have to understand that XDrawArc specifies the arc in 1/64th of a
degree increments. So a 1 degree arc is 64 units, a 2 degrees arc is 128
units, and a full circle is 64 * 360 (23,040) units.

You also have to realize that the arc will be drawn to fit within the
extents of the rectangle formed by (x,y) - (x + width - 1, y + height - 1).
Unlike many graphics libraries, the X and Y coordinates are NOT the center
of the arc. They are the upper left corner of the rectangle that will
contain the arc.

The following will (should) draw an arc starting from the top center (90
degrees) and circling around to the left until terminating at the bottom
center (180 degrees arc length):

If we assume the following variables (taken from my Kt QPainter
implementation [see footnote]):

* m_display = the display variable returned by XOpenDisplay().

* m_window = the handle of the window returned by XCreateWindow() [ or
XCreateSimpleWindow() ].

* m_gc = the handle returned by XCreateGC().

Then the command is:

XDrawArc(m_display,m_window,m_gc,nX,nY,nWidth,nHei ght,90 * 64,180 * 64);

Remember that zero degrees is at the 3 O'Clock position (on the right).
Positive arc values move along the arc in a counter-clockwise direction,
and negative arc values move along the arc in a clockwise direction.

[footnote: My implementation actually multiplies the arc length by 4 since
Qt (and thus Kt) specifies that arc lengths are already 1/16th of a
degree.]