what does CloseSubpath () do? 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
czczzzz
Earned a small fee
Earned a small fee
Posts: 20
Joined: Thu May 13, 2021 10:34 am

what does CloseSubpath () do?

Post by czczzzz »

I try to fill some area with color or Gradient one by one, but still can not figure it out what exactly those functions of wxGraphicspath do..... :(
dc.JPG
Right now I just create a lot of paths to do it

(wxGraphicsPath path = gc->CreatePath();
wxGraphicsPath path2 = gc->CreatePath();
wxGraphicsPath path3 = gc->CreatePath();...... :? :? :? )

what excatly CloseSubpath () do???
I read the document and I confused(I try the example,and it seem like that CloseSubpath () do nothing?? )


And Could someone tell is there a good tutorial or example to learn about wxGraphicscontext or wxDC......those things is confused but useful...... :shock: :shock:



sorry for my english
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: what does CloseSubpath () do?

Post by doublemax »

A wxGraphicsPath can contain multiple subpaths. E.g. you could draw 2 individual triangles with lines. But you don't want a line be drawn from the end of the last point of the first triangle to the first point of the seconds triangle. Calling CloseSubpath after the first triangle would solve this.

Looking at your code, i don't think CloseSubpath() is relevant to your issue.
Use the source, Luke!
czczzzz
Earned a small fee
Earned a small fee
Posts: 20
Joined: Thu May 13, 2021 10:34 am

Re: what does CloseSubpath () do?

Post by czczzzz »

Thanks for your explaining!!!

yes,it probably be not really relevant to my issue.....I just tried some triangles,and found that CloseSbupath() is working like "MoveToPoint(0.0,0.0)"......

:shock: :shock:

and I try to do some FillPath(),it seem like that I have to make a new path to do that??????

without a new path:
dc2.JPG
with a new path:
dc3.JPG
Could I achieve the same result like the second one without creating a new path?

It seem like that wxCraphicspath will do some "boolean job" in a same path...... :? :?
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: what does CloseSubpath () do?

Post by doublemax »

I don't think you can use different brushes in the same path. The brush is valid for the whole path when calling FillPath.

In your first version you're drawing the path two times. First after you added the first triangle, and a second time after adding the second triangle.
Use the source, Luke!
czczzzz
Earned a small fee
Earned a small fee
Posts: 20
Joined: Thu May 13, 2021 10:34 am

Re: what does CloseSubpath () do?

Post by czczzzz »

i think I got it [-o< [-o<
Post Reply