2D coordinate system
Before we start drawing, we need to have some knowledge about the 2D coordinate system. The 2D coordinate system uses two axes: x and y. The point of origin (being x = 0 and y = 0) is located at the top left corner. The x axis starts at 0 and increases to the right, and the y axis also starts at 0, but increases to the bottom. Note that the length of each axis is partly determined by the orientation.
Let's assume we have a device that supports an 800 X 480 resolution. In portrait, the x axis will be 480 pixels and the y axis 800. In landscape, x will be 800 pixels and y 480.
The orientation will change automatically depending on how you hold the device. By default, landscape left and landscape right are supported, as this does not affect our code. If we want to enable portrait as well, we can set the SupportedOrientations
property of the graphics device manager.
graphics.SupportedOrientations = DisplayOrientation.Portrait | DisplayOrientation...