Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Core Graphics coordinate system

When overriding drawRect I've found that the coordinates there use 0,0 as the upper left.

But the Apple UIView Programming Guide says this:

Some iOS technologies define default coordinate systems whose origin point and orientation differ 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 the view or window and whose y-axis points upward relative to the screen.

I'm confused; are they talking about something different than Quartz when they refer to Core Graphics here?

like image 256
johnbakers Avatar asked May 02 '12 06:05

johnbakers


People also ask

What is the default coordinate system for core graphics?

The default coordinate system used by Core Graphics framework is LLO-based.

What is Core Graphics framework?

Core Graphics is a low-level 2D graphics framework that allows drawing device independent graphics. All 2D drawing in UIKit uses Core Graphics internally. Core Graphics supports drawing in a number of scenarios including: Drawing to the screen via a UIView . Drawing images in memory or on screen.

What is origin of CGRect?

Overview. In the default Core Graphics coordinate space, the origin is located in the lower-left corner of the rectangle and the rectangle extends towards the upper-right corner.

What is CGPoint?

The data structure CGPoint represents a point in a two-dimensional coordinate system. The data structure CGRect represents the location and dimensions of a rectangle. The data structure CGSize represents the dimensions of width and height.


1 Answers

"Core Graphics" in this documentation means "Quartz", yes. It's just an oversimplification.

When you create a CGContext yourself, its coordinate system has the origin in the bottom-left. When UIKit creates the CGContext for drawing into a view, it helpfully flips the coordinate system before calling -drawRect:.

like image 140
Kurt Revis Avatar answered Oct 12 '22 13:10

Kurt Revis