Code

Only trace the painted area of the screen with each fill, reducing memory usage.