Question

I'm wondering how I should go about drawing a uibezierpath where the stroke width peaks at the center of the arc. Here's an example of what I mean:

Curve

Either I have to go through each point when drawing, and set the stroke width accordingly, or there's an easier way. Can anyone point me in the right direction?

Thanks

Was it helpful?

Solution

You can just draw the two outer paths with no stroke, join them, and then fill in the space between them.

OTHER TIPS

Another way to try this if you're interested:

I ended up getting this to work by creating a loop to draw a couple hundred line segments, and changing the line width accordingly during the draw loop.

To adjust the line width I used the following function: MAX_WIDTH * sinf(M_PI * (i/NUMBER_OF_SEGMENTS)

Looks great and no performance issues as far as I can tell. Worked out particularly well because I already had a list of the points to use on the curve. For other cases I'm guessing it would be better to use sosborn's method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top