I am making a grid component that will be rather busy graphically. Possibly, there will be a few thousand grid lines in the entire grid, even though only about a tenth will be visible through the viewport.
Should I make it so that only the visible lines are drawn, or does the viewport clip that efficiently behind the scenes?
Also, is there anything to gain from using fillrect (with a 1 pix width) instead of drawLine, if the lines are straightly vertical?
It is often the case with game graphics libs that rect drawing is significantly faster than line drawing.
It will of course clip lines that are offscreen, but obviously there’s always an overhead in calling the drawline method and letting it do the maths to figure out whether it’s onscreen. In this case you’re probably better using Graphics::getClipBounds() to only draw the lines that are needed.
And lines vs rectangles won’t make much difference, but I’d say go for rects.