How to determine if there is a break in the picture?

There is a canvas on which the figure is drawn. We need an algorithm to determine if there is one object in the picture or several. Where can you find such an algorithm?
Thank youJavaScript Ian Blair, Nov 19, 2019 
Breadthfirst or depthfirst traversal algorithm. It is also called the fill algorithm. Google. If in one fill you painted over all black pixels, then there is only one shape. Otherwise, if there are several components of interest, there is a gap.Aubrey Preston

regionprops in Matlab (Image Processing toolbox)Anonymous
2 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!