Search code examples
iosuibezierpathcgpath

How to get the enclosed subpaths from a CGPath


I am working on a drawing app. I have implemented the drawing string feature using CGPath. The next feature is that I can click on the view. If where I click includes an enclosed area, I can fill it with other colors. I am thinking that I need to get the enclosed subpath first, then fill color to it. Very much appreciate it if anyone can give me any idea. Thanks.

For you to understand it, I post a picture.

enter image description here


Solution

  • Okay, finally I found what I want is the "Flood Fill" Algorithm. If anyone wants to look for the referring article, please see here