CGContextRef 中的坐标系是什么样的? [英] How does the coordinate system in an CGContextRef look like?

查看:39
本文介绍了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 上用于视图、图层和图像绘制的标准核心图形绘制上下文的左下坐标为 (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.

所有这些都是 记录在 Apple 的 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 中的坐标系是什么样的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆