1

Using Swift methods touchBegan, touchMoved and touchEnded I save the touch points and than I draw a line using UIGraphicsGetCurrentContext() with methods beginPath(), move(to: Point), addLine(to: Point) and strokePath(). This line is repeated on 4 quadrants plus their negative values, therefore 8 lines are drawn.

Here is an example: Example image

I save this drawing as an Image when the user taps the tick (Done green button at top-right) for later manipulations.

I wonder if it's possible to create e closed path/shape with white pixels enclosed by the black lines. I want to fill the white area with custom color when the user touches inside it.

The shape is created by user input and I have no idea how it would look like.

Would be thankful to whoever finds the time to give it's contribute.

Thank you

ndr.hax
  • 345
  • 3
  • 13

1 Answers1

0

Maybe what you want is the "Flood Fill" algorithm, please see the article.

Changwei
  • 672
  • 1
  • 5
  • 16