Gradient backgrounds are made by drawing thin lines of alternating color repeatedly.
(Note: Increasing the X position by 0.5 units results in the smoothest color transition. The object’s X position actually becomes rounded off.)
Here is the result of the code. (Note which color appears on the top vs. the bottom.)