Well, I just figured out the answer of the second question: The syntax of fillRect
should be:
fillRect(x, y, width, height)
The 3rd and 4th parameters should be the rectangle’s width and height, not the coordinates of the bottom-right corner. So the provided code is correct.