How does the coordinate system in an CGContextRef look like?(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 中的坐标系是什么样的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:CGContextRef 中的坐标系是什么样的?


- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- Android - 拆分 Drawable 2022-01-01