So, let's say I have an array full of objects (lines, circles - as equations) that I want to draw onto an image. They could be in an ordered array, sorted in the same order I want them to appear, say array[0] would be atop all other items in the array when drawn.
So far I can only think of two ways of drawing all of the objects. Both have flaws.
The first is to go through every object, back to front, and draw them with their own methods. This is terribly inefficient if I have lots of overlap on these objects (because there's lots of re-drawing).
The second is to go through every pixel in the image and go through every object in the array in the correct order, seeing if it's present at that pixel using their own methods - if it is, I colour that pixel the colour of the object, then move onto the next pixel. This is terribly inefficient if I have lots of blackspace.
Is there some blaringly obvious solution I'm missing to all of this?
Also, would either benefit from being written to run concurrently more than the other?