views:

663

answers:

1

I assume that the origin is on the bottom left, and the y-axis expands up, starting from 0. The x-axis expands to the right, starting from 0.

I just ask because I get very weird results from my drawing code... want to make sure that I didn't get this part wrong.

+6  A: 

It depends on where this context is being used. The standard Core Graphics drawing context used on the Mac for view, layer, and image drawing has (0,0) for its bottom left coordinate.

The standard coordinate system on the iPhone is inverted, with the upper left coordinate for a UIView being (0,0). Its backing layer also has those flipped coordinates, so drawing into a context for the view or its layer starts at (0,0) for the upper left. UIImage contexts are also flipped in this manner, but PDF contexts are not.

All of this is documented in various locations within Apple's iPhone programming guides, but it can be a bit confusing to sort out.

Brad Larson