Core Graphics Coordinate System

When overriding drawRect I found that in coordinates, 0.0 is used there as the top left.

But the Apple UIView programming guide says the following:

Some iOS technologies define default coordinate systems whose starting point and orientation are different from those used by UIKit. For example, Core Graphics and OpenGL ES use a coordinate system whose origin lies in the lower left corner of a window or window, and the y axis is directed upward from the screen.

I'm confused; Are they talking about something other than quartz when they refer to Core Graphics here?

+8
ios core-graphics uiview quartz-graphics
source share
3 answers

"Core Graphics" in this documentation means "Quartz", yes. This is just a simplification.

When you create a CGContext yourself, its coordinate system has a beginning in the lower left corner. When UIKit creates a CGContext for drawing in the view, it helps to reset the coordinate system before calling -drawRect:

+7
source share

Core Graphics and Quartz on iOS are the same as in coordinates. iOS Technologies Guide says this:

Core Graphics (also known as Quartz) ...

The Core Graphics framework (CoreGraphics.framework) contains interfaces for the Quartz 2D drawing API. Quartz is the same advanced vector drawing engine used by Mac OS X.

The difference is that, technically, Quartz is a technology or mechanism, and "Core Graphics" is the name of the structure. (Mac OS, of course, has a quartz structure, which is just an umbrella.)

+2
source share

For others who are looking for this topic:

Here is a complete explanation of coordinate systems: Cocoa coordinate systems

It is not entirely useful that they differ from each other. There are methods for converting between coordinate systems at different levels of view in your application! For example, it finds the coordinates of a point that it is on (20,20) in a visible screen in an enlarged image. The result is relative to the start of the enlarged image, which can now be turned off in space.

 croppingFrame.origin = [self convertPoint:CGPointMake(20.0, 20.0) fromCoordinateSpace:(self.window.screen.fixedCoordinateSpace)]; 
+2
source share

All Articles