How to color portions of the screen.

How do I color on a portion of the screen? For example I can use GraphicsDevice.Clear(Color.CornflowerBlue);
to color the entire screen. But what if I only want to color the top upper half of the screen in cornflower blue, and the lower half in a different color? Is there some type of command that would let me specify a rectangle on the screen and to color it a certain color?

If you’re doing 2D you can just draw a stretched texture across whatever portion of the screen you want, then draw your graphics on top of that. You can just create a 1x1 white texture and use that.

For example, draw a red rectangle at the top-left of the screen that’s 500 wide and 200 high.

var pixel = new Texture2D(<whatever this param is>, 1, 1);
pixel.SetData<Color>(new Color[] { Color.White });
...
spriteBatch.Draw(pixel, new Rectangle(0, 0, 500, 200), Color.Red)

If you’re doing 3D, it really depends on what kind of scene you’re drawing.

Cool, thanks. I will give it a try.