Currently, the drawing code is very unclear. It needs to be refactored before going further. For instance, the interpolation and scaling code should be removed from drawPixel.