CGContextRef中的坐标系怎么样

CGContextRef中的坐标系怎么样

本文介绍了CGContextRef中的坐标系怎么样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我假设原点在左下角,y轴从0开始向上扩展。
x轴从0开始向右扩展。

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.

推荐答案

这取决于使用这个上下文的位置。在Mac上用于视图,图层和图像绘制的标准Core Graphics绘图上下文的左下角坐标为(0,0)。

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.

iPhone上的标准坐标系被反转,UIView的左上角坐标为(0,0)。它的背景层也有那些翻转的坐标,所以绘制到视图或其层的上下文从(0,0)开始为左上角。 UIImage上下文也以这种方式翻转,但PDF上下文不是。

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.

所有这些都是在苹果的iPhone编程指南,但它可能有点混乱的整理。

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

这篇关于CGContextRef中的坐标系怎么样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 07:57