ADC Home > Reference Library > Technical Q&As > Graphics & Imaging > Quartz >

CGContextClosePath


Q: When do I need to call CGContextClosePath?

A: Unlike ClosePicture and CloseRgn, CGContextClosePath doesn't stop the definition of a path, it adds a line from the current point back to the starting point in order to mathematically close the current subpath.

You can visually but not mathematically close the path yourself by drawing a final line back to the starting point. The difference between a path that is closed manually without calling CGContextClosePath and one that is closed using CGContextClosePath is that the former will have line ends applied at the start and end points while the latter will have line joins applied.

So, call CGContextClosePath when you want the current line join applied to the ends of your path and don't call it when you want the current line end caps applied.


[Oct 02 2001]


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.