move main functionality of FillPolygon to plot.js