Say I have two-dimensional grid with evenly-spaced integer coordinates, and each grid position (x,y) can either be ON or OFF. Is there a way to define what shape is created by the ON positions, as a list of vertices of the polygon? With the ON grid positions roughly creating the outline of a rectangles or triangle it isn't too hard. With more complex polygons, and perhaps non-convex ones (or perhaps even two polygons side-by-side) I cannot seem to wrap my head around how to approach this.
I've seen algorithms for point-in-polygon but I'm actually looking for the opposite I guess.
It's worth mentioning that no line created by the vertices could overlap a grid point that isn't ON because, well, otherwise it would be on. i.e. if a line overlapped at (2.8, 3.1), this would imply that grid position (2, 3) would have to be on.