Polygons drawing algorithm