How to simplify a single complex UIBezierPath polygon in iOS

后端 未结 3 1716
心在旅途
心在旅途 2020-12-17 01:40

Problem:

I have a user generated polygon (via registering user\'s touches on screen) which can be simple or complex (complex means having unknown number of intersect

3条回答
  •  遥遥无期
    2020-12-17 02:33

    With a little thought:

    1. find the leftmost vertex. It's definitely on the boundary. Start there;
    2. look along the current edge towards the next listed vertex;
    3. check if any of the other edges intersect the one you're looking along;
    4. if so then find the first vertex in front of your current position and move to it;
    5. repeat from (2) with the edge you just transitioned onto;
    6. continue until you get back to the vertex at (1).

    (and see the comment re: an erroneous earlier comment I'd made about getting the path out of a UIBezierPath)

提交回复
热议问题