You basically have to make a loop, and continuously change the rgb numbers, and the just draw a rectangle with the current color. Ex:
Red 255,0,0
Red Orange 255,100,0
Yellow Orange 255,200,0
Yellow 255,255,0
Lime Yellow 200,255,0
Yellow Green 100,255,0
Green 0,255,0
Turqouise 0,255,100
Aqua 0,200,200
Greenish Blue 0,100,255
Blue 0,0,255
Blue Violet 100,0,255
Violet 200,0,200
Red Violet 255,0,100
Red 255,0,0
And so on. These aren't the exact colors of the Rainbow, because the rainbow uses Magenta, Cyan and Yellow as the base colors, while the computer uses RGB. So you will have to work out exactly how to do this, but here is a start, hopefully.
Red 255,0,0
Red Orange 255,100,0
Yellow Orange 255,200,0
Yellow 255,255,0
Lime Yellow 200,255,0
Yellow Green 100,255,0
Green 0,255,0
Turqouise 0,255,100
Aqua 0,200,200
Greenish Blue 0,100,255
Blue 0,0,255
Blue Violet 100,0,255
Violet 200,0,200
Red Violet 255,0,100
Red 255,0,0
And so on. These aren't the exact colors of the Rainbow, because the rainbow uses Magenta, Cyan and Yellow as the base colors, while the computer uses RGB. So you will have to work out exactly how to do this, but here is a start, hopefully.