Thanks for the code.
The draw
function is running at 60 times per second, and within that, the fadeIn
function gets called that contains a loop that iterates 255 times. During each iteration, an image is rendered. A protective mechanism identifies it as an infinite loop, which it is not. However, there is a lot of drawing of images.
You can experiment with some optimization that produces the desired effect with less frequent drawing.