开发者

Understanding CGContextMoveToPoint

开发者 https://www.devze.com 2023-02-12 16:29 出处:网络
I\'m trying to understand how the CGContextMoveToPoint function works. B开发者_运维知识库asically, I have a CGPath that I want to draw multiple times at varying y offsets. To do so, I thought I\'d use

I'm trying to understand how the CGContextMoveToPoint function works. B开发者_运维知识库asically, I have a CGPath that I want to draw multiple times at varying y offsets. To do so, I thought I'd use the same CGPath reference and just move the entire context. Drawing the path works great. However, when I use CGContextMoveToPoint(context, 0.0, 100.0) the path doesn't move 100px down like it is supposed to. Adding the line doesn't change anything at all.

What am I doing wrong?


The coordinates you specify, for example in CGContextAddLineTo, is an absolute point not a relative point to the previous point. The best way of moving the entire path, is to translate the coordinate system itself (CGContextTranslateCTM) and draw the path there (and revert the system if needed).

0

精彩评论

暂无评论...
验证码 换一张
取 消