The polygon is outlined in orange, with numbered vertices. The polygon's margin boundary is blue, its padding boundary is green. You can move polygon vertices my dragging them and you can add vertices by clicking on a polygon edge. If you do much experimenting at all, you'll see that the simple algorithm employed here can will fail when the polygon's edges are close enough or short enough for the margin or padding boundaries to self-intersect.