I would like to be able to paint filled areas which consist of edges that are lines and arcs. I don't have a problem with convex figures, but I have with concave ones. This is what I want to paint:
I can get the outline painted very easily. I use stroke from QPainterPath which I create as following:
path = QPainterPath()
path.moveTo(v1)
path.lineTo(v2)
path.lineTo(v3)
path.arcTo(v1) #this is simplified
But I can't create a filled area this same way. Because the arc between v3
and v1
has the center outside of the figure. So the filled area is on the left side.
I've tried creating this with cubic Bezier approximation of an arc from this question with some success (left picture). Unfortunately, this approximation isn't perfect and goes crazy (on the left side again) when the arc is more than half of the circle. (right picture)
How to create shapes like on the first picture using QPainterPath
?
I could not reproduce the problem so in this answer I will publish the code I use for my test. Maybe you are incorrectly building the P1P3 curve.