optimization of centroid calculation

optimization for offscreen rendering
made example ui respond faster