Save paint calls by grouping lines to rectangles