Rectangle Drawing Optimisation

Miscellaneous Forums/General Discussion/Rectangle Drawing Optimisation

Grey...

There is an algorithm to do it because I have done such a thing before ( a few years ago actually).

1. Cordon off the whole area of the two rects. Take the MinX, MinY, MaxX and MaxY of the area.

2. Use a scanning function starting at MinX,MinY then simply check if that point is within the area of a rectangle within. If it is, then plot it.

3. Move onto the next point minX+1, MinY etc... Continue until the whole area is done.

Points to note: This method will ensure that you only plot once at a certain point. To increase the speed you can copy a valid plot point (x & y) into an array (instead of plotting) then when scanning has finished you simply read the array and plot all the valid points in one go.