# Java: Screen Coordinates

Every computer monitor screen is made of pixels. Each pixel is a small spot on the screen. There are approximately 3 pixels per millimeter, but the number many be slightly bigger or smaller depending on the screen. A typical screen might be 800 pixels wide and 640 pixels high, although screens that are larger or smaller are also common.

## Graphics and Graphics2D classes

These notes are written for the older, simpler, java.awt.Graphics class. The java.awt.Graphics class uses integer numbers of pixels for the coordinates, and has only simple graphics operations. The java.awt.Graphics2 class extends Graphics and allows floating-point coordinates, arbitrary shapes, affine transformations, anti-aliasing, and more. These notes only use the Graphics class.

## x and y coordinates

Java programs use an x,y coordinate system for all their graphic operations. The x coordinate is the pixel distance from the left. The y coordinate is the pixel distance from the top.

Note that the Java y coordinate system, like most other computer graphics systems, is different from the normal math coordinate system where the y coordinate goes up from the bottom.

       +------------------> x coordinate
       |
       |
       |
       |
       V
    y coordinate