Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS - How to fill color in Prescribed area

Tags:

ios

swift

when I touch one place,Within the Prescribed area fill the green color.like this:

like this

and this: enter image description here

click one of the fish,the both fish are red

Now I can only use the scan line seed filling algorithm to identify a closed area, but cannot identify multiple areas。

Like this coral, one click fills in multiple areas

if any one gives solution it would be so great,Thank you. (English is not my native language; please excuse typing errors.)

-----------------------------------------------------------

I have a crude idea.

  1. First find two seed points on the ear(A and B).
  2. Click on the picture, if you find that the stack contains seed point A, calling method floodFill(from: B) continue

but I don't konw how to implementation if you find that the stack contains seed point A in this demo

img

like image 737
make Avatar asked Jul 24 '19 07:07

make


1 Answers

I have solved the problem, this is a Demo

This solution requires fixing two seed points on the leaves。 When a seed point is triggered for coloring, The other one is also coloring. show

If there's a better solution, let me know please.

like image 198
make Avatar answered Oct 24 '22 10:10

make