A bit confused about x and y axis of screen

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

A bit confused about x and y axis of screen

riverfish
I'm about confused about the description of the screen.

From the Screen API:

A library of functions for displaying graphics on the screen. The Hack physical screen consists of 512 rows (indexed 0..511, top to bottom) of 256 pixels each (indexed 0..255, left to right). The top left pixel on the screen is indexed (0,0).

From this description, I glean that the x-axis is 256 pixels long and the y-axis is 512 pixels high.

Yet from doing tests drawing rectangles the size of the screen via:

do Screen.drawRectangle(0, 0, 511, 255);
and
do Screen.drawRectangle(0, 0, 255, 511);

It's clear that the x-axis and y-axis are switched so that th x-axis is actually 512 pixels long and 256 pixels high.

Why is this the case? Is this a typo of some sort?
Reply | Threaded
Open this post in threaded view
|

Re: A bit confused about x and y axis of screen

cadet1620
Administrator
The header comment in the projects/12/Screen.jack file has the dimensions swapped. It should read
/**
 * A library of functions for displaying graphics on the screen.
 * The Hack physical screen consists of 256 rows (indexed 0..255, top to bottom)
 * of 512 pixels each (indexed 0..511, left to right). The top left pixel on 
 * the screen is indexed (0,0).
 */

Thanks for catching this.