Why is the top left corner of the screen considered to be (0,0) and not the bottom left like in a graph?

  • 1
    Welcome user10646 :) Please start with the tour: video.stackexchange.com/tour and please add the software you are using to the question, because not every rendering software starts at the top left corner. – p2or Apr 8 '15 at 16:12
  • Cinema 4D starts from the center and spirals outwards unless you change the default behavior. – Jason Conrad Apr 9 '15 at 20:53

Probably because TV and CRTs scanned from the top left. Video cards store the screen buffer in this order, too, so scan-out from the screen buffer in left-to-right, top-to-bottom reads sequentially increasing memory addresses. Addressing video RAM as a 2-dimensional array

extern int32_t screenbuf[480][640]; screenbuf[0][0] = RED;

would modify the top-left pixel. My theory is that this led to graphics APIs using coordinate systems with 0,0 at the top left, even device-independent APIs (not 640x480 or whatever), because that choice mirrors direct addressing of video RAM. (and saves one subtraction every time a Y coordinate has to get mapped to a memory address.)

As some comment point out, not ALL graphical coordinate systems have the origin at the top left, but it is extremely common for graphics APIs as well as UIs, and for example window coordinates in the X Window System.

| improve this answer | |
  • There is no real reason, it only depends on the preference of the programmer, because it is mathematically irrelevant calculating the pixel first on the top, bottom, left or right. – p2or Apr 11 '15 at 14:58
  • I had another think about the TV/CRT thing, and realized that video cards scan out in sequential memory order, so video RAM layout matches the 0,0 = top left convention. – Peter Cordes Apr 12 '15 at 1:17
  • Interesting - I assume it's because of consistency and optimisation. Certainly that's real time dependend, but that's my guess... – p2or Apr 13 '15 at 6:51
  • Yeah, designing the graphics hardware to only need to fetch sequential memory addresses to feed the RAMDAC is an optimization. – Peter Cordes Apr 13 '15 at 14:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy