In iOS, y-axis starts from the top and grows downward. It is the opposite to macOS. What is the rationale and technical advantage behind this change?

softwareengineering.stackexchange https://softwareengineering.stackexchange.com/questions/226529

  •  02-10-2020
  •  | 
  •  

Question

In iOS, the coordinate (0, 0) means the top left corner. In macOS it is the bottom left corner.

What is the Apple's rationale or technical advantage of this coordinate system?

Était-ce utile?

La solution

There are very specific legacy and mathematical reasons why this is the case. Let's go back in time for a bit. It's the 1980s. The Apple Lisa pioneered a visual system known as LisaGraph. This evolved into QuickDraw which was extended as it became obvious that more colors and resolution were needed. QuickDraw was a 2D raster system that had a fixed number of pixels and used a reflected Cartesian system of coordinate numbering with negative numberings being at the left and top and positive being right and bottom. (0,0) would have been the center of the screen.

This system got tossed out the Window when Steve Jobs came back to Apple and brought NeXTStep with him. NeXT had used Display PostScript to power NeWS, its windowing system. Display Postscript uses a vector coordinate system with the lower left corner being (0,0) as this is how vectors are commonly referenced in mathematics.

Thus when it came time to build Quartz for Mac OS, they kept the same coordinate system and vector baseline. You can flip Quartz and Cocoa windows on Mac OS X if you want them to be similar to iOS.

The dominate coordinate system is upper left from Windows and it makes sense that Apple wanted to attract as many people as possible to build apps for its hotly selling tablets and phones. Given that the views can rotate with the phone in iOS but not Mac OS X, it stands to reason that they'd want the coordinate model for iOS to be fixed rather than adjustable.

Autres conseils

The answer is: because they can. Whenever there are 2 or more ways to do something there will be 2 or more ways that it is done.

Seriously though, Y up the page is the maths convention and Y down the page is the natural direction for filling an empty page. Both are arguable.

Other examples include: coords as (X,Y) or (Y,X); rotation origin to right (maths) or up (as in a clock); matrices in row major or column major order. The list is endless.

Licencié sous: CC-BY-SA avec attribution
scroll top