Why is the Java 2D beginning in the upper left corner?

I am not complaining, just wondering. Why does Java use the top left point of the drawing surface as a source? I assume that it is more natural to choose the lower left corner as the beginning and increase in the axis as they rise and to the right (similar to quartz).

+8
java graphics
source share
10 answers

Computer graphics had a beginning in the upper left corner from the very beginning, including QuickDraw. Using the bottom left (as in math) is a PostScript / PDF article. Since Quartz is based on PDF, it uses its coordinates, but it is basically a unique solution among graphic libraries.

+11
source share

He always worked like that.

On build days, each pixel was always in the upper left corner. This was the first pixel or character that the user could read.

This numbering method allows you to have an infinitely long image or text. If you started from the bottom left, and you needed to add a new line, you will have to shift all your things and recalculate the coordinates for everything.

+8
source share

It may also be because of the CRT monitor, where the electron gun draws an image from left to right and from top to bottom.

+4
source share

If you return far enough, as in 1981, you may find some exceptions!
http://central.kaserver5.org/Kasoft/Typeset/BBC/Ch08.html

"Imagine a graphics window that has its edges a, b, c and d of 'graphic blocks' from the lower left corner of the screen (which is always the starting point for graphics)."

+3
source share

may have emerged from a television standard where scanning starts from top to bottom.

+1
source share

I find it compatible with minimizing and maximizing frames. The obvious focus area is where the first word appears on a page written in English, namely, the top left witch is the most natural way, except when it comes to graphical representation of some mathematics in the first quadrant, which became the second with the y axis positive (reflected or rotated 180 ° relative to the origin (I came to this, trying to solve this issue), in fact, the decision was made then long before the computer and age crt

0
source share

With the right coordinate system, when X and Y are located in the upper left corner, Z goes to the screen. The graphics engine can now know points that are far from the screen ... more than Z is farther from the point .... very useful when rendering several objects placed in space, and some objects hide others ...

0
source share
Answers like “always been like that” do not really answer the question “why,” so I am confused by why the main voice answers concern the re-setting of the status quo with additional information.

Eric mentions that "[back] in the days of assembly, the pixel was always in the upper left corner," but he does not mention why. He continues to explain that if we start from the bottom left corner and want to add a new line to the text, then we will have to do this, basically overwriting everything on the screen from bottom to top (if you started from the lower left in the previous time, then you did not leave a place for this new line, the material must be pushed up to add new lines). User Irreputable commented that this only makes sense with some languages ​​(but I don’t know any languages ​​that start from the bottom up, which really matters), and that it doesn’t make much sense when it comes to images or graphics; and I agree that he is right about the latter.

Ubieto gives perhaps the most useful answer: that this is possibly due to the way the electron gun of CRT monitors draws the image from top to bottom, from left to right.

However, all these answers may miss one important point: the reason people ask such a question is that the upper left source of the origin of the axes is not only a point located in the upper left corner, but also because, contrary to Descartes the coordinate system that we all use all the way from elementary school, where the y axis increases up, this computer graphics and the Java coordinate system increase the y axis down! This is one of the harshest and most confusing aspects of this system. If the system had a start in the upper left corner of the screen, but reduced the y axis (and had negative numbers) down, then the electron gun of the CRT electronic monitor would explain the whole secret, at least for me. In the end, we will then understand why the point (0,0) is in the upper left corner, and everything else works as we expect from our mathematical education.

However, this is not the case as in the 2D coordinate system of Java and computer graphics; the y axis of this system increases downward, which is surprising. What for? I think the biggest secret is after we look at CRTs or the origins of screen technology. And trying to answer this question, I can only think of one possibility: computer scientists wanted the 2D graphics system to be simpler and avoid potential confusion, always having a positive x-axis coordinate with a negative y-axis. If we assume that the upper left origin was necessary due to the screen technology of that time with the help of an electron gun (in order to avoid screen tearing using this technology), then we understand that computer scientists had the opportunity:

  • Considering the screen as its fourth quadrant, since the Cartesian coordinate system will have every pixel in this quadrant (on the screen) having a positive x-axis coordinate and a negative y-axis coordinate, for example (5, -5); or

  • They can flip the y axis along the x axis (vertically down), bringing the 1st quadrant down, and each pixel on the screen after that will have both a positive X axis and positive y axis coordinates, like (5.5). Perhaps computer scientists simply saw this as a convenience and a way to do things that minimize confusion; two positive numbers are probably much less confusing and easier to compute and visualize than a positive and negative number.

Thus, there are two aspects of the question: the secret location (0,0) in the upper left corner instead of the lower left position, and the secret of the y axis increases downward. The first riddle is probably best explained by the technology of early monitors, which worked from top to bottom, from left to right. And the second riddle is probably best explained by the desire for simplicity and clarity by adopting a coordinate system with two positive numbers for the x and y coordinates, rather than a potentially confusing system that will constantly rely on the positive coordinate of the x axis, coupled to the negative coordinate of the y axis .

0
source share

Just a choice of implementation. Screen coordinates in windows and other OSs are given the same way, so I assume that they chose this to match the OS choice, which is probably a legacy.

-2
source share

It also has the advantage of being like 2-D arrays in programs, where [0] [0] refers to the top left element.

-2
source share

All Articles