How to draw a ring (annulus) in wxWidgets Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
ollydbg23
Super wx Problem Solver
Super wx Problem Solver
Posts: 438
Joined: Fri Dec 12, 2008 10:31 am

How to draw a ring (annulus) in wxWidgets

Post by ollydbg23 »

Hi, I would like to draw a ring or piece of ring (annulus), see http://en.wikipedia.org/wiki/Annulus_%28mathematics%29
I just read the wx documents about Device Context Drawing Functions, I see there is no such function.

Any good suggestions.

PS: what I can think is draw two circles(arcs or elliptic arcs), and the inner one is filled with the background color.

Thanks.
tuli
Knows some wx things
Knows some wx things
Posts: 42
Joined: Sat Dec 03, 2011 3:56 pm

Re: How to draw a ring (annulus) in wxWidgets

Post by tuli »

PS: what I can think is draw two circles(arcs or elliptic arcs), and the inner one is filled with the background color.
probably the easiest way, yes.
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: How to draw a ring (annulus) in wxWidgets

Post by doublemax »

PS: what I can think is draw two circles(arcs or elliptic arcs), and the inner one is filled with the background color.
If you don't need the inner part to be transparent, that works.

Otherwise, it can be done with wxGraphicsContext:

Code: Select all

wxPaintDC dc(this)
wxGraphicsContext *gc = wxGraphicsContext::Create( dc );

gc->SetPen(*wxBLACK_PEN);
gc->SetBrush(*wxRED_BRUSH);
wxGraphicsPath p = gc->CreatePath();
p.AddCircle(100, 100, 100);
p.AddCircle(100, 100,  50);
//gc->StrokePath(p);    // this would just draw two circles
gc->FillPath(p);

delete gc;
Use the source, Luke!
ollydbg23
Super wx Problem Solver
Super wx Problem Solver
Posts: 438
Joined: Fri Dec 12, 2008 10:31 am

Re: How to draw a ring (annulus) in wxWidgets

Post by ollydbg23 »

Thanks you for all your guys' help.
I'm currently use the simplest method(I don't need transparent feature).
Post Reply